Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

IamP

Members
  • Posts

    3
  • Joined

  • Last visited

IamP's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. IamP

    .

    It's work now.
  2. IamP

    .

    Thanks for your recommendation
  3. IamP

    .

    this is my code @SubscribeEvent public void checkItem(BlockEvent.EntityPlaceEvent event) { if (!event.getWorld().isRemote()) { if (event.getEntity() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntity(); Hand hand = player.getActiveHand(); ItemStack stack = player.getHeldItem(hand); System.out.println(stack); if (stack.getCount() == 1) { System.out.println(stack); int i = this.findItem(player, stack.getItem().getItem()); if (i != -1) { ItemStack item = player.inventory.mainInventory.get(i); player.inventory.mainInventory.set(i, ItemStack.EMPTY); player.setHeldItem(hand, item); System.out.println(stack + " 1"); } } } } } public int findItem(PlayerEntity player, Item item) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.mainInventory.get(i); if (!stack.isEmpty() && stack.getItem().getItem() == item) { return i; } } return -1; }
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.