From 9ac78a258890cf38e6715a324d935e1e6135146d Mon Sep 17 00:00:00 2001 From: Aether Date: Thu, 17 Oct 2024 19:17:59 -0400 Subject: [PATCH] r o t a t e --- src/game/java/net/minecraft/block/Block.java | 22 +++ .../java/net/minecraft/block/BlockAnvil.java | 10 + .../java/net/minecraft/block/BlockBanner.java | 18 ++ .../java/net/minecraft/block/BlockBed.java | 18 ++ .../java/net/minecraft/block/BlockButton.java | 18 ++ .../java/net/minecraft/block/BlockChest.java | 18 ++ .../java/net/minecraft/block/BlockCocoa.java | 18 ++ .../minecraft/block/BlockCommandBlock.java | 2 + .../net/minecraft/block/BlockDispenser.java | 18 ++ .../java/net/minecraft/block/BlockDoor.java | 18 ++ .../minecraft/block/BlockEndPortalFrame.java | 18 ++ .../java/net/minecraft/block/BlockEndRod.java | 18 ++ .../net/minecraft/block/BlockEnderChest.java | 18 ++ .../java/net/minecraft/block/BlockFence.java | 41 ++++ .../net/minecraft/block/BlockFenceGate.java | 19 ++ .../net/minecraft/block/BlockFurnace.java | 18 ++ .../java/net/minecraft/block/BlockHopper.java | 18 ++ .../minecraft/block/BlockHugeMushroom.java | 187 ++++++++++++++++++ .../java/net/minecraft/block/BlockLadder.java | 18 ++ .../java/net/minecraft/block/BlockLever.java | 98 +++++++++ .../java/net/minecraft/block/BlockLog.java | 28 +++ .../java/net/minecraft/block/BlockPane.java | 43 ++++ .../net/minecraft/block/BlockPistonBase.java | 18 ++ .../minecraft/block/BlockPistonExtension.java | 18 ++ .../minecraft/block/BlockPistonMoving.java | 18 ++ .../java/net/minecraft/block/BlockPortal.java | 28 +++ .../net/minecraft/block/BlockPumpkin.java | 18 ++ .../java/net/minecraft/block/BlockQuartz.java | 28 +++ .../java/net/minecraft/block/BlockRail.java | 181 +++++++++++++++++ .../minecraft/block/BlockRailDetector.java | 181 +++++++++++++++++ .../net/minecraft/block/BlockRailPowered.java | 181 +++++++++++++++++ .../block/BlockRedstoneComparator.java | 18 ++ .../block/BlockRedstoneRepeater.java | 18 ++ .../minecraft/block/BlockRedstoneWire.java | 43 ++++ .../minecraft/block/BlockRotatedPillar.java | 28 +++ .../java/net/minecraft/block/BlockSkull.java | 18 ++ .../block/BlockStainedGlassPane.java | 43 ++++ .../java/net/minecraft/block/BlockStairs.java | 74 +++++++ .../minecraft/block/BlockStandingSign.java | 18 ++ .../java/net/minecraft/block/BlockTorch.java | 18 ++ .../net/minecraft/block/BlockTrapDoor.java | 18 ++ .../net/minecraft/block/BlockTripWire.java | 43 ++++ .../minecraft/block/BlockTripWireHook.java | 18 ++ .../java/net/minecraft/block/BlockVine.java | 43 ++++ .../net/minecraft/block/BlockWallSign.java | 18 ++ .../net/minecraft/block/state/BlockState.java | 130 ++++++++++++ .../block/state/IBlockProperties.java | 69 +++++++ .../minecraft/block/state/IBlockState.java | 2 +- src/game/java/net/minecraft/util/Mirror.java | 98 +++++++++ .../java/net/minecraft/util/Rotation.java | 126 ++++++++++++ 50 files changed, 2197 insertions(+), 1 deletion(-) create mode 100644 src/game/java/net/minecraft/block/state/IBlockProperties.java create mode 100644 src/game/java/net/minecraft/util/Mirror.java create mode 100644 src/game/java/net/minecraft/util/Rotation.java diff --git a/src/game/java/net/minecraft/block/Block.java b/src/game/java/net/minecraft/block/Block.java index 88d52d6..dcdb0d3 100644 --- a/src/game/java/net/minecraft/block/Block.java +++ b/src/game/java/net/minecraft/block/Block.java @@ -33,10 +33,12 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.RegistryNamespacedDefaultedByKey; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Rotation; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; import net.minecraft.world.EnumSkyBlock; @@ -282,6 +284,26 @@ public class Block implements ILitBlock { return iblockstate; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + return state; + } + + @Deprecated + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + return state; + } + public Block(Material parMaterial, MapColor parMapColor) { this.enableStats = true; this.stepSound = soundTypeStone; diff --git a/src/game/java/net/minecraft/block/BlockAnvil.java b/src/game/java/net/minecraft/block/BlockAnvil.java index 638af3b..93361b7 100644 --- a/src/game/java/net/minecraft/block/BlockAnvil.java +++ b/src/game/java/net/minecraft/block/BlockAnvil.java @@ -22,6 +22,7 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.EnumFacing; import net.minecraft.util.IChatComponent; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; @@ -173,6 +174,15 @@ public class BlockAnvil extends BlockFalling { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + return state.getBlock() != this ? state : state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, DAMAGE }); } diff --git a/src/game/java/net/minecraft/block/BlockBanner.java b/src/game/java/net/minecraft/block/BlockBanner.java index 95b0301..35ab64d 100644 --- a/src/game/java/net/minecraft/block/BlockBanner.java +++ b/src/game/java/net/minecraft/block/BlockBanner.java @@ -18,6 +18,8 @@ import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -168,6 +170,14 @@ public class BlockBanner extends BlockContainer { this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, BlockPos blockpos) { EnumFacing enumfacing = (EnumFacing) iblockaccess.getBlockState(blockpos).getValue(FACING); float f = 0.0F; @@ -226,6 +236,14 @@ public class BlockBanner extends BlockContainer { this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, Integer.valueOf(0))); } + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(ROTATION, Integer.valueOf(rot.rotate(((Integer)state.getValue(ROTATION)).intValue(), 16))); + } + + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withProperty(ROTATION, Integer.valueOf(mirrorIn.mirrorRotation(((Integer)state.getValue(ROTATION)).intValue(), 16))); + } + public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { if (!worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid()) { this.dropBlockAsItem(worldIn, pos, state, 0); diff --git a/src/game/java/net/minecraft/block/BlockBed.java b/src/game/java/net/minecraft/block/BlockBed.java index 0fd9816..b08ac27 100644 --- a/src/game/java/net/minecraft/block/BlockBed.java +++ b/src/game/java/net/minecraft/block/BlockBed.java @@ -20,6 +20,8 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -301,6 +303,22 @@ public class BlockBed extends BlockDirectional { return state; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + /** * + * Convert the BlockState into the correct metadata value diff --git a/src/game/java/net/minecraft/block/BlockButton.java b/src/game/java/net/minecraft/block/BlockButton.java index 11c9e31..b719930 100644 --- a/src/game/java/net/minecraft/block/BlockButton.java +++ b/src/game/java/net/minecraft/block/BlockButton.java @@ -16,6 +16,8 @@ import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -373,6 +375,22 @@ public abstract class BlockButton extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, POWERED }); } diff --git a/src/game/java/net/minecraft/block/BlockChest.java b/src/game/java/net/minecraft/block/BlockChest.java index a6e05ca..a473ba5 100644 --- a/src/game/java/net/minecraft/block/BlockChest.java +++ b/src/game/java/net/minecraft/block/BlockChest.java @@ -24,6 +24,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.ILockableContainer; import net.minecraft.world.World; @@ -519,6 +521,22 @@ public class BlockChest extends BlockContainer { return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/BlockCocoa.java b/src/game/java/net/minecraft/block/BlockCocoa.java index a86fcf8..ba8a82f 100644 --- a/src/game/java/net/minecraft/block/BlockCocoa.java +++ b/src/game/java/net/minecraft/block/BlockCocoa.java @@ -17,6 +17,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -240,6 +242,22 @@ public class BlockCocoa extends BlockDirectional implements IGrowable { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, AGE }); } diff --git a/src/game/java/net/minecraft/block/BlockCommandBlock.java b/src/game/java/net/minecraft/block/BlockCommandBlock.java index 4e1326d..712cfa0 100644 --- a/src/game/java/net/minecraft/block/BlockCommandBlock.java +++ b/src/game/java/net/minecraft/block/BlockCommandBlock.java @@ -16,6 +16,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** diff --git a/src/game/java/net/minecraft/block/BlockDispenser.java b/src/game/java/net/minecraft/block/BlockDispenser.java index 6179c66..24cef15 100644 --- a/src/game/java/net/minecraft/block/BlockDispenser.java +++ b/src/game/java/net/minecraft/block/BlockDispenser.java @@ -26,7 +26,9 @@ import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.tileentity.TileEntityDropper; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; import net.minecraft.util.RegistryDefaulted; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -289,6 +291,22 @@ public class BlockDispenser extends BlockContainer { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, TRIGGERED }); } diff --git a/src/game/java/net/minecraft/block/BlockDoor.java b/src/game/java/net/minecraft/block/BlockDoor.java index c31e9e7..d869473 100644 --- a/src/game/java/net/minecraft/block/BlockDoor.java +++ b/src/game/java/net/minecraft/block/BlockDoor.java @@ -18,7 +18,9 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Rotation; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; @@ -335,6 +337,22 @@ public class BlockDoor extends Block { return iblockstate; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.getValue(HALF) != BlockDoor.EnumDoorHalf.LOWER ? state : state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + /** * + * Convert the given metadata into a BlockState for this Block diff --git a/src/game/java/net/minecraft/block/BlockEndPortalFrame.java b/src/game/java/net/minecraft/block/BlockEndPortalFrame.java index e662bb6..8f60388 100644 --- a/src/game/java/net/minecraft/block/BlockEndPortalFrame.java +++ b/src/game/java/net/minecraft/block/BlockEndPortalFrame.java @@ -16,6 +16,8 @@ import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -141,6 +143,22 @@ public class BlockEndPortalFrame extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, EYE }); } diff --git a/src/game/java/net/minecraft/block/BlockEndRod.java b/src/game/java/net/minecraft/block/BlockEndRod.java index 223b8f5..aa8deb7 100644 --- a/src/game/java/net/minecraft/block/BlockEndRod.java +++ b/src/game/java/net/minecraft/block/BlockEndRod.java @@ -14,6 +14,8 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -26,6 +28,22 @@ public class BlockEndRod extends Block { this.setCreativeTab(CreativeTabs.tabDecorations); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withProperty(FACING, mirrorIn.mirror((EnumFacing)state.getValue(FACING))); + } + public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos blockpos, IBlockState iblockstate) { this.setBlockBoundsBasedOnState(world, blockpos); return super.getCollisionBoundingBox(world, blockpos, iblockstate); diff --git a/src/game/java/net/minecraft/block/BlockEnderChest.java b/src/game/java/net/minecraft/block/BlockEnderChest.java index 0ffe3fd..256f8a7 100644 --- a/src/game/java/net/minecraft/block/BlockEnderChest.java +++ b/src/game/java/net/minecraft/block/BlockEnderChest.java @@ -20,6 +20,8 @@ import net.minecraft.tileentity.TileEntityEnderChest; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -189,6 +191,22 @@ public class BlockEnderChest extends BlockContainer { return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/BlockFence.java b/src/game/java/net/minecraft/block/BlockFence.java index ccc5b95..40ce1a6 100644 --- a/src/game/java/net/minecraft/block/BlockFence.java +++ b/src/game/java/net/minecraft/block/BlockFence.java @@ -16,6 +16,8 @@ import net.minecraft.item.ItemLead; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -222,6 +224,45 @@ public class BlockFence extends Block { .withProperty(WEST, Boolean.valueOf(this.canConnectTo(iblockaccess, blockpos.west()))); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + switch (rot) + { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + switch (mirrorIn) + { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + + default: + return super.withMirror(state, mirrorIn); + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH }); } diff --git a/src/game/java/net/minecraft/block/BlockFenceGate.java b/src/game/java/net/minecraft/block/BlockFenceGate.java index c5e4c98..7e11743 100644 --- a/src/game/java/net/minecraft/block/BlockFenceGate.java +++ b/src/game/java/net/minecraft/block/BlockFenceGate.java @@ -12,6 +12,8 @@ import net.minecraft.init.Blocks; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -75,6 +77,23 @@ public class BlockFenceGate extends BlockDirectional { return iblockstate; } + + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } public boolean canPlaceBlockAt(World world, BlockPos blockpos) { return world.getBlockState(blockpos.down()).getBlock().getMaterial().isSolid() diff --git a/src/game/java/net/minecraft/block/BlockFurnace.java b/src/game/java/net/minecraft/block/BlockFurnace.java index 985d623..7769f74 100644 --- a/src/game/java/net/minecraft/block/BlockFurnace.java +++ b/src/game/java/net/minecraft/block/BlockFurnace.java @@ -20,6 +20,8 @@ import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -267,6 +269,22 @@ public class BlockFurnace extends BlockContainer { return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/BlockHopper.java b/src/game/java/net/minecraft/block/BlockHopper.java index 24d45c6..6933c35 100644 --- a/src/game/java/net/minecraft/block/BlockHopper.java +++ b/src/game/java/net/minecraft/block/BlockHopper.java @@ -25,6 +25,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -259,6 +261,22 @@ public class BlockHopper extends BlockContainer { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, ENABLED }); } diff --git a/src/game/java/net/minecraft/block/BlockHugeMushroom.java b/src/game/java/net/minecraft/block/BlockHugeMushroom.java index 738e0d9..65baa00 100644 --- a/src/game/java/net/minecraft/block/BlockHugeMushroom.java +++ b/src/game/java/net/minecraft/block/BlockHugeMushroom.java @@ -13,6 +13,8 @@ import net.minecraft.item.Item; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -122,6 +124,191 @@ public class BlockHugeMushroom extends Block { return ((BlockHugeMushroom.EnumType) iblockstate.getValue(VARIANT)).getMetadata(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)) + { + case STEM: + break; + + case NORTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_EAST); + + case NORTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH); + + case NORTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_WEST); + + case WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.EAST); + + case EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.WEST); + + case SOUTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_EAST); + + case SOUTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH); + + case SOUTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_WEST); + + default: + return state; + } + + case COUNTERCLOCKWISE_90: + switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)) + { + case STEM: + break; + + case NORTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_WEST); + + case NORTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.WEST); + + case NORTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_WEST); + + case WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH); + + case EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH); + + case SOUTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_EAST); + + case SOUTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.EAST); + + case SOUTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_EAST); + + default: + return state; + } + + case CLOCKWISE_90: + switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)) + { + case STEM: + break; + + case NORTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_EAST); + + case NORTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.EAST); + + case NORTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_EAST); + + case WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH); + + case EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH); + + case SOUTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_WEST); + + case SOUTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.WEST); + + case SOUTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_WEST); + + default: + return state; + } + + default: + return state; + } + } + + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + BlockHugeMushroom.EnumType blockhugemushroom$enumtype = (BlockHugeMushroom.EnumType)state.getValue(VARIANT); + + switch (mirrorIn) + { + case LEFT_RIGHT: + switch (blockhugemushroom$enumtype) + { + case NORTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_WEST); + + case NORTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH); + + case NORTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_EAST); + + case WEST: + case EAST: + default: + return super.withMirror(state, mirrorIn); + + case SOUTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_WEST); + + case SOUTH: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH); + + case SOUTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_EAST); + } + + case FRONT_BACK: + switch (blockhugemushroom$enumtype) + { + case NORTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_EAST); + + case NORTH: + case SOUTH: + default: + break; + + case NORTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.NORTH_WEST); + + case WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.EAST); + + case EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.WEST); + + case SOUTH_WEST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_EAST); + + case SOUTH_EAST: + return state.withProperty(VARIANT, BlockHugeMushroom.EnumType.SOUTH_WEST); + } + } + + return super.withMirror(state, mirrorIn); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { VARIANT }); } diff --git a/src/game/java/net/minecraft/block/BlockLadder.java b/src/game/java/net/minecraft/block/BlockLadder.java index f843827..4a788e6 100644 --- a/src/game/java/net/minecraft/block/BlockLadder.java +++ b/src/game/java/net/minecraft/block/BlockLadder.java @@ -11,6 +11,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -169,6 +171,22 @@ public class BlockLadder extends Block { return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/BlockLever.java b/src/game/java/net/minecraft/block/BlockLever.java index b0f84e7..4f3fbeb 100644 --- a/src/game/java/net/minecraft/block/BlockLever.java +++ b/src/game/java/net/minecraft/block/BlockLever.java @@ -13,6 +13,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -269,6 +271,102 @@ public class BlockLever extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + switch ((BlockLever.EnumOrientation)state.getValue(FACING)) + { + case EAST: + return state.withProperty(FACING, BlockLever.EnumOrientation.WEST); + + case WEST: + return state.withProperty(FACING, BlockLever.EnumOrientation.EAST); + + case SOUTH: + return state.withProperty(FACING, BlockLever.EnumOrientation.NORTH); + + case NORTH: + return state.withProperty(FACING, BlockLever.EnumOrientation.SOUTH); + + default: + return state; + } + + case COUNTERCLOCKWISE_90: + switch ((BlockLever.EnumOrientation)state.getValue(FACING)) + { + case EAST: + return state.withProperty(FACING, BlockLever.EnumOrientation.NORTH); + + case WEST: + return state.withProperty(FACING, BlockLever.EnumOrientation.SOUTH); + + case SOUTH: + return state.withProperty(FACING, BlockLever.EnumOrientation.EAST); + + case NORTH: + return state.withProperty(FACING, BlockLever.EnumOrientation.WEST); + + case UP_Z: + return state.withProperty(FACING, BlockLever.EnumOrientation.UP_X); + + case UP_X: + return state.withProperty(FACING, BlockLever.EnumOrientation.UP_Z); + + case DOWN_X: + return state.withProperty(FACING, BlockLever.EnumOrientation.DOWN_Z); + + case DOWN_Z: + return state.withProperty(FACING, BlockLever.EnumOrientation.DOWN_X); + } + + case CLOCKWISE_90: + switch ((BlockLever.EnumOrientation)state.getValue(FACING)) + { + case EAST: + return state.withProperty(FACING, BlockLever.EnumOrientation.SOUTH); + + case WEST: + return state.withProperty(FACING, BlockLever.EnumOrientation.NORTH); + + case SOUTH: + return state.withProperty(FACING, BlockLever.EnumOrientation.WEST); + + case NORTH: + return state.withProperty(FACING, BlockLever.EnumOrientation.EAST); + + case UP_Z: + return state.withProperty(FACING, BlockLever.EnumOrientation.UP_X); + + case UP_X: + return state.withProperty(FACING, BlockLever.EnumOrientation.UP_Z); + + case DOWN_X: + return state.withProperty(FACING, BlockLever.EnumOrientation.DOWN_Z); + + case DOWN_Z: + return state.withProperty(FACING, BlockLever.EnumOrientation.DOWN_X); + } + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation(((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing())); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, POWERED }); } diff --git a/src/game/java/net/minecraft/block/BlockLog.java b/src/game/java/net/minecraft/block/BlockLog.java index 5e6e7b6..02e68b4 100644 --- a/src/game/java/net/minecraft/block/BlockLog.java +++ b/src/game/java/net/minecraft/block/BlockLog.java @@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -80,6 +81,33 @@ public abstract class BlockLog extends BlockRotatedPillar { BlockLog.EnumAxis.fromFacingAxis(enumfacing.getAxis())); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case COUNTERCLOCKWISE_90: + case CLOCKWISE_90: + switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) + { + case X: + return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); + + case Z: + return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); + + default: + return state; + } + + default: + return state; + } + } + public static enum EnumAxis implements IStringSerializable { X("x"), Y("y"), Z("z"), NONE("none"); diff --git a/src/game/java/net/minecraft/block/BlockPane.java b/src/game/java/net/minecraft/block/BlockPane.java index 987ada1..6c684a6 100644 --- a/src/game/java/net/minecraft/block/BlockPane.java +++ b/src/game/java/net/minecraft/block/BlockPane.java @@ -16,6 +16,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -217,6 +219,47 @@ public class BlockPane extends Block { return 0; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + switch (mirrorIn) + { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + + default: + return super.withMirror(state, mirrorIn); + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH }); } diff --git a/src/game/java/net/minecraft/block/BlockPistonBase.java b/src/game/java/net/minecraft/block/BlockPistonBase.java index 3db3f79..d064458 100644 --- a/src/game/java/net/minecraft/block/BlockPistonBase.java +++ b/src/game/java/net/minecraft/block/BlockPistonBase.java @@ -20,6 +20,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -457,6 +459,22 @@ public class BlockPistonBase extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, EXTENDED }); } diff --git a/src/game/java/net/minecraft/block/BlockPistonExtension.java b/src/game/java/net/minecraft/block/BlockPistonExtension.java index f878535..a13f36c 100644 --- a/src/game/java/net/minecraft/block/BlockPistonExtension.java +++ b/src/game/java/net/minecraft/block/BlockPistonExtension.java @@ -18,6 +18,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -257,6 +259,22 @@ public class BlockPistonExtension extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, TYPE, SHORT }); } diff --git a/src/game/java/net/minecraft/block/BlockPistonMoving.java b/src/game/java/net/minecraft/block/BlockPistonMoving.java index ab871ed..9c151ee 100644 --- a/src/game/java/net/minecraft/block/BlockPistonMoving.java +++ b/src/game/java/net/minecraft/block/BlockPistonMoving.java @@ -16,7 +16,9 @@ import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Rotation; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -295,6 +297,22 @@ public class BlockPistonMoving extends BlockContainer { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, TYPE }); } diff --git a/src/game/java/net/minecraft/block/BlockPortal.java b/src/game/java/net/minecraft/block/BlockPortal.java index 553a205..2d3c204 100644 --- a/src/game/java/net/minecraft/block/BlockPortal.java +++ b/src/game/java/net/minecraft/block/BlockPortal.java @@ -19,6 +19,7 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -256,6 +257,33 @@ public class BlockPortal extends BlockBreakable { return getMetaForAxis((EnumFacing.Axis) iblockstate.getValue(AXIS)); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case COUNTERCLOCKWISE_90: + case CLOCKWISE_90: + switch ((EnumFacing.Axis)state.getValue(AXIS)) + { + case X: + return state.withProperty(AXIS, EnumFacing.Axis.Z); + + case Z: + return state.withProperty(AXIS, EnumFacing.Axis.X); + + default: + return state; + } + + default: + return state; + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { AXIS }); } diff --git a/src/game/java/net/minecraft/block/BlockPumpkin.java b/src/game/java/net/minecraft/block/BlockPumpkin.java index 93bd282..4e17377 100644 --- a/src/game/java/net/minecraft/block/BlockPumpkin.java +++ b/src/game/java/net/minecraft/block/BlockPumpkin.java @@ -19,6 +19,8 @@ import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -166,6 +168,22 @@ public class BlockPumpkin extends BlockDirectional { return ((EnumFacing) iblockstate.getValue(FACING)).getHorizontalIndex(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/BlockQuartz.java b/src/game/java/net/minecraft/block/BlockQuartz.java index 5ebd146..98bfd0e 100644 --- a/src/game/java/net/minecraft/block/BlockQuartz.java +++ b/src/game/java/net/minecraft/block/BlockQuartz.java @@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -139,6 +140,33 @@ public class BlockQuartz extends Block { return ((BlockQuartz.EnumType) iblockstate.getValue(VARIANT)).getMetadata(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case COUNTERCLOCKWISE_90: + case CLOCKWISE_90: + switch ((BlockQuartz.EnumType)state.getValue(VARIANT)) + { + case LINES_X: + return state.withProperty(VARIANT, BlockQuartz.EnumType.LINES_Z); + + case LINES_Z: + return state.withProperty(VARIANT, BlockQuartz.EnumType.LINES_X); + + default: + return state; + } + + default: + return state; + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { VARIANT }); } diff --git a/src/game/java/net/minecraft/block/BlockRail.java b/src/game/java/net/minecraft/block/BlockRail.java index 33736c5..4146363 100644 --- a/src/game/java/net/minecraft/block/BlockRail.java +++ b/src/game/java/net/minecraft/block/BlockRail.java @@ -5,6 +5,8 @@ import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockPos; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -77,6 +79,185 @@ public class BlockRail extends BlockRailBase { return ((BlockRailBase.EnumRailDirection) iblockstate.getValue(SHAPE)).getMetadata(); } + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + } + + case COUNTERCLOCKWISE_90: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); + + case EAST_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); + } + + case CLOCKWISE_90: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); + + case EAST_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); + } + + default: + return state; + } + } + + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(SHAPE); + + switch (mirrorIn) + { + case LEFT_RIGHT: + switch (blockrailbase$enumraildirection) + { + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + default: + return super.withMirror(state, mirrorIn); + } + + case FRONT_BACK: + switch (blockrailbase$enumraildirection) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_NORTH: + case ASCENDING_SOUTH: + default: + break; + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + } + } + + return super.withMirror(state, mirrorIn); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { SHAPE }); } diff --git a/src/game/java/net/minecraft/block/BlockRailDetector.java b/src/game/java/net/minecraft/block/BlockRailDetector.java index f9dbc52..3be268a 100644 --- a/src/game/java/net/minecraft/block/BlockRailDetector.java +++ b/src/game/java/net/minecraft/block/BlockRailDetector.java @@ -19,6 +19,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EntitySelectors; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -221,6 +223,185 @@ public class BlockRailDetector extends BlockRailBase { return i; } + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + } + + case COUNTERCLOCKWISE_90: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); + + case EAST_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); + } + + case CLOCKWISE_90: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); + + case EAST_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); + } + + default: + return state; + } + } + + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(SHAPE); + + switch (mirrorIn) + { + case LEFT_RIGHT: + switch (blockrailbase$enumraildirection) + { + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + default: + return super.withMirror(state, mirrorIn); + } + + case FRONT_BACK: + switch (blockrailbase$enumraildirection) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_NORTH: + case ASCENDING_SOUTH: + default: + break; + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + } + } + + return super.withMirror(state, mirrorIn); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { SHAPE, POWERED }); } diff --git a/src/game/java/net/minecraft/block/BlockRailPowered.java b/src/game/java/net/minecraft/block/BlockRailPowered.java index b0fa622..8d3f3f8 100644 --- a/src/game/java/net/minecraft/block/BlockRailPowered.java +++ b/src/game/java/net/minecraft/block/BlockRailPowered.java @@ -8,6 +8,8 @@ import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockPos; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -206,6 +208,185 @@ public class BlockRailPowered extends BlockRailBase { return i; } + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + } + + case COUNTERCLOCKWISE_90: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case NORTH_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); + + case EAST_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); + + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + } + + case CLOCKWISE_90: + switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)) + { + case NORTH_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); + + case EAST_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); + + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + } + + default: + return state; + } + } + + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(SHAPE); + + switch (mirrorIn) + { + case LEFT_RIGHT: + switch (blockrailbase$enumraildirection) + { + case ASCENDING_NORTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH); + + case ASCENDING_SOUTH: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH); + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + default: + return super.withMirror(state, mirrorIn); + } + + case FRONT_BACK: + switch (blockrailbase$enumraildirection) + { + case ASCENDING_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST); + + case ASCENDING_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST); + + case ASCENDING_NORTH: + case ASCENDING_SOUTH: + default: + break; + + case SOUTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST); + + case SOUTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST); + + case NORTH_WEST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST); + + case NORTH_EAST: + return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST); + } + } + + return super.withMirror(state, mirrorIn); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { SHAPE, POWERED }); } diff --git a/src/game/java/net/minecraft/block/BlockRedstoneComparator.java b/src/game/java/net/minecraft/block/BlockRedstoneComparator.java index 71d6a37..547223d 100644 --- a/src/game/java/net/minecraft/block/BlockRedstoneComparator.java +++ b/src/game/java/net/minecraft/block/BlockRedstoneComparator.java @@ -24,6 +24,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -303,6 +305,22 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, MODE, POWERED }); } diff --git a/src/game/java/net/minecraft/block/BlockRedstoneRepeater.java b/src/game/java/net/minecraft/block/BlockRedstoneRepeater.java index 9f26bef..483537d 100644 --- a/src/game/java/net/minecraft/block/BlockRedstoneRepeater.java +++ b/src/game/java/net/minecraft/block/BlockRedstoneRepeater.java @@ -14,6 +14,8 @@ import net.minecraft.item.Item; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -169,6 +171,22 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, DELAY, LOCKED }); } diff --git a/src/game/java/net/minecraft/block/BlockRedstoneWire.java b/src/game/java/net/minecraft/block/BlockRedstoneWire.java index 1297c85..c42dda8 100644 --- a/src/game/java/net/minecraft/block/BlockRedstoneWire.java +++ b/src/game/java/net/minecraft/block/BlockRedstoneWire.java @@ -24,6 +24,8 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; import net.minecraft.util.MathHelper; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -479,6 +481,47 @@ public class BlockRedstoneWire extends Block { return ((Integer) iblockstate.getValue(POWER)).intValue(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + switch (mirrorIn) + { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + + default: + return super.withMirror(state, mirrorIn); + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { NORTH, EAST, SOUTH, WEST, POWER }); } diff --git a/src/game/java/net/minecraft/block/BlockRotatedPillar.java b/src/game/java/net/minecraft/block/BlockRotatedPillar.java index bae735b..f0113ec 100644 --- a/src/game/java/net/minecraft/block/BlockRotatedPillar.java +++ b/src/game/java/net/minecraft/block/BlockRotatedPillar.java @@ -4,6 +4,7 @@ import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Rotation; import net.minecraft.world.World; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; @@ -54,4 +55,31 @@ public class BlockRotatedPillar extends Block { protected BlockRotatedPillar(Material parMaterial, MapColor parMapColor) { super(parMaterial, parMapColor); } + + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case COUNTERCLOCKWISE_90: + case CLOCKWISE_90: + switch ((EnumFacing.Axis)state.getValue(AXIS)) + { + case X: + return state.withProperty(AXIS, EnumFacing.Axis.Z); + + case Z: + return state.withProperty(AXIS, EnumFacing.Axis.X); + + default: + return state; + } + + default: + return state; + } + } } \ No newline at end of file diff --git a/src/game/java/net/minecraft/block/BlockSkull.java b/src/game/java/net/minecraft/block/BlockSkull.java index d1a271f..39092de 100644 --- a/src/game/java/net/minecraft/block/BlockSkull.java +++ b/src/game/java/net/minecraft/block/BlockSkull.java @@ -32,6 +32,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.StatCollector; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.IBlockAccess; @@ -294,6 +296,22 @@ public class BlockSkull extends BlockContainer { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, NODROP }); } diff --git a/src/game/java/net/minecraft/block/BlockStainedGlassPane.java b/src/game/java/net/minecraft/block/BlockStainedGlassPane.java index 0e1c1ae..9fa9d7f 100644 --- a/src/game/java/net/minecraft/block/BlockStainedGlassPane.java +++ b/src/game/java/net/minecraft/block/BlockStainedGlassPane.java @@ -14,6 +14,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -107,6 +109,47 @@ public class BlockStainedGlassPane extends BlockPane { public int getMetaFromState(IBlockState iblockstate) { return ((EnumDyeColor) iblockstate.getValue(COLOR)).getMetadata(); } + + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + switch (mirrorIn) + { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + + default: + return super.withMirror(state, mirrorIn); + } + } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH, COLOR }); diff --git a/src/game/java/net/minecraft/block/BlockStairs.java b/src/game/java/net/minecraft/block/BlockStairs.java index b7a6ab5..7313551 100644 --- a/src/game/java/net/minecraft/block/BlockStairs.java +++ b/src/game/java/net/minecraft/block/BlockStairs.java @@ -22,7 +22,9 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Rotation; import net.minecraft.util.Vec3; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; @@ -693,6 +695,78 @@ public class BlockStairs extends Block { return iblockstate; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + @SuppressWarnings("incomplete-switch") + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); + BlockStairs.EnumShape blockstairs$enumshape = (BlockStairs.EnumShape)state.getValue(SHAPE); + + switch (mirrorIn) + { + case LEFT_RIGHT: + if (enumfacing.getAxis() == EnumFacing.Axis.Z) + { + switch (blockstairs$enumshape) + { + case OUTER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_RIGHT); + + case OUTER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_LEFT); + + case INNER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_LEFT); + + case INNER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_RIGHT); + + default: + return state.withRotation(Rotation.CLOCKWISE_180); + } + } + + break; + + case FRONT_BACK: + if (enumfacing.getAxis() == EnumFacing.Axis.X) + { + switch (blockstairs$enumshape) + { + case OUTER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_RIGHT); + + case OUTER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_LEFT); + + case INNER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_RIGHT); + + case INNER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_LEFT); + + case STRAIGHT: + return state.withRotation(Rotation.CLOCKWISE_180); + } + } + } + + return super.withMirror(state, mirrorIn); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, HALF, SHAPE }); } diff --git a/src/game/java/net/minecraft/block/BlockStandingSign.java b/src/game/java/net/minecraft/block/BlockStandingSign.java index 55bdfe0..a7bc313 100644 --- a/src/game/java/net/minecraft/block/BlockStandingSign.java +++ b/src/game/java/net/minecraft/block/BlockStandingSign.java @@ -5,6 +5,8 @@ import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockPos; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.World; /** @@ -72,6 +74,22 @@ public class BlockStandingSign extends BlockSign { return ((Integer) iblockstate.getValue(ROTATION)).intValue(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(ROTATION, Integer.valueOf(rot.rotate(((Integer)state.getValue(ROTATION)).intValue(), 16))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withProperty(ROTATION, Integer.valueOf(mirrorIn.mirrorRotation(((Integer)state.getValue(ROTATION)).intValue(), 16))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { ROTATION }); } diff --git a/src/game/java/net/minecraft/block/BlockTorch.java b/src/game/java/net/minecraft/block/BlockTorch.java index 92cbb0e..3d1b888 100644 --- a/src/game/java/net/minecraft/block/BlockTorch.java +++ b/src/game/java/net/minecraft/block/BlockTorch.java @@ -17,7 +17,9 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Rotation; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -282,6 +284,22 @@ public class BlockTorch extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/BlockTrapDoor.java b/src/game/java/net/minecraft/block/BlockTrapDoor.java index 8f3127a..5d83d6a 100644 --- a/src/game/java/net/minecraft/block/BlockTrapDoor.java +++ b/src/game/java/net/minecraft/block/BlockTrapDoor.java @@ -16,7 +16,9 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Rotation; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -278,6 +280,22 @@ public class BlockTrapDoor extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, OPEN, HALF }); } diff --git a/src/game/java/net/minecraft/block/BlockTripWire.java b/src/game/java/net/minecraft/block/BlockTripWire.java index 2a9614a..0d62efa 100644 --- a/src/game/java/net/minecraft/block/BlockTripWire.java +++ b/src/game/java/net/minecraft/block/BlockTripWire.java @@ -17,6 +17,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -298,6 +300,47 @@ public class BlockTripWire extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + switch (mirrorIn) + { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + + default: + return super.withMirror(state, mirrorIn); + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { POWERED, SUSPENDED, ATTACHED, DISARMED, NORTH, EAST, WEST, SOUTH }); diff --git a/src/game/java/net/minecraft/block/BlockTripWireHook.java b/src/game/java/net/minecraft/block/BlockTripWireHook.java index 55d0fc0..1910b1d 100644 --- a/src/game/java/net/minecraft/block/BlockTripWireHook.java +++ b/src/game/java/net/minecraft/block/BlockTripWireHook.java @@ -18,6 +18,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -360,6 +362,22 @@ public class BlockTripWireHook extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, POWERED, ATTACHED, SUSPENDED }); } diff --git a/src/game/java/net/minecraft/block/BlockVine.java b/src/game/java/net/minecraft/block/BlockVine.java index 73ba858..58395f0 100644 --- a/src/game/java/net/minecraft/block/BlockVine.java +++ b/src/game/java/net/minecraft/block/BlockVine.java @@ -20,6 +20,8 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -462,6 +464,47 @@ public class BlockVine extends Block { return i; } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) + { + switch (rot) + { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + + default: + return state; + } + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) + { + switch (mirrorIn) + { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + + default: + return super.withMirror(state, mirrorIn); + } + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { UP, NORTH, EAST, SOUTH, WEST }); } diff --git a/src/game/java/net/minecraft/block/BlockWallSign.java b/src/game/java/net/minecraft/block/BlockWallSign.java index fb06eac..1d8b3a6 100644 --- a/src/game/java/net/minecraft/block/BlockWallSign.java +++ b/src/game/java/net/minecraft/block/BlockWallSign.java @@ -6,6 +6,8 @@ import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -104,6 +106,22 @@ public class BlockWallSign extends BlockSign { return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); } + /** + * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); + } + + /** + * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed + * blockstate. + */ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); + } + protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING }); } diff --git a/src/game/java/net/minecraft/block/state/BlockState.java b/src/game/java/net/minecraft/block/state/BlockState.java index 666c2f9..67b5246 100644 --- a/src/game/java/net/minecraft/block/state/BlockState.java +++ b/src/game/java/net/minecraft/block/state/BlockState.java @@ -10,6 +10,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; + import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Objects; @@ -20,17 +22,25 @@ import com.google.common.collect.ImmutableTable; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.logisticscraft.occlusionculling.util.Vec3d; import net.hoosiertransfer.Alfheim.ILightInfoProvider; import net.hoosiertransfer.Alfheim.ILitBlock; import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.Cartesian; import net.minecraft.util.EnumFacing; import net.minecraft.util.MapPopulator; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; /** * + @@ -256,6 +266,126 @@ public class BlockState implements ILightInfoProvider { return hashmap; } + public Material getMaterial() + { + return this.block.getMaterial(); + } + + public boolean isFullBlock() + { + return this.block.isFullBlock(); + } + + public int getLightOpacity() + { + return this.block.getLightOpacity(); + } + + public int getLightValue() + { + return this.block.getLightValue(); + } + + public boolean isTranslucent() + { + return this.block.isTranslucent(); + } + + public boolean useNeighborBrightness() + { + return this.block.getUseNeighborBrightness(); + } + + public MapColor getMapColor() + { + return this.block.getMapColor(this); + } + + public IBlockState withRotation(Rotation rot) + { + return this.block.withRotation(this, rot); + } + + public IBlockState withMirror(Mirror mirrorIn) + { + return this.block.withMirror(this, mirrorIn); + } + + public boolean isFullCube() + { + return this.block.isFullCube(); + } + + public float getAmbientOcclusionLightValue() + { + return this.block.getAmbientOcclusionLightValue(); + } + + public boolean isBlockNormalCube() + { + return this.block.isBlockNormalCube(); + } + + public boolean isNormalCube() + { + return this.block.isNormalCube(); + } + + public boolean canProvidePower() + { + return this.block.canProvidePower(); + } + + public int getWeakPower(IBlockAccess blockAccess, BlockPos pos, EnumFacing side) + { + return this.block.getWeakPower(blockAccess, pos, this, side); + } + + public boolean hasComparatorInputOverride() + { + return this.block.hasComparatorInputOverride(); + } + + public int getComparatorInputOverride(World worldIn, BlockPos pos) + { + return this.block.getComparatorInputOverride(worldIn, pos); + } + + public float getBlockHardness(World worldIn, BlockPos pos) + { + return this.block.getBlockHardness(worldIn, pos); + } + + public float getPlayerRelativeBlockHardness(EntityPlayer player, World worldIn, BlockPos pos) + { + return this.block.getPlayerRelativeBlockHardness(player, worldIn, pos); + } + + public int getStrongPower(IBlockAccess blockAccess, BlockPos pos, EnumFacing side) + { + return this.block.getStrongPower(blockAccess, pos, this, side); + } + + public IBlockState getActualState(IBlockAccess blockAccess, BlockPos pos) + { + return this.block.getActualState(this, blockAccess, pos); + } + + public boolean shouldSideBeRendered(IBlockAccess blockAccess, BlockPos pos, EnumFacing facing) + { + return this.block.shouldSideBeRendered(blockAccess, pos, facing); + } + + public boolean isOpaqueCube() + { + return this.block.isOpaqueCube(); + } + + public boolean isFullyOpaque() + { + return this.block.isFullyOpaque(this); + } + public int alfheim$getLightFor(IBlockAccess iBlockAccess, EnumSkyBlock lightType, BlockPos blockPos) { return ((ILitBlock) block).alfheim$getLightFor(((IBlockState) this), iBlockAccess, lightType, blockPos); } diff --git a/src/game/java/net/minecraft/block/state/IBlockProperties.java b/src/game/java/net/minecraft/block/state/IBlockProperties.java new file mode 100644 index 0000000..af3c199 --- /dev/null +++ b/src/game/java/net/minecraft/block/state/IBlockProperties.java @@ -0,0 +1,69 @@ +package net.minecraft.block.state; + +import java.util.List; +import javax.annotation.Nullable; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public interface IBlockProperties +{ + Material getMaterial(); + + boolean isFullBlock(); + + int getLightOpacity(); + + int getLightValue(); + + boolean isTranslucent(); + + boolean useNeighborBrightness(); + + MapColor getMapColor(); + + /** + * Returns the blockstate with the given rotation. If inapplicable, returns itself. + */ + IBlockState withRotation(Rotation rot); + + /** + * Returns the blockstate mirrored in the given way. If inapplicable, returns itself. + */ + IBlockState withMirror(Mirror mirrorIn); + + boolean isFullCube(); + + float getAmbientOcclusionLightValue(); + + boolean isBlockNormalCube(); + + boolean isNormalCube(); + + boolean canProvidePower(); + + boolean hasComparatorInputOverride(); + + int getComparatorInputOverride(World worldIn, BlockPos pos); + + float getBlockHardness(World worldIn, BlockPos pos); + + float getPlayerRelativeBlockHardness(EntityPlayer player, World worldIn, BlockPos pos); + + int getStrongPower(IBlockAccess blockAccess, BlockPos pos, EnumFacing side); + + IBlockState getActualState(IBlockAccess blockAccess, BlockPos pos); + + boolean shouldSideBeRendered(IBlockAccess blockAccess, BlockPos pos, EnumFacing facing); + + boolean isOpaqueCube(); + + boolean isFullyOpaque(); +} diff --git a/src/game/java/net/minecraft/block/state/IBlockState.java b/src/game/java/net/minecraft/block/state/IBlockState.java index 44ef1c4..0075acd 100644 --- a/src/game/java/net/minecraft/block/state/IBlockState.java +++ b/src/game/java/net/minecraft/block/state/IBlockState.java @@ -38,7 +38,7 @@ import net.minecraft.world.IBlockAccess; * POSSIBILITY OF SUCH DAMAGE. * */ -public interface IBlockState { +public interface IBlockState extends IBlockProperties { /** * + * Get the names of all properties defined for this BlockState diff --git a/src/game/java/net/minecraft/util/Mirror.java b/src/game/java/net/minecraft/util/Mirror.java new file mode 100644 index 0000000..a060af8 --- /dev/null +++ b/src/game/java/net/minecraft/util/Mirror.java @@ -0,0 +1,98 @@ +package net.minecraft.util; + +public enum Mirror +{ + NONE("no_mirror"), + LEFT_RIGHT("mirror_left_right"), + FRONT_BACK("mirror_front_back"); + + private final String name; + private static String[] mirrorNames = new String[values().length]; + + private Mirror(String nameIn) + { + this.name = nameIn; + } + + /** + * Mirrors the given rotation like specified by this mirror. rotations start at 0 and go up to rotationCount-1. 0 is + * front, rotationCount/2 is back. + */ + public int mirrorRotation(int rotationIn, int rotationCount) + { + int i = rotationCount / 2; + int j = rotationIn > i ? rotationIn - rotationCount : rotationIn; + + switch (this) + { + case LEFT_RIGHT: + return (rotationCount - j) % rotationCount; + + case FRONT_BACK: + return (i - j + rotationCount) % rotationCount; + + default: + return rotationIn; + } + } + + /** + * Determines the rotation that is equivalent to this mirror if the rotating object faces in the given direction + */ + public Rotation toRotation(EnumFacing facing) + { + EnumFacing.Axis enumfacing$axis = facing.getAxis(); + return (this != LEFT_RIGHT || enumfacing$axis != EnumFacing.Axis.Z) && (this != FRONT_BACK || enumfacing$axis != EnumFacing.Axis.X) ? Rotation.NONE : Rotation.CLOCKWISE_180; + } + + /** + * Mirror the given facing according to this mirror + */ + public EnumFacing mirror(EnumFacing facing) + { + switch (this) + { + case LEFT_RIGHT: + if (facing == EnumFacing.WEST) + { + return EnumFacing.EAST; + } + else + { + if (facing == EnumFacing.EAST) + { + return EnumFacing.WEST; + } + + return facing; + } + + case FRONT_BACK: + if (facing == EnumFacing.NORTH) + { + return EnumFacing.SOUTH; + } + else + { + if (facing == EnumFacing.SOUTH) + { + return EnumFacing.NORTH; + } + + return facing; + } + + default: + return facing; + } + } + + static { + int i = 0; + + for (Mirror mirror : values()) + { + mirrorNames[i++] = mirror.name; + } + } +} diff --git a/src/game/java/net/minecraft/util/Rotation.java b/src/game/java/net/minecraft/util/Rotation.java new file mode 100644 index 0000000..22716a0 --- /dev/null +++ b/src/game/java/net/minecraft/util/Rotation.java @@ -0,0 +1,126 @@ +package net.minecraft.util; + +public enum Rotation +{ + NONE("rotate_0"), + CLOCKWISE_90("rotate_90"), + CLOCKWISE_180("rotate_180"), + COUNTERCLOCKWISE_90("rotate_270"); + + private final String name; + private static String[] rotationNames = new String[values().length]; + + private Rotation(String nameIn) + { + this.name = nameIn; + } + + public Rotation add(Rotation rotation) + { + switch (rotation) + { + case CLOCKWISE_180: + switch (this) + { + case NONE: + return CLOCKWISE_180; + + case CLOCKWISE_90: + return COUNTERCLOCKWISE_90; + + case CLOCKWISE_180: + return NONE; + + case COUNTERCLOCKWISE_90: + return CLOCKWISE_90; + } + + case COUNTERCLOCKWISE_90: + switch (this) + { + case NONE: + return COUNTERCLOCKWISE_90; + + case CLOCKWISE_90: + return NONE; + + case CLOCKWISE_180: + return CLOCKWISE_90; + + case COUNTERCLOCKWISE_90: + return CLOCKWISE_180; + } + + case CLOCKWISE_90: + switch (this) + { + case NONE: + return CLOCKWISE_90; + + case CLOCKWISE_90: + return CLOCKWISE_180; + + case CLOCKWISE_180: + return COUNTERCLOCKWISE_90; + + case COUNTERCLOCKWISE_90: + return NONE; + } + + default: + return this; + } + } + + public EnumFacing rotate(EnumFacing facing) + { + if (facing.getAxis() == EnumFacing.Axis.Y) + { + return facing; + } + else + { + switch (this) + { + case CLOCKWISE_90: + return facing.rotateY(); + + case CLOCKWISE_180: + return facing.getOpposite(); + + case COUNTERCLOCKWISE_90: + return facing.rotateYCCW(); + + default: + return facing; + } + } + } + + public int rotate(int p_185833_1_, int p_185833_2_) + { + switch (this) + { + case CLOCKWISE_90: + return (p_185833_1_ + p_185833_2_ / 4) % p_185833_2_; + + case CLOCKWISE_180: + return (p_185833_1_ + p_185833_2_ / 2) % p_185833_2_; + + case COUNTERCLOCKWISE_90: + return (p_185833_1_ + p_185833_2_ * 3 / 4) % p_185833_2_; + + default: + return p_185833_1_; + } + } + + static { + int i = 0; + + for (Rotation rotation : values()) + { + rotationNames[i++] = rotation.name; + } + } +}