本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerOpenContainerEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerOpenContainerEvent类的具体用法?Java PlayerOpenContainerEvent怎么用?Java PlayerOpenContainerEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerOpenContainerEvent类属于net.minecraftforge.event.entity.player包,在下文中一共展示了PlayerOpenContainerEvent类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playerHasContainerOpen
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
/**
* 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());
}
}
示例2: playerOpenContainerEvent
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
@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!");
}
}
示例3: containerOpen
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
@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);
}
示例4: onPlayerOpenContainer
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
@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);
}
}
}
示例5: canInteractWith
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
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;
}
示例6: open
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
@SubscribeEvent
public void open (PlayerOpenContainerEvent event)
{
}