當前位置: 首頁>>代碼示例>>Java>>正文


Java MovingObjectPosition.getBlockPos方法代碼示例

本文整理匯總了Java中net.minecraft.util.MovingObjectPosition.getBlockPos方法的典型用法代碼示例。如果您正苦於以下問題:Java MovingObjectPosition.getBlockPos方法的具體用法?Java MovingObjectPosition.getBlockPos怎麽用?Java MovingObjectPosition.getBlockPos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.MovingObjectPosition的用法示例。


在下文中一共展示了MovingObjectPosition.getBlockPos方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawSelectionBox

import net.minecraft.util.MovingObjectPosition; //導入方法依賴的package包/類
/**
 * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
 */
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
    if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
    {
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
        GL11.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();
        GlStateManager.depthMask(false);
        float f = 0.002F;
        BlockPos blockpos = movingObjectPositionIn.getBlockPos();
        Block block = this.theWorld.getBlockState(blockpos).getBlock();

        if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
        {
            block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
            double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
            double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
            double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
            func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
        }

        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:32,代碼來源:RenderGlobal.java

示例2: onItemRightClick

import net.minecraft.util.MovingObjectPosition; //導入方法依賴的package包/類
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
            {
                return itemStackIn;
            }

            if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.water)
            {
                --itemStackIn.stackSize;
                playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);

                if (itemStackIn.stackSize <= 0)
                {
                    return new ItemStack(Items.potionitem);
                }

                if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.potionitem)))
                {
                    playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.potionitem, 1, 0), false);
                }
            }
        }

        return itemStackIn;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:48,代碼來源:ItemGlassBottle.java

示例3: onItemRightClick

import net.minecraft.util.MovingObjectPosition; //導入方法依賴的package包/類
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (worldIn.isRemote)
    {
        return itemStackIn;
    }
    else
    {
        MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);

        if (movingobjectposition == null)
        {
            return itemStackIn;
        }
        else
        {
            if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
            {
                BlockPos blockpos = movingobjectposition.getBlockPos();

                if (!worldIn.isBlockModifiable(playerIn, blockpos))
                {
                    return itemStackIn;
                }

                if (!playerIn.canPlayerEdit(blockpos, movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                if (worldIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid)
                {
                    Entity entity = spawnCreature(worldIn, itemStackIn.getMetadata(), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);

                    if (entity != null)
                    {
                        if (entity instanceof EntityLivingBase && itemStackIn.hasDisplayName())
                        {
                            ((EntityLiving)entity).setCustomNameTag(itemStackIn.getDisplayName());
                        }

                        if (!playerIn.capabilities.isCreativeMode)
                        {
                            --itemStackIn.stackSize;
                        }

                        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    }
                }
            }

            return itemStackIn;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:59,代碼來源:ItemMonsterPlacer.java

示例4: onItemRightClick

import net.minecraft.util.MovingObjectPosition; //導入方法依賴的package包/類
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    boolean flag = this.isFull == Blocks.air;
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (flag)
            {
                if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);
                Material material = iblockstate.getBlock().getMaterial();

                if (material == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
                {
                    worldIn.setBlockToAir(blockpos);
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return this.fillBucket(itemStackIn, playerIn, Items.water_bucket);
                }

                if (material == Material.lava && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
                {
                    worldIn.setBlockToAir(blockpos);
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return this.fillBucket(itemStackIn, playerIn, Items.lava_bucket);
                }
            }
            else
            {
                if (this.isFull == Blocks.air)
                {
                    return new ItemStack(Items.bucket);
                }

                BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit);

                if (!playerIn.canPlayerEdit(blockpos1, movingobjectposition.sideHit, itemStackIn))
                {
                    return itemStackIn;
                }

                if (this.tryPlaceContainedLiquid(worldIn, blockpos1) && !playerIn.capabilities.isCreativeMode)
                {
                    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
                    return new ItemStack(Items.bucket);
                }
            }
        }

        return itemStackIn;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:73,代碼來源:ItemBucket.java

示例5: onItemRightClick

import net.minecraft.util.MovingObjectPosition; //導入方法依賴的package包/類
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
            {
                return itemStackIn;
            }

            BlockPos blockpos1 = blockpos.up();
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --itemStackIn.stackSize;
                }

                playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
            }
        }

        return itemStackIn;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:47,代碼來源:ItemLilyPad.java

示例6: drawSelectionBox

import net.minecraft.util.MovingObjectPosition; //導入方法依賴的package包/類
/**
 * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
 */
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
    if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
    {
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
        GL11.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();

        if (Config.isShaders())
        {
            Shaders.disableTexture2D();
        }

        GlStateManager.depthMask(false);
        float f = 0.002F;
        BlockPos blockpos = movingObjectPositionIn.getBlockPos();
        Block block = this.theWorld.getBlockState(blockpos).getBlock();

        if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
        {
            block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
            double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
            double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
            double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
            func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
        }

        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();

        if (Config.isShaders())
        {
            Shaders.enableTexture2D();
        }

        GlStateManager.disableBlend();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:44,代碼來源:RenderGlobal.java


注:本文中的net.minecraft.util.MovingObjectPosition.getBlockPos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。