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


Java EnumFacing.UP属性代码示例

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


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

示例1: getFacingFromEntity

public static EnumFacing getFacingFromEntity(BlockPos pos, EntityLivingBase p_185647_1_)
{
    if (MathHelper.abs((float)p_185647_1_.posX - (float)pos.getX()) < 2.0F && MathHelper.abs((float)p_185647_1_.posZ - (float)pos.getZ()) < 2.0F)
    {
        double d0 = p_185647_1_.posY + (double)p_185647_1_.getEyeHeight();

        if (d0 - (double)pos.getY() > 2.0D)
        {
            return EnumFacing.UP;
        }

        if ((double)pos.getY() - d0 > 0.0D)
        {
            return EnumFacing.DOWN;
        }
    }

    return p_185647_1_.getHorizontalFacing().getOpposite();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:BlockPistonBase.java

示例2: getFacingFromEntity

public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn)
{
    if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
    {
        double d0 = entityIn.posY + (double)entityIn.getEyeHeight();

        if (d0 - (double)clickedBlock.getY() > 2.0D)
        {
            return EnumFacing.UP;
        }

        if ((double)clickedBlock.getY() - d0 > 0.0D)
        {
            return EnumFacing.DOWN;
        }
    }

    return entityIn.getHorizontalFacing().getOpposite();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:BlockPistonBase.java

示例3: canPlaceBlockOnSide

public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    BlockPos blockpos = pos;
    IProperty iproperty = this.singleSlab.getVariantProperty();
    Object object = this.singleSlab.getVariant(stack);
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;

        if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty))
        {
            return true;
        }
    }

    pos = pos.offset(side);
    IBlockState iblockstate1 = worldIn.getBlockState(pos);
    return iblockstate1.getBlock() == this.singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:ItemSlab.java

示例4: canPlaceBlockOnSide

@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    BlockPos blockpos = pos;
    int subtype = getMetadata(stack);
    IBlockState clickedState = worldIn.getBlockState(pos);

    if (clickedState.getBlock() == this.singleSlab)
    {
        boolean flag = clickedState.getValue(net.minecraft.block.BlockSlab.HALF) == net.minecraft.block.BlockSlab.EnumBlockHalf.TOP;

        if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && subtype == singleSlabCS.getSubtype(clickedState))
        {
            return true;
        }
    }

    pos = pos.offset(side);
    IBlockState existingState = worldIn.getBlockState(pos);
    return existingState.getBlock() == this.singleSlab && subtype == singleSlabCS.getSubtype(existingState) || super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:21,代码来源:ItemSlab.java

示例5: onItemUse

@Override
public EnumActionResult onItemUse (EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    IBlockState state = worldIn.getBlockState(pos);

    if (facing != EnumFacing.UP)
        return EnumActionResult.FAIL;
    if (!player.canPlayerEdit(pos.offset(facing), facing, stack))
        return EnumActionResult.FAIL;
    if (!state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this))
        return EnumActionResult.FAIL;
    if (!worldIn.isAirBlock(pos.up()))
        return EnumActionResult.FAIL;

    worldIn.setBlockState(pos.up(), ModBlocks.candelilla.getDefaultState());
    if (player instanceof EntityPlayerMP)
        CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos.up(), stack);

    stack.shrink(1);
    return EnumActionResult.SUCCESS;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:21,代码来源:ItemCandelillaSeeds.java

示例6: onItemUse

public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos.offset(facing), facing, itemstack))
    {
        int subtype = getMetadata(itemstack);
        IBlockState currentState = worldIn.getBlockState(pos);

        if (currentState.getBlock() == singleSlab)
        {
            int subtype1 = this.singleSlabCS.getSubtype(currentState);
            net.minecraft.block.BlockSlab.EnumBlockHalf half = currentState.getValue(net.minecraft.block.BlockSlab.HALF);

            if ((facing == EnumFacing.UP && half == net.minecraft.block.BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && half == net.minecraft.block.BlockSlab.EnumBlockHalf.TOP)
                && subtype1 == subtype)
            {
                IBlockState stateDouble = this.makeState(subtype1);
                AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);

                if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
                {
                    SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
                    worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                    itemstack.shrink(1);
                }

                return EnumActionResult.SUCCESS;
            }
        }

        return this.tryPlace(player, itemstack, worldIn, pos.offset(facing), subtype) ? EnumActionResult.SUCCESS : super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    } else
    {
        return EnumActionResult.FAIL;
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:37,代码来源:ItemSlab.java

示例7: canPlaceBlockOnSide

public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.snow_layer)
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    return worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:ItemBlock.java

示例8: processRightClickBlock

public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation, (byte)2));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:NetHandlerPlayServer.java

示例9: isPossible

@Override
    public boolean isPossible(World world, BlockPos pos, EnumFacing side) {
        if (side != EnumFacing.UP) {
            return false;
        }
        TileEntity te = world.getTileEntity(pos);
        if (te != null) {
            return false;
        }
//        Block block = world.getBlockState(pos).getBlock();
//        if (block.is)
        return true;
    }
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:13,代码来源:DigdownActionFactory.java

示例10: onItemUse

/**
 * 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 (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (side == EnumFacing.UP)
    {
        return false;
    }
    else
    {
        BlockPos blockpos = pos.offset(side);

        if (!playerIn.canPlayerEdit(blockpos, side, stack))
        {
            return false;
        }
        else
        {
            EntityHanging entityhanging = this.createEntity(worldIn, blockpos, side);

            if (entityhanging != null && entityhanging.onValidSurface())
            {
                if (!worldIn.isRemote)
                {
                    worldIn.spawnEntityInWorld(entityhanging);
                }

                --stack.stackSize;
            }

            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:39,代码来源:ItemHangingEntity.java

示例11: renderModel

private void renderModel(EnumFacing facing, double x, double y, double z, float partialTicks) {
	float tick = RenderHelper.getRenderWorldTime(partialTicks);
	final float prevU = OpenGlHelper.lastBrightnessX;
	final float prevV = OpenGlHelper.lastBrightnessY;
	bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	//Top
	GlStateManager.pushMatrix();
	GlStateManager.translate(x + 0.5D, y + 0.5D, z + 0.5D);
	if(facing != null && facing != EnumFacing.UP && facing != EnumFacing.DOWN) {
		GlStateManager.rotate(90F, facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH ? 1F : 0F, 0F, facing == EnumFacing.EAST || facing == EnumFacing.WEST ? 1F : 0F);
	}
	GlStateManager.pushMatrix();
	GlStateManager.rotate(partialTicks + tick * 0.5F % 360F, 0F, 1F, 0F);
	BlockBaker.render(BlockBaker.VACUUM_TOP);
	GlStateManager.popMatrix();
	//Middle
	GlStateManager.disableLighting();
	GLHelper.lightMap(255F, 255F);
	BlockBaker.render(BlockBaker.VACUUM_PIECE);
	GLHelper.lightMap(prevU, prevV);
	GlStateManager.enableLighting();
	//Bottom
	GlStateManager.pushMatrix();
	GlStateManager.rotate(partialTicks + tick * 0.5F % 360F, 0F, -1F, 0F);
	BlockBaker.render(BlockBaker.VACUUM_BOTTOM);
	GlStateManager.popMatrix();
	GlStateManager.popMatrix();
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:28,代码来源:VacuumConveyorRenderer.java

示例12: getFacingFromVertexData

public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:FaceBakery.java

示例13: getSlotsForFace

public int[] getSlotsForFace(EnumFacing side)
{
    return side == EnumFacing.UP ? inputSlots : outputSlots;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:4,代码来源:TileEntityBrewingStand.java

示例14: onItemUse

/**
 * 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 (stack.stackSize == 0)
    {
        return false;
    }
    else if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(side);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i <= 7)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1);

                if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2))
                {
                    worldIn.playSoundEffect((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                    return true;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:47,代码来源:ItemSnow.java

示例15: onItemUse

/**
 * 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 (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityBanner)
            {
                ((TileEntityBanner)tileentity).setItemValues(stack);
            }

            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:53,代码来源:ItemBanner.java


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