Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package alexsocol.osm.items;
- import java.util.List;
- import alexsocol.osm.ModInfo;
- import alexsocol.osm.OSMMain;
- import alexsocol.osm.blocks.tileentity.PortalInTileEntity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.MovingObjectPosition;
- import net.minecraft.util.Vec3;
- import net.minecraft.world.World;
- public class PortalConnectingModule extends Item {
- public PortalConnectingModule() {
- this.setCreativeTab(OSMMain.osmTab);
- this.setTextureName(ModInfo.MODID + ":PortalConnectingModule");
- this.setUnlocalizedName("PortalConnectingModule");
- }
- @Override
- public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
- if (!world.isRemote){
- if (player.isSneaking()){
- stack.stackTagCompound = new NBTTagCompound();
- stack.stackTagCompound.setDouble("telepX", x + 0.5);
- stack.stackTagCompound.setDouble("telepY", y + 1);
- stack.stackTagCompound.setDouble("telepZ", z + 0.5);
- }
- if (!player.isSneaking()){
- TileEntity tile = world.getTileEntity(x, y, z);
- if (tile instanceof PortalInTileEntity){
- PortalInTileEntity portal = (PortalInTileEntity)tile;
- portal.CordX = stack.stackTagCompound.getDouble("telepX");
- portal.CordY = stack.stackTagCompound.getDouble("telepY");
- portal.CordZ = stack.stackTagCompound.getDouble("telepZ");
- }
- }
- }
- return true;
- }
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
- if (stack.stackTagCompound != null) {
- list.add("X: " + stack.stackTagCompound.getDouble("telepX"));
- list.add("Y: " + stack.stackTagCompound.getDouble("telepY"));
- list.add("Z: " + stack.stackTagCompound.getDouble("telepZ"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment