From 06f724de78a8b78a8971a7d645341fd1d70b9518 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Fri, 2 Aug 2013 02:55:39 -0400 Subject: [PATCH] Entangler now teleports! Done for the night, signing off. Lots of work to do tomorrow! --- .../entangler/ItemQuantumEntangler.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/resonantinduction/entangler/ItemQuantumEntangler.java b/src/resonantinduction/entangler/ItemQuantumEntangler.java index 120828092..b828b6e3a 100644 --- a/src/resonantinduction/entangler/ItemQuantumEntangler.java +++ b/src/resonantinduction/entangler/ItemQuantumEntangler.java @@ -5,6 +5,7 @@ import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -24,7 +25,7 @@ public class ItemQuantumEntangler extends ItemBase { super("entangler", id); setMaxStackSize(1); - //TODO Icon, energy + //TODO Handheld model, render animation, energy usage (should be easy?) } @Override @@ -50,18 +51,17 @@ public class ItemQuantumEntangler extends ItemBase { if(!world.isRemote) { - for(int yCount = y+1; yCount < 255; yCount++) + if(world.isAirBlock(x, y+1, z) && world.isAirBlock(x, y+2, z)) { - if(!world.isAirBlock(x, yCount, z)) - { - return false; - } + int dimID = world.provider.dimensionId; + + entityplayer.addChatMessage("Bound Entangler to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'"); + setBindVec(itemstack, new Vector3(x, y, z), dimID); + + return true; } - entityplayer.addChatMessage("Binded Entangler to block [" + x + ", " + y + ", " + z + "]"); - setBindVec(itemstack, new Vector3(x, y, z), world.provider.dimensionId); - - return true; + entityplayer.addChatMessage("Error: invalid block for binding!"); } return false; @@ -78,7 +78,21 @@ public class ItemQuantumEntangler extends ItemBase return itemstack; } - //TODO teleport to coords, dimension + //TELEPORT// + + Vector3 vec = getBindVec(itemstack); + int dimID = getDimID(itemstack); + + //travel to dimension if different dimID + if(world.provider.dimensionId != dimID) + { + ((EntityPlayerMP)entityplayer).travelToDimension(dimID); + } + + //actually teleport to new coords + ((EntityPlayerMP)entityplayer).playerNetServerHandler.setPlayerLocation(vec.x+0.5, vec.y+1, vec.z+0.5, entityplayer.rotationYaw, entityplayer.rotationPitch); + + world.playSoundAtEntity(entityplayer, "mob.endermen.portal", 1.0F, 1.0F); } return itemstack;