本文整理匯總了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();
}