@SubscribeEvent public void containerOpen(PlayerContainerEvent.Open event) { if(!event.getEntityPlayer().world.isRemote && event.getContainer() instanceof ContainerMercenary) { IInventory iinventory = ((ContainerMerchant) event.getContainer()).getMerchantInventory(); ITextComponent itextcomponent = ((ContainerMercenary) event.getContainer()).mercenary.getDisplayName(); MerchantRecipeList merchantrecipelist =((ContainerMercenary) event.getContainer()).mercenary.getRecipes(event.getEntityPlayer()); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(event.getContainer().windowId); merchantrecipelist.writeToBuf(packetbuffer); ((EntityPlayerMP)event.getEntityPlayer()).connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer)); } } }
/** Drops excess items in case of using vanilla containers. */ @SubscribeEvent public void containerClose(PlayerContainerEvent.Close event) { EntityPlayer player = event.getEntityPlayer(); int size = player.getCapability(GeoCaps.CAP_PLAYER, null) .getInventorySize(); for (int i = size; i < player.inventory.mainInventory.size(); i++) { ItemStack stack = player.inventory.mainInventory.get(i); player.inventory.mainInventory.set(i, ItemStack.EMPTY); if (!stack.isEmpty()) { player.dropItem(stack, true); } } }
@SubscribeEvent public static void onContainerOpen(PlayerContainerEvent.Open event) { Container container = event.getContainer(); if(container instanceof ContainerMerchant) { if(!openContainers.containsKey(container)) openContainers.put((ContainerMerchant) container, new ContainerWrapper((ContainerMerchant) container)); } }
@SubscribeEvent public static void onContainerClose(PlayerContainerEvent.Close event) { Container container = event.getContainer(); if(container instanceof ContainerMerchant) { if(openContainers.containsKey(container)) { openContainers.get(container).resetList(); openContainers.remove(container); } } }
@SubscribeEvent public void onContainerOpened(PlayerContainerEvent.Open event) { if (!SettingsFlags.instance.enableCustomInventory) { return; } try { Container c = event.getContainer(); for (int i = 0; i < c.inventorySlots.size(); ++i) { Slot s = c.inventorySlots.get(i); if (s.getClass().equals(Slot.class) && s.inventory instanceof InventoryPlayer && !(s instanceof ManagedSlot) && s.getSlotIndex() >= 9 && s.getSlotIndex() < 36) { ManagedSlot wrapper = new ManagedSlot(s); c.inventorySlots.remove(i); c.inventorySlots.add(i, wrapper); } } } catch (Exception ex) { ExPMisc.modLogger.log(LogLevel.Error, "ExPetrum was unable to initialize it's inventory system! This is most likely caused by another mod!", ex); } }
@Override public void onEvent(PlayerContainerEvent.Open event) { if (this.allowedInteractions.containsKey(event.getEntityPlayer())) { if (this.allowedInteractions.get(event.getEntityPlayer()) == event.getEntityPlayer().openContainer) event.setResult(Result.ALLOW); else this.allowedInteractions.remove(event.getEntityPlayer()); } }
@SubscribeEvent public void onPlayerTick(PlayerContainerEvent.Open event) { event.getContainer(); }
@SubscribeEvent public void container(PlayerContainerEvent.Open event) { if (!event.getEntityPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals("none")) { event.getEntityPlayer().closeScreen(); } }