當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityItem.setAgeToCreativeDespawnTime方法代碼示例

本文整理匯總了Java中net.minecraft.entity.item.EntityItem.setAgeToCreativeDespawnTime方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityItem.setAgeToCreativeDespawnTime方法的具體用法?Java EntityItem.setAgeToCreativeDespawnTime怎麽用?Java EntityItem.setAgeToCreativeDespawnTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.item.EntityItem的用法示例。


在下文中一共展示了EntityItem.setAgeToCreativeDespawnTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dropFakeItems

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void dropFakeItems(PlayerDropsEvent event) {
	InventoryWearables inv = event.getEntityLiving().getCapability(TF2weapons.INVENTORY_CAP, null);
	for (int i = 3; i < 13; i++)
		if (inv.getStackInSlot(i) != null) {
			event.getEntityPlayer().dropItem(inv.getStackInSlot(i), true, false);
		}
	
	if(WeaponsCapability.get(event.getEntity()).isFeign())
		for(EntityItem item:event.getDrops()) {
			item.getEntityData().setBoolean("Fake", true);
			item.setAgeToCreativeDespawnTime();
		}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:15,代碼來源:TF2EventsCommon.java

示例2: processCreativeInventoryAction

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(C10PacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());

    if (this.playerEntity.theItemInWorldManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    tileentity.writeToNBT(nbttagcompound1);
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize();
        boolean flag2 = itemstack == null || itemstack.getItem() != null;
        boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;

        if (flag1 && flag2 && flag3)
        {
            if (itemstack == null)
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropPlayerItemWithRandomChoice(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:63,代碼來源:NetHandlerPlayServer.java

示例3: processCreativeInventoryAction

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.interactionManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.world.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
        boolean flag2 = itemstack.func_190926_b() || itemstack.getMetadata() >= 0 && itemstack.func_190916_E() <= 64 && !itemstack.func_190926_b();

        if (flag1 && flag2)
        {
            if (itemstack.func_190926_b())
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), ItemStack.field_190927_a);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:61,代碼來源:NetHandlerPlayServer.java

示例4: processCreativeInventoryAction

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.interactionManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
        boolean flag2 = itemstack == null || itemstack.getItem() != null;
        boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;

        if (flag1 && flag2 && flag3)
        {
            if (itemstack == null)
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:62,代碼來源:NetHandlerPlayServer.java


注:本文中的net.minecraft.entity.item.EntityItem.setAgeToCreativeDespawnTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。