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

项目:EnchantView    文件:EnchantView.java   
/**
 * This is the main event ticker. It only ticks when the player has an open container so we can rule out other ticks.
 * The player usually has an open container (the inventory) but we can simple check for that and return.
 * This also ticks once per player rather than once per World or once per MinecraftServer, so it provides an extra layer of convenience.
 */
@SubscribeEvent
public void playerHasContainerOpen(PlayerOpenContainerEvent event){
    UUID uuid = event.getEntityPlayer().getUniqueID();
    // If the inventory is not a crafting inventory then clear stuff.
    if (!(event.getEntityPlayer().openContainer instanceof ContainerEnchantment)){
        purgeUUID(uuid);
        return;
    }
    ContainerEnchantment container = (ContainerEnchantment)event.getEntityPlayer().openContainer;

    if (!tickTimes.containsKey(uuid)){
        tickTimes.put(uuid, 0L);
    }
    // We set it to zero and immediately increment it so waiting a second
    // is guaranteed. This is simpler than just setting it to one.
    tickTimes.put(uuid, tickTimes.get(uuid) + 1L);

    // We have to check for OnCraftMatrixChanged manually.
    TableState state = new TableState(container);
    if (!prevTableStates.containsKey(uuid) || !prevTableStates.get(uuid).equals(state)){
        prevTableStates.put(uuid, state);
        tableUpdated(event.getEntityPlayer());
    }

    // 20 ticks is one second.
    if (tickTimes.get(uuid) % 20L == 0L){
        cycleHint(event.getEntityPlayer());
    }
}
项目:ClaimIO    文件:EventBus.java   
@SubscribeEvent
public void playerOpenContainerEvent(PlayerOpenContainerEvent event) {
    if (CoreClaim.claimManager.checkEventCancel(event.entityPlayer, (int) event.entity.posX, (int) event.entity.posZ)) {
        event.setCanceled(true);
        Utils.messageToPlayer(event.entityPlayer, EnumChatFormatting.RED + "Oh snap, you are not allowed to open this!");
    }
}
项目:AdvancedRocketry    文件:PlanetEventHandler.java   
@SubscribeEvent
public void containerOpen(PlayerOpenContainerEvent event) {
    //event.entityPlayer.openContainer
    if(canPlayerBypassInvChecks(event.entityPlayer))
        if(event.entityPlayer.openContainer.windowId == 0)
            removePlayerFromInventoryBypass(event.entityPlayer);
        else
            event.setResult(Result.ALLOW);
}
项目:mcplus_mods    文件:EventHandlerRotten.java   
@SubscribeEvent
public void onPlayerOpenContainer(PlayerOpenContainerEvent parEvent)
{
    World world = parEvent.entity.worldObj;
    if ((int)world.getWorldTime() % TICK != 0) return;

    Container container = parEvent.entityPlayer.openContainer;

    for(int i = 0; i < container.inventorySlots.size(); ++i)
    {
        Slot slot = container.getSlot(i);
        ItemStack itemstack = slot.getStack();

        if (itemstack != null && isRotItem(itemstack.getItem()))
        {
            int time = getTime(world);
            NBTTagCompound tagcompound = itemstack.getTagCompound();
            if (tagcompound == null) itemstack.setTagCompound(tagcompound = new NBTTagCompound());

            if (!tagcompound.hasKey("rottime"))
            {
                tagcompound.setInteger("rottime", time);
            }
            else
            {
                int newTime = getTotalRotTime(world, itemstack);
                if (newTime < 0)
                {
                    tagcompound.setInteger("rottime", newTime = newTime - getSavedRotTime(world, itemstack));
                }
            }

            tagcompound.setInteger("worldtime", time);
        }
    }
}
项目:TRHS_Club_Mod_2016    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:CauldronGit    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:Skills    文件:EventHandler.java   
@SubscribeEvent
public void open (PlayerOpenContainerEvent event)
{
}
项目:Cauldron    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:Cauldron    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:Cauldron    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:RuneCraftery    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:RuneCraftery    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
项目:BetterNutritionMod    文件:ForgeHooks.java   
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
    PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}