本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
}
}
示例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());
}
}