r o t a t e

This commit is contained in:
Aether 2024-10-17 19:17:59 -04:00
parent 10626a44f4
commit 9ac78a2588
50 changed files with 2197 additions and 1 deletions

View File

@ -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;

View File

@ -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 });
}

View File

@ -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);

View File

@ -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

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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;
/**

View File

@ -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 });
}

View File

@ -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

View File

@ -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 });
}

View File

@ -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);

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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()

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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");

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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;
}
}
}

View File

@ -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 });
}

View File

@ -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 });

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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 });
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}