net.minecraft.block.BlockHorizontal Java Examples

The following examples show how to use net.minecraft.block.BlockHorizontal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockGearbox.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing,
    float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
    EnumFacing facingHorizontal = placer.getHorizontalFacing();
    if (!placer.isSneaking()) {
        facingHorizontal = facingHorizontal.getOpposite();
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, facingHorizontal);
}
 
Example #2
Source File: BlockGearbox.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, enumfacing);
}
 
Example #3
Source File: BlockLiftLever.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
@Nonnull
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing,
    float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
    EnumFacing facingHorizontal = placer.getHorizontalFacing();
    if (!placer.isSneaking()) {
        facingHorizontal = facingHorizontal.getOpposite();
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, facingHorizontal);
}
 
Example #4
Source File: BlockLiftLever.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
@Nonnull
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, enumfacing);
}
 
Example #5
Source File: ItemFuton.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand,
		EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (worldIn.isRemote) {
		return EnumActionResult.SUCCESS;
	} else if (facing != EnumFacing.UP) {
		return EnumActionResult.FAIL;
	} else {
		IBlockState iblockstate = worldIn.getBlockState(pos);
		Block block = iblockstate.getBlock();
		boolean flag = block.isReplaceable(worldIn, pos);

		if (!flag) {
			pos = pos.up();
		}

		int i = MathHelper.floor(playerIn.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
		EnumFacing enumfacing = EnumFacing.getHorizontal(i);
		BlockPos blockpos = pos.offset(enumfacing);
		ItemStack itemstack = playerIn.getHeldItem(hand);

		if (playerIn.canPlayerEdit(pos, facing, itemstack) && playerIn.canPlayerEdit(blockpos, facing, itemstack)) {
			boolean flag1 = worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
			boolean flag2 = flag || worldIn.isAirBlock(pos);
			boolean flag3 = flag1 || worldIn.isAirBlock(blockpos);

			if (flag2 && flag3 && worldIn.getBlockState(pos.down()).isTopSolid()
					&& worldIn.getBlockState(blockpos.down()).isFullCube()) {
				IBlockState iblockstate1 = BlockLoader.FUTON.getDefaultState()
						.withProperty(BlockFuton.OCCUPIED, Boolean.valueOf(false))
						.withProperty(BlockHorizontal.FACING, enumfacing)
						.withProperty(BlockFuton.PART, BlockFuton.EnumPartType.FOOT);

				if (worldIn.setBlockState(pos, iblockstate1, 11)) {
					IBlockState iblockstate2 = iblockstate1.withProperty(BlockFuton.PART,
							BlockFuton.EnumPartType.HEAD);
					worldIn.setBlockState(blockpos, iblockstate2, 11);
				}

				SoundType soundtype = iblockstate1.getBlock().getSoundType(iblockstate1, worldIn, pos, playerIn);
				worldIn.playSound(null, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS,
						(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
				itemstack.shrink(1);
				return EnumActionResult.SUCCESS;
			}
			return EnumActionResult.FAIL;
		}
		return EnumActionResult.FAIL;
	}
}
 
Example #6
Source File: RedstoneUtil.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isFrontPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING) == side;
}
 
Example #7
Source File: RedstoneUtil.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isBackPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING).getOpposite() == side;
}
 
Example #8
Source File: RedstoneUtil.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isLeftPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING).rotateYCCW() == side;
}
 
Example #9
Source File: RedstoneUtil.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isRightPort(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(BlockHorizontal.FACING).rotateY() == side;
}
 
Example #10
Source File: RedstoneUtil.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
public static BlockPos getFrontBlock(IBlockAccess blockAccess, BlockPos pos) {
  return pos.offset(blockAccess.getBlockState(pos).getValue(BlockHorizontal.FACING));
}
 
Example #11
Source File: BlockMap.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private void parsePaleteBlockParameter(String blockname, String propertyString, PaletteEntry entry) {
	String[] aProp = propertyString.split(":");

	if (aProp.length != 2) {
		return;
	}

	IProperty prop = null;
  	EnumFacing value = null;

	if ("facing".equals(aProp[0])) {
		// 

		// prop = PropertyDirection.create("facing", new Predicate() {
		// };<EnumFacing><EnumFacing>();

		
		if(blockname.equals("minecraft:torch")){
			prop = PropertyDirection.create("facing", new Predicate<EnumFacing>() {
				public boolean apply(EnumFacing p_apply_1_) {
					return p_apply_1_ != EnumFacing.DOWN;
				}
			});
			//FIXME
			//return;
		}else{
			prop = BlockHorizontal.FACING;
		}
		
		
	} // PropertyDirection

	if ("north".equals(aProp[1])) {
		value = EnumFacing.NORTH;
	} else if ("south".equals(aProp[1])) {
		value = EnumFacing.SOUTH;
	}
	
	

	if (value == null || prop == null) {
		return;
	}

	System.out.println("adding property [" + aProp[0] + "] [" + aProp[1] + "]");

	entry.block = entry.block.withProperty(prop, value);
}
 
Example #12
Source File: LiftLeverTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityLiftLever tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {

    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();

    GlStateManager.translate(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
    GlStateManager.pushMatrix();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);
    IBlockState gearState = Minecraft.getMinecraft().world.getBlockState(tileentity.getPos());
    if (gearState.getBlock() instanceof BlockLiftLever) {
        EnumFacing facing = gearState.getValue(BlockHorizontal.FACING);

        GlStateManager.translate(0.5, 0.5, 0.5);
        switch (facing) {
            case UP:
                GL11.glRotated(90, 1, 0, 0);
                break;
            case DOWN:
                GL11.glRotated(270, 1, 0, 0);
                break;
            case NORTH:
                GL11.glRotated(0, 0, 1, 0);
                break;
            case EAST:
                GL11.glRotated(270, 0, 1, 0);
                break;
            case SOUTH:
                GL11.glRotated(180, 0, 1, 0);
                break;
            case WEST:
                GL11.glRotated(90, 0, 1, 0);
                break;
        }
        GlStateManager.translate(-0.5, -0.5, -0.5);
    }

    float leverOffset = tileentity.getPrevLeverOffset()
        + (tileentity.getLeverOffset() - tileentity.getPrevLeverOffset()) * partialTick;

    // double keyframe = ((Minecraft.getMinecraft().world.getTotalWorldTime() + partialTick) % 44) + 1;

    double keyframe = (44 * leverOffset) + 1;
    GibsAnimationRegistry.getAnimation("lift_lever").renderAnimation(keyframe, brightness);

    GlStateManager.popMatrix();
    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example #13
Source File: BlockGearbox.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState() {
    return new BlockStateContainer(this, BlockHorizontal.FACING);
}
 
Example #14
Source File: BlockGearbox.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public int getMetaFromState(IBlockState state) {
    int i = state.getValue(BlockHorizontal.FACING)
        .getIndex();
    return i;
}
 
Example #15
Source File: BlockLiftLever.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
protected BlockStateContainer createBlockState() {
    return new BlockStateContainer(this, BlockHorizontal.FACING);
}
 
Example #16
Source File: BlockLiftLever.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public int getMetaFromState(IBlockState state) {
    return state.getValue(BlockHorizontal.FACING)
        .getIndex();
}