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


Java Entity.setCustomNameTag方法代碼示例

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


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

示例1: onItemUse

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.mob_spawner)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
                tileentity.markDirty();
                worldIn.markBlockForUpdate(pos);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --stack.stackSize;
                }

                return true;
            }
        }

        pos = pos.offset(side);
        double d0 = 0.0D;

        if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, stack.getMetadata(), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && stack.hasDisplayName())
            {
                entity.setCustomNameTag(stack.getDisplayName());
            }

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }
        }

        return true;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:64,代碼來源:ItemMonsterPlacer.java

示例2: onItemUse

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    ItemStack itemstack = stack.getHeldItem(pos);

    if (playerIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else if (!stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = playerIn.getBlockState(worldIn);
        Block block = iblockstate.getBlock();

        if (block == Blocks.MOB_SPAWNER)
        {
            TileEntity tileentity = playerIn.getTileEntity(worldIn);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.func_190894_a(func_190908_h(itemstack));
                tileentity.markDirty();
                playerIn.notifyBlockUpdate(worldIn, iblockstate, iblockstate, 3);

                if (!stack.capabilities.isCreativeMode)
                {
                    itemstack.func_190918_g(1);
                }

                return EnumActionResult.SUCCESS;
            }
        }

        BlockPos blockpos = worldIn.offset(hand);
        double d0 = this.func_190909_a(playerIn, blockpos);
        Entity entity = spawnCreature(playerIn, func_190908_h(itemstack), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + d0, (double)blockpos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && itemstack.hasDisplayName())
            {
                entity.setCustomNameTag(itemstack.getDisplayName());
            }

            applyItemEntityDataToEntity(playerIn, stack, itemstack, entity);

            if (!stack.capabilities.isCreativeMode)
            {
                itemstack.func_190918_g(1);
            }
        }

        return EnumActionResult.SUCCESS;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:63,代碼來源:ItemMonsterPlacer.java

示例3: onItemRightClick

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (itemStackIn.isRemote)
    {
        return new ActionResult(EnumActionResult.PASS, itemstack);
    }
    else
    {
        RayTraceResult raytraceresult = this.rayTrace(itemStackIn, worldIn, true);

        if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            BlockPos blockpos = raytraceresult.getBlockPos();

            if (!(itemStackIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid))
            {
                return new ActionResult(EnumActionResult.PASS, itemstack);
            }
            else if (itemStackIn.isBlockModifiable(worldIn, blockpos) && worldIn.canPlayerEdit(blockpos, raytraceresult.sideHit, itemstack))
            {
                Entity entity = spawnCreature(itemStackIn, func_190908_h(itemstack), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);

                if (entity == null)
                {
                    return new ActionResult(EnumActionResult.PASS, itemstack);
                }
                else
                {
                    if (entity instanceof EntityLivingBase && itemstack.hasDisplayName())
                    {
                        entity.setCustomNameTag(itemstack.getDisplayName());
                    }

                    applyItemEntityDataToEntity(itemStackIn, worldIn, itemstack, entity);

                    if (!worldIn.capabilities.isCreativeMode)
                    {
                        itemstack.func_190918_g(1);
                    }

                    worldIn.addStat(StatList.getObjectUseStats(this));
                    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
                }
            }
            else
            {
                return new ActionResult(EnumActionResult.FAIL, itemstack);
            }
        }
        else
        {
            return new ActionResult(EnumActionResult.PASS, itemstack);
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:58,代碼來源:ItemMonsterPlacer.java

示例4: onItemUse

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.MOB_SPAWNER)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.setEntityName(getEntityIdFromItem(stack));
                tileentity.markDirty();
                worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --stack.stackSize;
                }

                return EnumActionResult.SUCCESS;
            }
        }

        pos = pos.offset(facing);
        double d0 = 0.0D;

        if (facing == EnumFacing.UP && iblockstate.getBlock() instanceof BlockFence) //Forge: Fix Vanilla bug comparing state instead of block
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, getEntityIdFromItem(stack), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && stack.hasDisplayName())
            {
                entity.setCustomNameTag(stack.getDisplayName());
            }

            applyItemEntityDataToEntity(worldIn, playerIn, stack, entity);

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }
        }

        return EnumActionResult.SUCCESS;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:66,代碼來源:ItemMonsterPlacer.java

示例5: onItemRightClick

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (worldIn.isRemote)
    {
        return new ActionResult(EnumActionResult.PASS, itemStackIn);
    }
    else
    {
        RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);

        if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            BlockPos blockpos = raytraceresult.getBlockPos();

            if (!(worldIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid))
            {
                return new ActionResult(EnumActionResult.PASS, itemStackIn);
            }
            else if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, raytraceresult.sideHit, itemStackIn))
            {
                Entity entity = spawnCreature(worldIn, getEntityIdFromItem(itemStackIn), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);

                if (entity == null)
                {
                    return new ActionResult(EnumActionResult.PASS, itemStackIn);
                }
                else
                {
                    if (entity instanceof EntityLivingBase && itemStackIn.hasDisplayName())
                    {
                        entity.setCustomNameTag(itemStackIn.getDisplayName());
                    }

                    applyItemEntityDataToEntity(worldIn, playerIn, itemStackIn, entity);

                    if (!playerIn.capabilities.isCreativeMode)
                    {
                        --itemStackIn.stackSize;
                    }

                    playerIn.addStat(StatList.getObjectUseStats(this));
                    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
                }
            }
            else
            {
                return new ActionResult(EnumActionResult.FAIL, itemStackIn);
            }
        }
        else
        {
            return new ActionResult(EnumActionResult.PASS, itemStackIn);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:56,代碼來源:ItemMonsterPlacer.java

示例6: updateNameTag

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
private static void updateNameTag(EntityPlayerMP player, NemesisEntry nemesis) {
	Entity entity = player.world.getEntityByID(nemesis.getSpawned());
	if (entity != null) {
		entity.setCustomNameTag(nemesis.getNameAndTitle());
	}
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:7,代碼來源:MessageSyncNemesisRequest.java


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