From 9440f8cceb99a7e419fd32ab6425e5464e6c1218 Mon Sep 17 00:00:00 2001 From: EdwinMindcraft Date: Mon, 5 Feb 2018 22:01:12 +0100 Subject: [PATCH] Fixed Keystone Recepticles and Gateways. Thank to BlackJac on Discord :stuck_out_tongue: --- .gitignore | 2 +- .../TileEntityKeystoneRecepticle.java | 39 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 28ff8b1e2..13d381fa9 100644 --- a/.gitignore +++ b/.gitignore @@ -45,5 +45,5 @@ LICENSE-fml.txt MinecraftForge-Credits.txt MinecraftForge-License.txt *.launch -build_travis.sh +build_travis.* build.bat diff --git a/src/main/java/am2/common/blocks/tileentity/TileEntityKeystoneRecepticle.java b/src/main/java/am2/common/blocks/tileentity/TileEntityKeystoneRecepticle.java index e7444e2e7..f2543b66c 100644 --- a/src/main/java/am2/common/blocks/tileentity/TileEntityKeystoneRecepticle.java +++ b/src/main/java/am2/common/blocks/tileentity/TileEntityKeystoneRecepticle.java @@ -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; @@ -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); @@ -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... @@ -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); } @@ -501,7 +506,7 @@ public AxisAlignedBB getRenderBoundingBox(){ @Override public int getChargeRate(){ - return 5; + return 200; //A whole lot of nope. } @Override