本文整理汇总了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());
}
}
开发者ID:thebombzen,项目名称:EnchantView,代码行数:35,代码来源:EnchantView.java
示例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!");
}
}
开发者ID:unitedworldminers,项目名称:ClaimIO,代码行数:8,代码来源:EventBus.java
示例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);
}
开发者ID:zmaster587,项目名称:AdvancedRocketry,代码行数:10,代码来源:PlanetEventHandler.java
示例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);
}
}
}
开发者ID:andykuo1,项目名称:mcplus_mods,代码行数:37,代码来源:EventHandlerRotten.java
示例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;
}
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:7,代码来源:ForgeHooks.java
示例6: open
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; //导入依赖的package包/类
@SubscribeEvent
public void open (PlayerOpenContainerEvent event)
{
}
开发者ID:GenDeathrow,项目名称:Skills,代码行数:5,代码来源:EventHandler.java
注:本文中的net.minecraftforge.event.entity.player.PlayerOpenContainerEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论