本文整理汇总了Java中net.minecraft.tileentity.MobSpawnerBaseLogic.setEntityName方法的典型用法代码示例。如果您正苦于以下问题:Java MobSpawnerBaseLogic.setEntityName方法的具体用法?Java MobSpawnerBaseLogic.setEntityName怎么用?Java MobSpawnerBaseLogic.setEntityName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.tileentity.MobSpawnerBaseLogic
的用法示例。
在下文中一共展示了MobSpawnerBaseLogic.setEntityName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import net.minecraft.tileentity.MobSpawnerBaseLogic; //导入方法依赖的package包/类
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
IChunkProvider chunkProvider) {
for (TileEntity tileEntity : world.getChunkFromChunkCoords(chunkX, chunkZ).getTileEntityMap().values()) {
if (tileEntity instanceof TileEntityMobSpawner) {
MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner) tileEntity).getSpawnerBaseLogic();
if ("CaveSpider".equals(spawner.getEntityNameToSpawn()) && random.nextInt(4) == 0) {
spawner.setEntityName("EnderSpider");
}
}
}
}
示例2: onItemUse
import net.minecraft.tileentity.MobSpawnerBaseLogic; //导入方法依赖的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;
}
}
示例3: onItemUse
import net.minecraft.tileentity.MobSpawnerBaseLogic; //导入方法依赖的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;
}
}
示例4: onItemUse
import net.minecraft.tileentity.MobSpawnerBaseLogic; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*
* @param pos
* The block being right-clicked
* @param side
* The side being right-clicked
*/
@Override
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 = spawnEntity(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, 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;
}
}