Java 类net.minecraftforge.event.entity.player.PlayerContainerEvent 实例源码

项目:Mods    文件:TF2EventsCommon.java   
@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));
        }
    }
}
项目:geomastery    文件:PlayerEvents.java   
/** 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);
        }
    }
}
项目:Soot    文件:VillagerAntimonyHandler.java   
@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));
    }
}
项目:Soot    文件:VillagerAntimonyHandler.java   
@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);
        }
    }
}
项目:ExPetrum    文件:ExPHandlerServer.java   
@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);
    }
}
项目:morecommands    文件:CommandOpen.java   
@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());
    }
}
项目:Fallout_Equestria    文件:EventHandlerPre.java   
@SubscribeEvent
public void onPlayerTick(PlayerContainerEvent.Open event) {
    event.getContainer();
}
项目:Kingdom-Keys-Re-Coded    文件:EntityEvents.java   
@SubscribeEvent
public void container(PlayerContainerEvent.Open event) {
    if (!event.getEntityPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals("none")) {
        event.getEntityPlayer().closeScreen();
    }
}