Entangler now teleports!

Done for the night, signing off. Lots of work to do tomorrow!
This commit is contained in:
Aidan Brady 2013-08-02 02:55:39 -04:00
parent 1323384a80
commit 06f724de78

View file

@ -5,6 +5,7 @@ import java.util.List;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -24,7 +25,7 @@ public class ItemQuantumEntangler extends ItemBase
{ {
super("entangler", id); super("entangler", id);
setMaxStackSize(1); setMaxStackSize(1);
//TODO Icon, energy //TODO Handheld model, render animation, energy usage (should be easy?)
} }
@Override @Override
@ -50,20 +51,19 @@ public class ItemQuantumEntangler extends ItemBase
{ {
if(!world.isRemote) 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)) int dimID = world.provider.dimensionId;
{
return false;
}
}
entityplayer.addChatMessage("Binded Entangler to block [" + x + ", " + y + ", " + z + "]"); entityplayer.addChatMessage("Bound Entangler to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'");
setBindVec(itemstack, new Vector3(x, y, z), world.provider.dimensionId); setBindVec(itemstack, new Vector3(x, y, z), dimID);
return true; return true;
} }
entityplayer.addChatMessage("Error: invalid block for binding!");
}
return false; return false;
} }
@ -78,7 +78,21 @@ public class ItemQuantumEntangler extends ItemBase
return itemstack; 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; return itemstack;