本文整理汇总了Java中net.minecraftforge.event.entity.item.ItemTossEvent.getEntityItem方法的典型用法代码示例。如果您正苦于以下问题:Java ItemTossEvent.getEntityItem方法的具体用法?Java ItemTossEvent.getEntityItem怎么用?Java ItemTossEvent.getEntityItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.item.ItemTossEvent
的用法示例。
在下文中一共展示了ItemTossEvent.getEntityItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerTossEvent
import net.minecraftforge.event.entity.item.ItemTossEvent; //导入方法依赖的package包/类
public static EntityItem onPlayerTossEvent(EntityPlayer player, ItemStack item, boolean includeName)
{
player.captureDrops = true;
EntityItem ret = player.dropItem(item, false, includeName);
player.capturedDrops.clear();
player.captureDrops = false;
if (ret == null)
{
return null;
}
ItemTossEvent event = new ItemTossEvent(ret, player);
if (MinecraftForge.EVENT_BUS.post(event))
{
return null;
}
if (!player.worldObj.isRemote)
{
player.getEntityWorld().spawnEntityInWorld(event.getEntityItem());
}
return event.getEntityItem();
}
示例2: usePlayer
import net.minecraftforge.event.entity.item.ItemTossEvent; //导入方法依赖的package包/类
@Override
public void usePlayer(OpenModsFakePlayer player) {
player.setPositionAndRotation(x, y - player.getEyeHeight(), z, yaw, pitch);
final EntityItem itemToDrop = new EntityItem(player.getEntityWorld(), x, y, z, stack.copy());
itemToDrop.setPosition(itemToDrop.posX, itemToDrop.posY - itemToDrop.height, itemToDrop.posZ);
itemToDrop.setPickupDelay(40);
ItemTossEvent event = new ItemTossEvent(itemToDrop, player);
if (MinecraftForge.EVENT_BUS.post(event)) {
Log.info("Item %s drop from this %s aborted by event", stack, this);
} else {
final EntityItem droppedItem = event.getEntityItem();
droppedItem.motionX = v.x;
droppedItem.motionY = v.y;
droppedItem.motionZ = v.z;
player.getEntityWorld().spawnEntity(droppedItem);
}
}
示例3: onTossItem
import net.minecraftforge.event.entity.item.ItemTossEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onTossItem(ItemTossEvent event)
{
if (event.getEntityItem() != null && event.getPlayer() instanceof EntityPlayerMP)
{
ItemStack stack = event.getEntityItem().getEntityItem();
sendItemStackToClient((EntityPlayerMP)event.getPlayer(), MalmoMessageType.SERVER_DISCARDITEM, stack);
}
}
示例4: onItemTossEvent
import net.minecraftforge.event.entity.item.ItemTossEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemTossEvent (ItemTossEvent event) {
if (!event.getPlayer().world.isRemote)
if(event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getInDrive() && !event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Anti)) {
event.setCanceled(true);
return;
}
if (event.getEntityItem().getItem().getItem() instanceof ItemKeyblade && (event.getEntityItem().getItem().getItem() != ModItems.WoodenKeyblade && event.getEntityItem().getItem().getItem() != ModItems.WoodenStick && event.getEntityItem().getItem().getItem() != ModItems.DreamSword && event.getEntityItem().getItem().getItem() != ModItems.DreamStaff)) {
event.getEntityItem().isDead = true;
event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if(!ItemStack.areItemStacksEqual(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0), ItemStack.EMPTY))
PacketDispatcher.sendTo(new SyncKeybladeData(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) event.getPlayer());
} else if (event.getEntityItem().getItem().getItem() instanceof ItemMunny) {
event.setCanceled(true);
if (!event.getPlayer().world.isRemote) {
PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getEntityItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getPlayer());
event.getPlayer().getCapability(ModCapabilities.MUNNY, null).addMunny(event.getEntityItem().getItem().getTagCompound().getInteger("amount"));
}
}
if (event.getEntityItem().getItem().getItem() == event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
event.getEntityItem().isDead = true;
event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(EnumHand.MAIN_HAND, false);
PacketDispatcher.sendTo(new SyncOrgXIIIData(event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) event.getPlayer());
}
}