SHARE
TWEET

Untitled

a guest Jun 12th, 2019 139 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.izako.HunterX.events;
  2.  
  3. import com.izako.HunterX.init.ModItems;
  4.  
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.inventory.EntityEquipmentSlot;
  7. import net.minecraft.inventory.IInventory;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.text.TextComponentString;
  10. import net.minecraft.world.World;
  11. import net.minecraftforge.event.entity.player.PlayerInteractEvent;
  12. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  13.  
  14. public class HanzoArmorBaseEvent {
  15.  
  16.     public static int itemArea = 0;
  17.  
  18.     public static void removeItem(EntityPlayer ep, ItemStack removeitem) {
  19.         IInventory inv = ep.inventory;
  20.         for (int i = 0; i < inv.getSizeInventory(); i++) {
  21.             if (inv.getStackInSlot(i) != null) {
  22.                 ItemStack j = inv.getStackInSlot(i);
  23.                 if (j.getItem() != null && j.getItem() == removeitem.getItem()) {
  24.                     inv.removeStackFromSlot(i);
  25.                     itemArea = i;
  26.                 }
  27.             }
  28.         }
  29.     }
  30.  
  31.     @SubscribeEvent
  32.     public void hanzoArmorBaseEvent(PlayerInteractEvent event) {
  33.         EntityPlayer playerIn = event.getEntityPlayer();
  34.         World world = event.getWorld();
  35.         ItemStack sword = new ItemStack(ModItems.HANZOS_SWORD);
  36.         ItemStack chest = playerIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
  37.         if(!world.isRemote) {if ((event instanceof PlayerInteractEvent.RightClickEmpty || event instanceof PlayerInteractEvent.RightClickBlock) && chest.getItem().equals(ModItems.HANZOS_CHESTPLATE) && playerIn.inventory.getCurrentItem().isEmpty()
  38.                 && playerIn.isSneaking() && playerIn.inventory.getStackInSlot(itemArea).isEmpty()){
  39.             playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, sword);
  40.         } else if ((event instanceof PlayerInteractEvent.LeftClickEmpty || event instanceof PlayerInteractEvent.LeftClickBlock)&& chest.getItem().equals(ModItems.HANZOS_CHESTPLATE) && playerIn.isSneaking()
  41.                 && playerIn.inventory.getStackInSlot(itemArea).getItem().equals(ModItems.HANZOS_SWORD)) {
  42.  
  43.             this.removeItem(playerIn, sword);
  44.         }
  45.        
  46. }
  47. }}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top