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


Java MobSpawnerBaseLogic.setEntityName方法代码示例

本文整理汇总了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");
            }
        }
    }
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:13,代码来源:EnderSpiderSpawnerGen.java

示例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;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:64,代码来源:ItemMonsterPlacer.java

示例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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:66,代码来源:ItemMonsterPlacer.java

示例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;
	}
}
 
开发者ID:worldwidewoogie,项目名称:demomod,代码行数:58,代码来源:DemoMonsterPlacer.java


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