Skip to content

Commit

Permalink
Fixed Keystone Recepticles and Gateways.
Browse files Browse the repository at this point in the history
Thank to BlackJac on Discord 😛
  • Loading branch information
EdwinMindcraft committed Feb 5, 2018
1 parent ed88ddd commit 9440f8c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ LICENSE-fml.txt
MinecraftForge-Credits.txt
MinecraftForge-License.txt
*.launch
build_travis.sh
build_travis.*
build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.potion.Potion;
import net.minecraft.stats.StatList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
Expand Down Expand Up @@ -212,8 +214,6 @@ public void update(){
if (entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)entity;
if (player.isPotionActive(PotionEffectsDefs.HASTE) && player.isPotionActive(Potion.getPotionFromResourceLocation("speed")) && player.isSprinting()){
//if (worldObj.isRemote)
//player.addStat(ArsMagica2.achievements.EightyEightMilesPerHour, 1);
this.key = 0;
if (!worldObj.isRemote){
EntityLightningBolt elb = new EntityLightningBolt(worldObj, pos.getX(), pos.getY(), pos.getZ(), false);
Expand Down Expand Up @@ -272,11 +272,10 @@ private void doTeleport(Entity entity){

AMVector3 newLocation = ArsMagica2.proxy.blocks.getNextKeystonePortalLocation(this.worldObj, pos, false, this.key);
AMVector3 myLocation = new AMVector3(pos);

double distance = myLocation.distanceTo(newLocation);
float essenceCost = (float)(Math.pow(distance, 2) * 0.00175f);
float essenceCost = (float)(distance * distance * 0.00175f);

int meta = getBlockMetadata();
EnumFacing facing = worldObj.getBlockState(newLocation.toBlockPos()).getValue(BlockKeystoneReceptacle.FACING);

if (ArsMagica2.config.getHazardousGateways()){
//uh-oh! Not enough power! The teleporter will still send you though, but I wonder where...
Expand All @@ -293,38 +292,44 @@ private void doTeleport(Entity entity){
double newX = myLocation.x + (Math.cos(angleH) * distanceWeCanGo);
double newZ = myLocation.z + (Math.sin(angleH) * distanceWeCanGo);
double newY = myLocation.y;

while (worldObj.isAirBlock(new BlockPos(newX, newY, newZ))){
while (!worldObj.isAirBlock(new BlockPos(newX, newY, newZ))){
newY++;
}

newLocation = new AMVector3(newX, newY, newZ);
}
}else{
this.worldObj.playSound(newLocation.x, newLocation.y, newLocation.z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0F, 1.0F, true);
return;
//this.worldObj.playSound(newLocation.x, newLocation.y, newLocation.z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0F, 1.0F, true);
//return;
}


float newRotation = 0;
switch (meta){
case 0:
switch (facing){
case EAST:
newRotation = 270;
break;
case 1:
case NORTH:
newRotation = 180;
break;
case 2:
case WEST:
newRotation = 90;
break;
case 3:
case SOUTH:
newRotation = 0;
break;
default:
break;
}
entity.setPositionAndRotation(newLocation.x + 0.5, newLocation.y - entity.height, newLocation.z + 0.5, newRotation, entity.rotationPitch);
//entity.setPositionAndRotation(newLocation.x + 0.5, newLocation.y - entity.height, newLocation.z + 0.5, newRotation, entity.rotationPitch);
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).addStat(StatList.getObjectUseStats(Item.getItemFromBlock(blockType)));

PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(this.worldObj).getHighestPowerType(this), essenceCost);


entity.rotationYaw = newRotation;
entity.setPositionAndUpdate(newLocation.x + 0.5F, newLocation.y - entity.height, newLocation.z + 0.5);
this.worldObj.playSound(myLocation.x, myLocation.y, myLocation.z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0F, 1.0F, true);
this.worldObj.playSound(newLocation.x, newLocation.y, newLocation.z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0F, 1.0F, true);
}
Expand Down Expand Up @@ -501,7 +506,7 @@ public AxisAlignedBB getRenderBoundingBox(){

@Override
public int getChargeRate(){
return 5;
return 200; //A whole lot of nope.
}

@Override
Expand Down

0 comments on commit 9440f8c

Please sign in to comment.