net.minecraftforge.event.entity.player.PlayerDestroyItemEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.player.PlayerDestroyItemEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemBreakingTracker.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SubscribeEvent public void onPlayerDestroyItem(PlayerDestroyItemEvent ev) { if (!ConfigManager.SERVER.enableScraping.get()) return; if (ev.getPlayer().world.isRemote) return; ItemStack stack = ev.getOriginal(); if (stack.isEmpty()) return; Item item = stack.getItem(); if (!(item instanceof TieredItem)) return; onItemBroken(ev.getPlayer(), stack); }
Example #2
Source File: SlotPottery.java From GardenCollection with MIT License | 5 votes |
@Override public void onPickupFromSlot (EntityPlayer player, ItemStack itemStack) { FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, inputInventory); onCrafting(itemStack); ItemStack itemTarget = inputInventory.getStackInSlot(1); if (itemTarget != null) { inputInventory.decrStackSize(1, 1); if (itemTarget.getItem().hasContainerItem(itemTarget)) { ItemStack itemContainer = itemTarget.getItem().getContainerItem(itemTarget); if (itemContainer != null && itemContainer.isItemStackDamageable() && itemContainer.getItemDamage() > itemContainer.getMaxDamage()) { MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.player, itemContainer)); return; } if (!itemTarget.getItem().doesContainerItemLeaveCraftingGrid(itemTarget) || !this.player.inventory.addItemStackToInventory(itemContainer)) { if (inputInventory.getStackInSlot(1) == null) inputInventory.setInventorySlotContents(1, itemContainer); else this.player.dropPlayerItemWithRandomChoice(itemContainer, false); } } } ItemStack itemPattern = inputInventory.getStackInSlot(0); if (itemPattern != null && itemPattern.getItem() == Items.dye) { inputInventory.decrStackSize(0, 1); } }
Example #3
Source File: RewardForPossessingItemImplementation.java From malmo with MIT License | 4 votes |
@SubscribeEvent public void onDestroyItem(PlayerDestroyItemEvent event) { if (event.getEntityPlayer() instanceof EntityPlayerMP) removeCollectedItemCount(event.getOriginal()); }
Example #4
Source File: AgentQuitFromPossessingItemImplementation.java From malmo with MIT License | 4 votes |
@SubscribeEvent public void onDestroyItem(PlayerDestroyItemEvent event) { if (event.getEntityPlayer() instanceof EntityPlayerMP) removeCollectedItemCount(event.getOriginal()); }
Example #5
Source File: FMPPlacementListener.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
public static boolean place(EntityPlayer player, World world){ MovingObjectPosition hit = RayTracer.reTrace(world, player); if(hit == null) return false; BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ); ItemStack held = player.getHeldItem(); PartPressureTube part = null; if(held == null) return false; Block heldBlock = Block.getBlockFromItem(held.getItem()); if(heldBlock == Blockss.pressureTube) { part = new PartPressureTube(); } else if(heldBlock == Blockss.advancedPressureTube) { part = new PartAdvancedPressureTube(); } if(part == null) return false; if(world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff { Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ); Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ); if(!ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float)f.x, (float)f.y, (float)f.z)) { player.swingItem(); PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement(hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float)f.x, (float)f.y, (float)f.z)); return true; } } TileMultipart tile = TileMultipart.getOrConvertTile(world, pos); if(tile == null || !tile.canAddPart(part)) { pos = pos.offset(hit.sideHit); tile = TileMultipart.getOrConvertTile(world, pos); if(tile == null || !tile.canAddPart(part)) return false; } if(!world.isRemote) { TileMultipart.addPart(world, pos, part); world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, Blockss.pressureTube.stepSound.func_150496_b(), (Blockss.pressureTube.stepSound.getVolume() + 1.0F) / 2.0F, Blockss.pressureTube.stepSound.getPitch() * 0.8F); if(!player.capabilities.isCreativeMode) { held.stackSize--; if(held.stackSize == 0) { player.inventory.mainInventory[player.inventory.currentItem] = null; MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held)); } } } else { player.swingItem(); NetworkHandler.sendToServer(new PacketFMPPlacePart()); } return true; }