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


Java EntityMinecart.setCustomNameTag方法代码示例

本文整理汇总了Java中net.minecraft.entity.item.EntityMinecart.setCustomNameTag方法的典型用法代码示例。如果您正苦于以下问题:Java EntityMinecart.setCustomNameTag方法的具体用法?Java EntityMinecart.setCustomNameTag怎么用?Java EntityMinecart.setCustomNameTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.item.EntityMinecart的用法示例。


在下文中一共展示了EntityMinecart.setCustomNameTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemUse

import net.minecraft.entity.item.EntityMinecart; //导入方法依赖的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)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:ItemMinecart.java

示例2: onItemUse

import net.minecraft.entity.item.EntityMinecart; //导入方法依赖的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)
{
    IBlockState iblockstate = playerIn.getBlockState(worldIn);

    if (!BlockRailBase.isRailBlock(iblockstate))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        ItemStack itemstack = stack.getHeldItem(pos);

        if (!playerIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.create(playerIn, (double)worldIn.getX() + 0.5D, (double)worldIn.getY() + 0.0625D + d0, (double)worldIn.getZ() + 0.5D, this.minecartType);

            if (itemstack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(itemstack.getDisplayName());
            }

            playerIn.spawnEntityInWorld(entityminecart);
        }

        itemstack.func_190918_g(1);
        return EnumActionResult.SUCCESS;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:ItemMinecart.java

示例3: onItemUse

import net.minecraft.entity.item.EntityMinecart; //导入方法依赖的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)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (!BlockRailBase.isRailBlock(iblockstate))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.create(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return EnumActionResult.SUCCESS;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:38,代码来源:ItemMinecart.java

示例4: dispenseStack

import net.minecraft.entity.item.EntityMinecart; //导入方法依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
    World world = source.getWorld();
    double d0 = source.getX() + (double)enumfacing.getFrontOffsetX() * 1.125D;
    double d1 = Math.floor(source.getY()) + (double)enumfacing.getFrontOffsetY();
    double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ() * 1.125D;
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    IBlockState iblockstate = world.getBlockState(blockpos);
    BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
    double d3;

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (blockrailbase$enumraildirection.isAscending())
        {
            d3 = 0.6D;
        }
        else
        {
            d3 = 0.1D;
        }
    }
    else
    {
        if (iblockstate.getBlock().getMaterial() != Material.air || !BlockRailBase.isRailBlock(world.getBlockState(blockpos.down())))
        {
            return this.behaviourDefaultDispenseItem.dispense(source, stack);
        }

        IBlockState iblockstate1 = world.getBlockState(blockpos.down());
        BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.getValue(((BlockRailBase)iblockstate1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;

        if (enumfacing != EnumFacing.DOWN && blockrailbase$enumraildirection1.isAscending())
        {
            d3 = -0.4D;
        }
        else
        {
            d3 = -0.9D;
        }
    }

    EntityMinecart entityminecart = EntityMinecart.func_180458_a(world, d0, d1 + d3, d2, ((ItemMinecart)stack.getItem()).minecartType);

    if (stack.hasDisplayName())
    {
        entityminecart.setCustomNameTag(stack.getDisplayName());
    }

    world.spawnEntityInWorld(entityminecart);
    stack.splitStack(1);
    return stack;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:55,代码来源:ItemMinecart.java

示例5: dispenseStack

import net.minecraft.entity.item.EntityMinecart; //导入方法依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    World world = source.getWorld();
    double d0 = source.getX() + (double)enumfacing.getFrontOffsetX() * 1.125D;
    double d1 = Math.floor(source.getY()) + (double)enumfacing.getFrontOffsetY();
    double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ() * 1.125D;
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    IBlockState iblockstate = world.getBlockState(blockpos);
    BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
    double d3;

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (blockrailbase$enumraildirection.isAscending())
        {
            d3 = 0.6D;
        }
        else
        {
            d3 = 0.1D;
        }
    }
    else
    {
        if (iblockstate.getMaterial() != Material.AIR || !BlockRailBase.isRailBlock(world.getBlockState(blockpos.down())))
        {
            return this.behaviourDefaultDispenseItem.dispense(source, stack);
        }

        IBlockState iblockstate1 = world.getBlockState(blockpos.down());
        BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.getValue(((BlockRailBase)iblockstate1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;

        if (enumfacing != EnumFacing.DOWN && blockrailbase$enumraildirection1.isAscending())
        {
            d3 = -0.4D;
        }
        else
        {
            d3 = -0.9D;
        }
    }

    EntityMinecart entityminecart = EntityMinecart.create(world, d0, d1 + d3, d2, ((ItemMinecart)stack.getItem()).minecartType);

    if (stack.hasDisplayName())
    {
        entityminecart.setCustomNameTag(stack.getDisplayName());
    }

    world.spawnEntityInWorld(entityminecart);
    stack.func_190918_g(1);
    return stack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:55,代码来源:ItemMinecart.java

示例6: dispenseStack

import net.minecraft.entity.item.EntityMinecart; //导入方法依赖的package包/类
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    World world = source.getWorld();
    double d0 = source.getX() + (double)enumfacing.getFrontOffsetX() * 1.125D;
    double d1 = Math.floor(source.getY()) + (double)enumfacing.getFrontOffsetY();
    double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ() * 1.125D;
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    IBlockState iblockstate = world.getBlockState(blockpos);
    BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
    double d3;

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (blockrailbase$enumraildirection.isAscending())
        {
            d3 = 0.6D;
        }
        else
        {
            d3 = 0.1D;
        }
    }
    else
    {
        if (iblockstate.getMaterial() != Material.AIR || !BlockRailBase.isRailBlock(world.getBlockState(blockpos.down())))
        {
            return this.behaviourDefaultDispenseItem.dispense(source, stack);
        }

        IBlockState iblockstate1 = world.getBlockState(blockpos.down());
        BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.getValue(((BlockRailBase)iblockstate1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;

        if (enumfacing != EnumFacing.DOWN && blockrailbase$enumraildirection1.isAscending())
        {
            d3 = -0.4D;
        }
        else
        {
            d3 = -0.9D;
        }
    }

    EntityMinecart entityminecart = EntityMinecart.create(world, d0, d1 + d3, d2, ((ItemMinecart)stack.getItem()).minecartType);

    if (stack.hasDisplayName())
    {
        entityminecart.setCustomNameTag(stack.getDisplayName());
    }

    world.spawnEntityInWorld(entityminecart);
    stack.splitStack(1);
    return stack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:58,代码来源:ItemMinecart.java


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