Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package halestormxv.eAngelus.items;
- import halestormxv.eAngelus.main.Reference;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockChest;
- 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.ActionResult;
- import net.minecraft.util.EnumActionResult;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.text.TextComponentString;
- import net.minecraft.world.World;
- /**
- * Created by Blaze on 8/24/2017.
- */
- public class MysticKeystone extends Item
- {
- public MysticKeystone(String name)
- {
- super();
- this.setUnlocalizedName(name);
- this.setCreativeTab(Reference.eaCreativeTab);
- }
- public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
- {
- if (!world.isRemote)
- {
- ItemStack stack = player.getHeldItem(hand);
- Block b = world.getBlockState(pos).getBlock();
- if ((b instanceof BlockChest))
- {
- TileEntity tileChest = world.getTileEntity(pos);
- NBTTagCompound tileTag = tileChest.getTileData();
- if ((tileTag.hasKey("divinationLock_k_kname")) && (tileTag.getString("divinationLock_k_kname").equals(stack.getDisplayName())))
- {
- tileTag.removeTag("divinationLock_k_kname");
- tileTag.removeTag("divinationLock_k_pname");
- tileTag.removeTag("divinationLock");
- player.sendMessage(new TextComponentString("The Mystic Bindings dispel."));
- }
- else
- {
- tileTag.setString("divinationLock_k_kname", stack.getDisplayName());
- //tileTag.setString("divinationLock_k_pname", player.getPersistentID().toString());
- tileTag.setString("divinationLock_k_pname", player.getName());
- //tileTag.setString("divinationLock", player.getName());
- tileTag.setString("divinationLock", player.getName());
- player.sendMessage(new TextComponentString("Mystic Bindings have been placed on the chest."));
- }
- }
- else
- {
- System.out.println("Not a chest silly.");
- }
- }
- return EnumActionResult.PASS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement