SHARE
TWEET

Untitled

a guest Jun 12th, 2019 117 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  int itemArea = 0;
  17.     public  int isSpawned = 0;
  18.  
  19.     public void removeItem(EntityPlayer ep, ItemStack removeitem) {
  20.         IInventory inv = ep.inventory;
  21.         for (int i = 0; i < inv.getSizeInventory(); i++) {
  22.             if (inv.getStackInSlot(i) != null) {
  23.                 ItemStack j = inv.getStackInSlot(i);
  24.                 if (j.getItem() != null && j.getItem() == removeitem.getItem()) {
  25.                     inv.removeStackFromSlot(i);
  26.                     itemArea = i;
  27.                 }
  28.             }
  29.         }
  30.     }
  31.  
  32.     @SubscribeEvent
  33.     public void hanzoArmorBaseEvent(PlayerInteractEvent.RightClickEmpty event) {
  34.         EntityPlayer playerIn = event.getEntityPlayer();
  35.         World world = event.getWorld();
  36.         ItemStack sword = new ItemStack(ModItems.HANZOS_SWORD);
  37.         ItemStack chest = playerIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
  38.         if(!world.isRemote) {if (chest.getItem().equals(ModItems.HANZOS_CHESTPLATE) && playerIn.inventory.getCurrentItem().isEmpty()
  39.                 && playerIn.isSneaking() && (isSpawned == 0 || playerIn.inventory.getStackInSlot(itemArea).isEmpty())) {
  40.             playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, sword);
  41.             isSpawned = 1;
  42.             playerIn.sendMessage(new TextComponentString("if"));
  43.         } else if (chest.getItem().equals(ModItems.HANZOS_CHESTPLATE) && playerIn.isSneaking() && (isSpawned == 1
  44.                 || playerIn.inventory.getStackInSlot(itemArea).getItem().equals(ModItems.HANZOS_SWORD))) {
  45.  
  46.             this.removeItem(playerIn, sword);
  47.             isSpawned = 0;
  48.             playerIn.sendMessage(new TextComponentString("else if"));
  49.         }
  50.         }
  51.     }
  52. }
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