當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。