本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.getItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.getItemStack方法的具体用法?Java PlayerInteractEvent.getItemStack怎么用?Java PlayerInteractEvent.getItemStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent.getItemStack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockInteract
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockInteract(PlayerInteractEvent event) {
cachedItem = event.getItemStack();
cachedBlockPos = event.getPos();
IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(event.getPos());
Material mat = state.getMaterial();
cachedVariant = state.getBlock().getMetaFromState(state);
// we use this to detect the material of a broken block, so we want to ignore air, because otherwise this would
// always be set to air at the point we handle a block break
if (mat != Material.AIR) {
cachedMaterial = mat;
}
}
示例2: playerInteractEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void playerInteractEvent(PlayerInteractEvent event)
{
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getItemStack();
if (stack.isEmpty() || !Helper.shouldCare(player)) return;
if (GlobalBanList.isBanned(player.dimension, stack))
{
player.sendStatusMessage(new TextComponentString(ItemBlacklist.message), true);
if (ItemBlacklist.log) ItemBlacklist.getLogger().info("{} tried to use {} at {} ({})", player.getName(), stack.getDisplayName(), event.getPos(), event.getFace());
if (event.isCancelable())
event.setCanceled(true);
GlobalBanList.process(player.dimension, player.inventory);
}
}
示例3: UseOffhandItemEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
public UseOffhandItemEvent(PlayerInteractEvent event){
super(event);
this.event = event;
this.offhand = event.getItemStack();
this.swingOffhand = onBlock();
}