Java 类net.minecraft.block.BlockHorizontal 实例源码

项目:Zombe-Modpack    文件:EntityPlayer.java   
/**
 * Returns the orientation of the bed in degrees.
 */
public float getBedOrientationInDegrees()
{
    if (this.bedLocation != null)
    {
        EnumFacing enumfacing = (EnumFacing)this.world.getBlockState(this.bedLocation).getValue(BlockHorizontal.FACING);

        switch (enumfacing)
        {
            case SOUTH:
                return 90.0F;

            case WEST:
                return 0.0F;

            case NORTH:
                return 270.0F;

            case EAST:
                return 180.0F;
        }
    }

    return 0.0F;
}
项目:Backmemed    文件:EntityPlayer.java   
/**
 * Returns the orientation of the bed in degrees.
 */
public float getBedOrientationInDegrees()
{
    if (this.bedLocation != null)
    {
        EnumFacing enumfacing = (EnumFacing)this.world.getBlockState(this.bedLocation).getValue(BlockHorizontal.FACING);

        switch (enumfacing)
        {
            case SOUTH:
                return 90.0F;

            case WEST:
                return 0.0F;

            case NORTH:
                return 270.0F;

            case EAST:
                return 180.0F;
        }
    }

    return 0.0F;
}
项目:Structure    文件:StructureBlock.java   
public StructureBlock(boolean canMirror)
{
    super(Material.PISTON);
    this.canMirror = canMirror;
    setSoundType(SoundType.STONE);
    setHardness(0.5f);

    IBlockState defaultState = this.blockState
            .getBaseState()
            .withProperty(BlockHorizontal.FACING, EnumFacing.NORTH);

    if (canMirror)
    {
        defaultState = defaultState.withProperty(MIRROR, false);
    }

    setDefaultState(defaultState);
}
项目:Structure    文件:StructureShapeBlock.java   
public StructureShapeBlock()
{
    super(Material.PISTON);
    setSoundType(SoundType.STONE);
    setHardness(0.5f);

    setUnlocalizedName(NAME);

    IBlockState state = this.blockState.getBaseState().withProperty(BlockHorizontal.FACING, EnumFacing.NORTH);

    if (canMirror())
    {
        state = state.withProperty(MIRROR, false);
    }

    setDefaultState(state);
}
项目:Structure    文件:StructureShapeBlock.java   
@Override
@Deprecated
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
    final IStructureTE te = (IStructureTE) world.getTileEntity(pos);

    if (te != null)
    {
        final BlockPos mloc = te.getMasterBlockLocation();
        final StructureBlock sb = StructureRegistry.getStructureBlock(te.getRegHash());

        if (sb == null || sb.getPattern().getCollisionBoxes() == null)
        {
            return;
        }

        localToGlobalCollisionBoxes(mloc.getX(), mloc.getY(), mloc.getZ(),
                mask, list, sb.getPattern().getCollisionBoxes(),
                state.getValue(BlockHorizontal.FACING), getMirror(state),
                sb.getPattern().getBlockBounds()
        );
    }
}
项目:Structure    文件:StructureShapeTE.java   
@Override
public BlockPos getMasterBlockLocation()
{
    if (!masterLocation.isPresent())
    {
        final IBlockState state = getWorld().getBlockState(pos);
        final StructureBlock sb = StructureRegistry.getStructureBlock(definitionHash);

        if (sb == null)
        {
            return pos;
        }

        masterLocation = Optional.of(localToGlobal(
                -local.getX(), -local.getY(), -local.getZ(),
                pos.getX(), pos.getY(), pos.getZ(),
                state.getValue(BlockHorizontal.FACING), getMirror(state),
                sb.getPattern().getBlockBounds()));
    }

    return masterLocation.get();
}
项目:Structure    文件:StructureTE.java   
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
    if (!renderBounds.isPresent())
    {
        final StructureBlock sb = getMasterBlockInstance();

        if (sb == null)
        {
            return INFINITE_EXTENT_AABB;
        }

        final IBlockState state = getWorld().getBlockState(pos);
        final EnumFacing orientation = state.getValue(BlockHorizontal.FACING);
        final boolean mirror = StructureBlock.getMirror(state);

        renderBounds = Optional.of(localToGlobalBoundingBox(pos, local, sb.getPattern(), orientation, mirror));
    }

    return renderBounds.get();
}
项目:Structure    文件:IStructureTE.java   
default IBlockState getTransmutedBlock()
{
    final StructureBlock sb = StructureRegistry.getStructureBlock(getRegHash());

    if (sb != null)
    {
        final IBlockState state = getWorld().getBlockState(getPos());

        if (state != null && state.getBlock() instanceof IStructureTE)
        {
            final IBlockState block = sb.getPattern().getBlock(getLocal()).getBlockState();

            return block == null ?
                    Blocks.AIR.getDefaultState() :
                    localToGlobal(
                            block,
                            state.getValue(BlockHorizontal.FACING),
                            getMirror(state)
                    );
        }
    }

    return Blocks.AIR.getDefaultState();
}
项目:Never-Enough-Currency    文件:TileEntityRenderDisplay.java   
public void renderShelf(TileEntityDisplay te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(BlockHorizontal.FACING);

    for (int i = 0; i < 4; ++i) {
        if (!te.getStackInSlot(i).isEmpty()) {
            EntityItem customItem = new EntityItem(te.getWorld());
            customItem.hoverStart = 0.0F;
            customItem.setItem(te.getStackInSlot(i));
            GlStateManager.pushMatrix();
            GlStateManager.translate((float) x, (float) y, (float) z);
            if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) {
                if (i < 2) {
                    GlStateManager.translate(0.25F + (0.5F * i), 0.5F, 0.5F);
                } else {
                    GlStateManager.translate(0.25F + (0.5F * (i - 2)), 0F, 0.5F);
                }
            } else {
                if (i < 2) {
                    GlStateManager.translate(0.5F, 0.5F, 0.75F - (0.5F * i));
                } else {
                    GlStateManager.translate(0.5F, 0F, 0.75F - (0.5F * (i - 2)));
                }
            }

            if (ConfigHandler.laidDownShelves && !(te.getStackInSlot(i).getItem() instanceof ItemBlock)) {
                GlStateManager.rotate(-90, 1, 0, 0);

                GlStateManager.translate(0, -0.25, 0.075);
            }

            GlStateManager.rotate(90 * facing.getOpposite().getHorizontalIndex(), 0.0F, 1.0F, 0.0F);

            GlStateManager.scale(0.7F, 0.7F, 0.7F);

            itemRender.doRender(customItem, 0, 0, 0, 0, 0);
            GlStateManager.popMatrix();
        }
    }
}
项目:Halloween    文件:EntityJumpkin.java   
@Override
public void onLivingUpdate()
{
    // ensure that jumpkins spawn aligned as blocks (TODO - doesn't work)
    if (this.firstUpdate)
    {
        this.alignToBlocks();
    }

    if (!this.world.isRemote)
    {
        // if it's daytime, jumpkins have a chance to turn into pumpkins
        if (ModConfiguration.jumpkinsDespawnDuringDaytime && this.world.isDaytime())
        {
            float brightness = this.getBrightness();
            if (brightness > 0.5F && this.world.canBlockSeeSky(this.getPosition()) && ((this.rand.nextFloat() * 30F) < ((brightness - 0.4F) * 2.0F)))
            {
                // but only if the config says so, and mobGriefing is turned on, and they're on the ground or in water
                if (ModConfiguration.jumpkinsTurnToPumpkins && this.world.getGameRules().getBoolean("mobGriefing") && (this.onGround || this.isInWater()))
                {
                    IBlockState state = Blocks.PUMPKIN.getDefaultState().withProperty(BlockHorizontal.FACING, this.getHorizontalFacing());
                    this.world.setBlockState(this.getPosition(), state);
                }
                this.setDead();
                this.spawnExplosionParticle();
            }
        }
    }
    super.onLivingUpdate();
}
项目:Structure    文件:StructureBlock.java   
@Override
protected BlockStateContainer createBlockState()
{
    if (canMirror)
    {
        return new BlockStateContainer(this, BlockHorizontal.FACING, MIRROR);
    }

    return new BlockStateContainer(this, BlockHorizontal.FACING);
}
项目:Structure    文件:StructureBlock.java   
@Override
@Deprecated
public IBlockState getStateFromMeta(int meta)
{
    final EnumFacing facing = EnumFacing.getHorizontal(meta & 0x3);

    IBlockState state = getDefaultState().withProperty(BlockHorizontal.FACING, facing);

    if (canMirror)
    {
        state = state.withProperty(MIRROR, (meta & 0x4) != 0);
    }

    return state;
}
项目:Structure    文件:StructureBlock.java   
public int getMetaFromState(IBlockState state)
{
    final EnumFacing facing = state.getValue(BlockHorizontal.FACING);
    final boolean mirror = getMirror(state);

    if (canMirror)
    {
        return facing.getHorizontalIndex() | (mirror ? 1 << 2 : 0);
    } else
    {
        return facing.getHorizontalIndex();
    }
}
项目:Structure    文件:StructureBlock.java   
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    super.onBlockPlacedBy(world, pos, state, placer, stack);

    final EnumFacing orientation = state.getValue(BlockHorizontal.FACING);
    final boolean mirror = getMirror(state);

    formStructure(world, pos, state, 0x2);
    updateExternalNeighbours(world, pos, getPattern(), orientation, mirror, false);
}
项目:Structure    文件:StructureBlock.java   
@Override
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity entityIn)
{
    if (getPattern().getCollisionBoxes() != null)
    {
        localToGlobalCollisionBoxes(
                pos.getX(), pos.getY(), pos.getZ(),
                mask, list, getPattern().getCollisionBoxes(),
                state.getValue(BlockHorizontal.FACING), getMirror(state),
                getPattern().getBlockBounds()
        );
    }
}
项目:Structure    文件:StructureShapeBlock.java   
@Override
protected BlockStateContainer createBlockState()
{
    if (canMirror())
    {
        return new BlockStateContainer(this, BlockHorizontal.FACING, MIRROR);
    }

    return new BlockStateContainer(this, BlockHorizontal.FACING);
}
项目:Structure    文件:StructureShapeBlock.java   
@Deprecated
public IBlockState getStateFromMeta(int meta)
{
    final EnumFacing facing = EnumFacing.getHorizontal(meta & 0x3);

    IBlockState state = getDefaultState().withProperty(BlockHorizontal.FACING, facing);

    if (canMirror())
    {
        state = state.withProperty(MIRROR, (meta & 0x4) != 0);
    }

    return state;
}
项目:Structure    文件:StructureShapeBlock.java   
public int getMetaFromState(IBlockState state)
{
    final EnumFacing facing = state.getValue(BlockHorizontal.FACING);
    final boolean mirror = getMirror(state);

    if (canMirror())
    {
        return facing.getHorizontalIndex() | (mirror ? 1 << 2 : 0);
    } else
    {
        return facing.getHorizontalIndex();
    }
}
项目:Structure    文件:StructureShapeBlock.java   
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
{
    final IStructureTE te = (IStructureTE) world.getTileEntity(pos);
    final boolean isPlayerCreative = player != null && player.capabilities.isCreativeMode;
    final boolean isPlayerSneaking = player != null && player.isSneaking();

    final StructureBlock sb = StructureRegistry.getStructureBlock(te.getRegHash());

    if (sb != null)
    {
        sb.breakStructure(world,
                te.getMasterBlockLocation(),
                state.getValue(BlockHorizontal.FACING),
                getMirror(state),
                isPlayerCreative,
                isPlayerSneaking
        );
        updateExternalNeighbours(world,
                te.getMasterBlockLocation(),
                sb.getPattern(),
                state.getValue(BlockHorizontal.FACING),
                getMirror(state),
                false
        );

    } else
    {
        world.setBlockToAir(pos);
    }

    return true;
}
项目:Structure    文件:DefaultMinecraftRotation.java   
@Override
public IBlockState alterBlockState(IBlockState state, EnumFacing orientation, boolean mirror)
{
    final EnumFacing facing = state.getValue(BlockHorizontal.FACING);

    return state.withProperty(BlockHorizontal.FACING, localToGlobal(facing, orientation, mirror));
}
项目:Structure    文件:StairsMinecraftRotation.java   
@Override
public IBlockState alterBlockState(IBlockState state, EnumFacing orientation, boolean mirror)
{
    final EnumFacing facing = state.getValue(BlockHorizontal.FACING);
    final EnumShape shape = state.getValue(SHAPE);
    final EnumHalf half = state.getValue(HALF);

    return state
            .withProperty(BlockHorizontal.FACING, localToGlobal(facing, orientation, mirror))
            .withProperty(SHAPE, mirror & half == EnumHalf.BOTTOM ? opp[shape.ordinal()] : shape);
}
项目:Structure    文件:StairMatcher.java   
@Override
public boolean matchBlockState(IBlockState b1, IBlockState b2)
{
    final EnumFacing b1Facing = b1.getValue(BlockHorizontal.FACING);
    final EnumFacing b2Facing = b2.getValue(BlockHorizontal.FACING);

    final EnumHalf b1Half = b1.getValue(HALF);
    final EnumHalf b2Half = b2.getValue(HALF);

    final EnumShape b1Shape = b1.getValue(SHAPE);
    final EnumShape b2Shape = b2.getValue(SHAPE);

    if (b1Half != b2Half)
    {
        return false;
    }

    if (b1Facing == b2Facing)
    {
        return b1Shape == b2Shape;
    }

    if (b1Facing.getOpposite() == b2Facing)
    {
        return false;
    }

    if ((b1Shape == EnumShape.OUTER_RIGHT && b2Shape == EnumShape.OUTER_LEFT) ||
            (b1Shape == EnumShape.INNER_RIGHT && b2Shape == EnumShape.INNER_LEFT) ||
            (b1Shape == EnumShape.OUTER_LEFT && b2Shape == EnumShape.OUTER_RIGHT) ||
            (b1Shape == EnumShape.INNER_LEFT && b2Shape == EnumShape.INNER_RIGHT))
    {
        return true;
    }

    return false;
}
项目:InspiringWorld    文件:BlockLit.java   
@Override
@Nonnull
public IBlockState getStateFromMeta(int meta)
{
    EnumFacing face = EnumFacing.values()[meta & 7];
    boolean isLit = (meta >> 3) == 1;
    return this.blockState.getBaseState().withProperty(IS_LIT, isLit).withProperty(BlockHorizontal.FACING, face);
}
项目:InspiringWorld    文件:BlockLit.java   
@Override
@Nonnull
protected BlockStateContainer createBlockState()
{
    return new BlockStateContainer(this, BlockHorizontal.FACING, IS_LIT)
    {
        @Override
        @Nonnull
        protected StateImplementation createState(@Nonnull Block block, ImmutableMap<IProperty<?>, Comparable<?>>
            properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties)
        {
            return new State(block, properties);
        }
    };
}
项目:MC-Prefab    文件:HouseConfiguration.java   
private static void PlaceBed(World world, BlockPos cornerPosition, EnumFacing facing)
{
    // This is the "north west" corner.
    BlockPos itemPosition = cornerPosition.offset(facing.rotateY(), 1).offset(facing.getOpposite(), 2).down();

    IBlockState bedFootState = Blocks.BED.getDefaultState().withProperty(BlockHorizontal.FACING, facing)
            .withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);

    if (world.setBlockState(itemPosition, bedFootState, 3))
    {
        IBlockState bedHeadState = bedFootState.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD);
        world.setBlockState(itemPosition.offset(facing), bedHeadState, 3);
    }

}
项目:Alchemy    文件:GeneratorFruitTree.java   
protected void generateTrunkFruit(World world, int age, BlockPos pos, EnumFacing direction) {
    IBlockState newFruit = fruitAgeHandler.apply(trunkFruit, age);
    if (newFruit != null) {
        if (trunkFruit.getPropertyKeys().contains(BlockHorizontal.FACING))
            trunkFruit = trunkFruit.withProperty(BlockCocoa.FACING, direction.getOpposite());
        setTrunkFruit(world, pos);
    }
}
项目:MrCrayfishSkateboardingMod    文件:StateHelper.java   
public static RelativeFacing getRelativeFacing(IBlockAccess world, BlockPos pos, EnumFacing facing, RelativeFacing relativeFacing)
{
    BlockPos target = getBlockPosRelativeTo(world, pos, facing, relativeFacing);
    IBlockState state = world.getBlockState(target);
    if(state.getProperties().containsKey(BlockHorizontal.FACING))
    {
        EnumFacing otherFacing = (EnumFacing) world.getBlockState(target).getValue(BlockHorizontal.FACING);
        return getDirectionRelativeTo(facing, otherFacing);
    }
    return RelativeFacing.NONE;
}
项目:MrCrayfishSkateboardingMod    文件:StateHelper.java   
public static RelativeFacing getRelativeFacing(IBlockAccess world, BlockPos pos, EnumFacing facing, RelativeFacing relativeFacing)
{
    BlockPos target = getBlockPosRelativeTo(world, pos, facing, relativeFacing);
    IBlockState state = world.getBlockState(target);
    if(state.getProperties().containsKey(BlockHorizontal.FACING))
    {
        EnumFacing otherFacing = (EnumFacing) world.getBlockState(target).getValue(BlockHorizontal.FACING);
        return getDirectionRelativeTo(facing, otherFacing);
    }
    return RelativeFacing.NONE;
}
项目:ProgressiveAutomation    文件:Vanilla.java   
private IBlockState getCorrectCocoState(World worldObj, BlockPos pos) {
    if (worldObj.isAirBlock(pos)) {
        for (EnumFacing facing : EnumFacing.Plane.HORIZONTAL) {
            BlockPos testPos = pos.offset(facing);
            IBlockState testState = worldObj.getBlockState(testPos);
            Block testBlock = testState.getBlock();
            if (testBlock == Blocks.LOG && testState.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE) {
                return Blocks.COCOA.getDefaultState().withProperty(BlockHorizontal.FACING, facing);
            }
        }
    }
    return null;
}
项目:Minecoprocessors    文件:RedstoneUtil.java   
public static boolean isFrontPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING) == side;
}
项目:Minecoprocessors    文件:RedstoneUtil.java   
public static boolean isBackPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING).getOpposite() == side;
}
项目:Minecoprocessors    文件:RedstoneUtil.java   
public static boolean isLeftPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING).rotateYCCW() == side;
}
项目:Minecoprocessors    文件:RedstoneUtil.java   
public static boolean isRightPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING).rotateY() == side;
}
项目:Minecoprocessors    文件:RedstoneUtil.java   
public static BlockPos getFrontBlock(IBlockAccess blockAccess, BlockPos pos) {
  return pos.offset(blockAccess.getBlockState(pos).getValue(BlockHorizontal.FACING));
}
项目:Zombe-Modpack    文件:EntityPlayer.java   
public EntityPlayer.SleepResult trySleep(BlockPos bedLocation)
{
    EnumFacing enumfacing = (EnumFacing)this.world.getBlockState(bedLocation).getValue(BlockHorizontal.FACING);

    if (!this.world.isRemote)
    {
        if (this.isPlayerSleeping() || !this.isEntityAlive())
        {
            return EntityPlayer.SleepResult.OTHER_PROBLEM;
        }

        if (!this.world.provider.isSurfaceWorld())
        {
            return EntityPlayer.SleepResult.NOT_POSSIBLE_HERE;
        }

        if (this.world.isDaytime())
        {
            return EntityPlayer.SleepResult.NOT_POSSIBLE_NOW;
        }

        if (!this.func_190774_a(bedLocation, enumfacing))
        {
            return EntityPlayer.SleepResult.TOO_FAR_AWAY;
        }

        double d0 = 8.0D;
        double d1 = 5.0D;
        List<EntityMob> list = this.world.<EntityMob>getEntitiesWithinAABB(EntityMob.class, new AxisAlignedBB((double)bedLocation.getX() - 8.0D, (double)bedLocation.getY() - 5.0D, (double)bedLocation.getZ() - 8.0D, (double)bedLocation.getX() + 8.0D, (double)bedLocation.getY() + 5.0D, (double)bedLocation.getZ() + 8.0D));

        if (!list.isEmpty())
        {
            return EntityPlayer.SleepResult.NOT_SAFE;
        }
    }

    if (this.isRiding())
    {
        this.dismountRidingEntity();
    }

    this.setSize(0.2F, 0.2F);

    if (this.world.isBlockLoaded(bedLocation))
    {
        float f1 = 0.5F + (float)enumfacing.getFrontOffsetX() * 0.4F;
        float f = 0.5F + (float)enumfacing.getFrontOffsetZ() * 0.4F;
        this.setRenderOffsetForSleep(enumfacing);
        this.setPosition((double)((float)bedLocation.getX() + f1), (double)((float)bedLocation.getY() + 0.6875F), (double)((float)bedLocation.getZ() + f));
    }
    else
    {
        this.setPosition((double)((float)bedLocation.getX() + 0.5F), (double)((float)bedLocation.getY() + 0.6875F), (double)((float)bedLocation.getZ() + 0.5F));
    }

    this.sleeping = true;
    this.sleepTimer = 0;
    this.bedLocation = bedLocation;
    this.motionX = 0.0D;
    this.motionY = 0.0D;
    this.motionZ = 0.0D;

    if (!this.world.isRemote)
    {
        this.world.updateAllPlayersSleepingFlag();
    }

    return EntityPlayer.SleepResult.OK;
}
项目:Thermionics    文件:BlockStateBehavior.java   
@Override
public BlockStateContainer createBlockState(Block block) {
    return new BlockStateContainer(block, BlockHorizontal.FACING);
}
项目:Thermionics    文件:BlockStateBehavior.java   
@Override
public IBlockState getDefaultState(IBlockState baseState) {
    return baseState.withProperty(BlockHorizontal.FACING, EnumFacing.NORTH);
}
项目:Thermionics    文件:BlockStateBehavior.java   
@Override
public IBlockState getPlacementState(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    return state.withProperty(BlockHorizontal.FACING, placer.getAdjustedHorizontalFacing().getOpposite());
}
项目:Thermionics    文件:BlockStateBehavior.java   
@Override
public IBlockState getStateFromMeta(Block block, int meta) {
    return block.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.getHorizontal(meta & 0x03));
}
项目:Thermionics    文件:BlockStateBehavior.java   
@Override
public int getMetaFromState(IBlockState state) {
    return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}