当前位置: 首页>>代码示例>>Java>>正文


Java ItemTossEvent.getEntityItem方法代码示例

本文整理汇总了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();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:ForgeHooks.java

示例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);
	}
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:22,代码来源:DropItemAction.java

示例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);
    }
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:10,代码来源:RewardForDiscardingItemImplementation.java

示例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());
    }
}
 
开发者ID:Wehavecookies56,项目名称:Kingdom-Keys-Re-Coded,代码行数:29,代码来源:ItemEvents.java


注:本文中的net.minecraftforge.event.entity.item.ItemTossEvent.getEntityItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。