diff --git a/src/main/java/net/minecraft/block/Block.java b/src/main/java/net/minecraft/block/Block.java index 0deeb55..f3f7dca 100644 --- a/src/main/java/net/minecraft/block/Block.java +++ b/src/main/java/net/minecraft/block/Block.java @@ -31,8 +31,10 @@ import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -282,6 +284,28 @@ public class Block implements ILitBlock { return iblockstate; } + @Deprecated + + /** + * 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/main/java/net/minecraft/block/BlockAnvil.java b/src/main/java/net/minecraft/block/BlockAnvil.java index d4ab840..2045df8 100644 --- a/src/main/java/net/minecraft/block/BlockAnvil.java +++ b/src/main/java/net/minecraft/block/BlockAnvil.java @@ -19,6 +19,7 @@ import net.minecraft.inventory.ContainerRepair; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.ITextComponent; @@ -173,6 +174,16 @@ 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/main/java/net/minecraft/block/BlockBanner.java b/src/main/java/net/minecraft/block/BlockBanner.java index 029f03f..cd89f2a 100644 --- a/src/main/java/net/minecraft/block/BlockBanner.java +++ b/src/main/java/net/minecraft/block/BlockBanner.java @@ -16,6 +16,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; @@ -168,6 +170,16 @@ 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 +238,16 @@ 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/main/java/net/minecraft/block/BlockBed.java b/src/main/java/net/minecraft/block/BlockBed.java index d8afc4d..77a769c 100644 --- a/src/main/java/net/minecraft/block/BlockBed.java +++ b/src/main/java/net/minecraft/block/BlockBed.java @@ -18,6 +18,8 @@ import net.minecraft.server.MinecraftServer; 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.util.math.BlockPos; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockAccess; @@ -301,6 +303,24 @@ 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/main/java/net/minecraft/block/BlockButton.java b/src/main/java/net/minecraft/block/BlockButton.java index b583478..8ab0729 100644 --- a/src/main/java/net/minecraft/block/BlockButton.java +++ b/src/main/java/net/minecraft/block/BlockButton.java @@ -14,6 +14,8 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -373,6 +375,24 @@ 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/main/java/net/minecraft/block/BlockChest.java b/src/main/java/net/minecraft/block/BlockChest.java index c1d9e9d..e624e0d 100644 --- a/src/main/java/net/minecraft/block/BlockChest.java +++ b/src/main/java/net/minecraft/block/BlockChest.java @@ -21,6 +21,8 @@ import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -519,6 +521,24 @@ 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/main/java/net/minecraft/block/BlockChorusFlower.java b/src/main/java/net/minecraft/block/BlockChorusFlower.java index f4bf1c4..58bfb16 100644 --- a/src/main/java/net/minecraft/block/BlockChorusFlower.java +++ b/src/main/java/net/minecraft/block/BlockChorusFlower.java @@ -270,7 +270,7 @@ public class BlockChorusFlower extends Block { if (!flag) { worldIn.setBlockState(p_185601_1_.up(i), - EaglerItems.getEaglerBlock("chorus_plant").getDefaultState().withProperty(AGE, Integer.valueOf(5)), + EaglerItems.getEaglerBlock("chorus_flower").getDefaultState().withProperty(AGE, Integer.valueOf(5)), 2); } } diff --git a/src/main/java/net/minecraft/block/BlockCocoa.java b/src/main/java/net/minecraft/block/BlockCocoa.java index 41505e0..a61dd06 100644 --- a/src/main/java/net/minecraft/block/BlockCocoa.java +++ b/src/main/java/net/minecraft/block/BlockCocoa.java @@ -15,6 +15,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -130,6 +132,24 @@ public class BlockCocoa extends BlockDirectional implements IGrowable { } + /** + * 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))); + } + /** * + * Called by ItemBlocks after a block is set in the world, to diff --git a/src/main/java/net/minecraft/block/BlockCommandBlock.java b/src/main/java/net/minecraft/block/BlockCommandBlock.java index 1a2eed2..a4c0fa7 100644 --- a/src/main/java/net/minecraft/block/BlockCommandBlock.java +++ b/src/main/java/net/minecraft/block/BlockCommandBlock.java @@ -19,6 +19,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.StringUtils; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -271,6 +273,24 @@ public class BlockCommandBlock extends BlockContainer { | (((Boolean) state.getValue(CONDITIONAL)).booleanValue() ? 8 : 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) { + 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, CONDITIONAL }); } diff --git a/src/main/java/net/minecraft/block/BlockDispenser.java b/src/main/java/net/minecraft/block/BlockDispenser.java index 727d403..da4532b 100644 --- a/src/main/java/net/minecraft/block/BlockDispenser.java +++ b/src/main/java/net/minecraft/block/BlockDispenser.java @@ -25,6 +25,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.tileentity.TileEntityDropper; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryDefaulted; import net.minecraft.world.World; @@ -289,6 +291,24 @@ 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/main/java/net/minecraft/block/BlockDoor.java b/src/main/java/net/minecraft/block/BlockDoor.java index ec3ce6f..274cc11 100644 --- a/src/main/java/net/minecraft/block/BlockDoor.java +++ b/src/main/java/net/minecraft/block/BlockDoor.java @@ -16,6 +16,8 @@ import net.minecraft.item.Item; 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.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -335,6 +337,24 @@ 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/main/java/net/minecraft/block/BlockEndPortalFrame.java b/src/main/java/net/minecraft/block/BlockEndPortalFrame.java index 576cfc9..6261157 100644 --- a/src/main/java/net/minecraft/block/BlockEndPortalFrame.java +++ b/src/main/java/net/minecraft/block/BlockEndPortalFrame.java @@ -14,6 +14,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -141,6 +143,24 @@ 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/main/java/net/minecraft/block/BlockEndRod.java b/src/main/java/net/minecraft/block/BlockEndRod.java index 750705a..210c56a 100644 --- a/src/main/java/net/minecraft/block/BlockEndRod.java +++ b/src/main/java/net/minecraft/block/BlockEndRod.java @@ -12,6 +12,8 @@ import net.minecraft.entity.EntityLivingBase; 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.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -26,6 +28,24 @@ 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/main/java/net/minecraft/block/BlockEnderChest.java b/src/main/java/net/minecraft/block/BlockEnderChest.java index 3b66e38..85209fe 100644 --- a/src/main/java/net/minecraft/block/BlockEnderChest.java +++ b/src/main/java/net/minecraft/block/BlockEnderChest.java @@ -19,6 +19,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityEnderChest; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -189,6 +191,24 @@ 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/main/java/net/minecraft/block/BlockFence.java b/src/main/java/net/minecraft/block/BlockFence.java index c7073c7..81ad2b1 100644 --- a/src/main/java/net/minecraft/block/BlockFence.java +++ b/src/main/java/net/minecraft/block/BlockFence.java @@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemLead; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -222,6 +224,47 @@ 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/main/java/net/minecraft/block/BlockFenceGate.java b/src/main/java/net/minecraft/block/BlockFenceGate.java index fab4f39..4cdc061 100644 --- a/src/main/java/net/minecraft/block/BlockFenceGate.java +++ b/src/main/java/net/minecraft/block/BlockFenceGate.java @@ -10,6 +10,8 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -76,6 +78,24 @@ 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() ? super.canPlaceBlockAt(world, blockpos) diff --git a/src/main/java/net/minecraft/block/BlockFurnace.java b/src/main/java/net/minecraft/block/BlockFurnace.java index 69a3758..ce2ec2b 100644 --- a/src/main/java/net/minecraft/block/BlockFurnace.java +++ b/src/main/java/net/minecraft/block/BlockFurnace.java @@ -19,6 +19,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -267,6 +269,24 @@ 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/main/java/net/minecraft/block/BlockHopper.java b/src/main/java/net/minecraft/block/BlockHopper.java index b38eddc..1047231 100644 --- a/src/main/java/net/minecraft/block/BlockHopper.java +++ b/src/main/java/net/minecraft/block/BlockHopper.java @@ -23,6 +23,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityHopper; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -259,6 +261,24 @@ 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/main/java/net/minecraft/block/BlockHugeMushroom.java b/src/main/java/net/minecraft/block/BlockHugeMushroom.java index 386cff7..9c971aa 100644 --- a/src/main/java/net/minecraft/block/BlockHugeMushroom.java +++ b/src/main/java/net/minecraft/block/BlockHugeMushroom.java @@ -12,6 +12,8 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; 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/main/java/net/minecraft/block/BlockLadder.java b/src/main/java/net/minecraft/block/BlockLadder.java index 877fd0e..3115b92 100644 --- a/src/main/java/net/minecraft/block/BlockLadder.java +++ b/src/main/java/net/minecraft/block/BlockLadder.java @@ -9,6 +9,8 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -169,6 +171,24 @@ 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/main/java/net/minecraft/block/BlockLever.java b/src/main/java/net/minecraft/block/BlockLever.java index c166dec..14e40e2 100644 --- a/src/main/java/net/minecraft/block/BlockLever.java +++ b/src/main/java/net/minecraft/block/BlockLever.java @@ -11,6 +11,8 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -269,6 +271,103 @@ 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/main/java/net/minecraft/block/BlockLog.java b/src/main/java/net/minecraft/block/BlockLog.java index b42f24c..c2349a1 100644 --- a/src/main/java/net/minecraft/block/BlockLog.java +++ b/src/main/java/net/minecraft/block/BlockLog.java @@ -7,6 +7,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; 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/main/java/net/minecraft/block/BlockPane.java b/src/main/java/net/minecraft/block/BlockPane.java index 0e969e0..05f32ed 100644 --- a/src/main/java/net/minecraft/block/BlockPane.java +++ b/src/main/java/net/minecraft/block/BlockPane.java @@ -14,6 +14,8 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -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/main/java/net/minecraft/block/BlockPistonBase.java b/src/main/java/net/minecraft/block/BlockPistonBase.java index 98a7271..f7da415 100644 --- a/src/main/java/net/minecraft/block/BlockPistonBase.java +++ b/src/main/java/net/minecraft/block/BlockPistonBase.java @@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -458,6 +460,24 @@ 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/main/java/net/minecraft/block/BlockPistonExtension.java b/src/main/java/net/minecraft/block/BlockPistonExtension.java index f72d693..48ffa4c 100644 --- a/src/main/java/net/minecraft/block/BlockPistonExtension.java +++ b/src/main/java/net/minecraft/block/BlockPistonExtension.java @@ -16,6 +16,8 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -257,6 +259,24 @@ 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/main/java/net/minecraft/block/BlockPistonMoving.java b/src/main/java/net/minecraft/block/BlockPistonMoving.java index af56d6f..5dd7dc1 100644 --- a/src/main/java/net/minecraft/block/BlockPistonMoving.java +++ b/src/main/java/net/minecraft/block/BlockPistonMoving.java @@ -14,6 +14,8 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -295,6 +297,24 @@ 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/main/java/net/minecraft/block/BlockPortal.java b/src/main/java/net/minecraft/block/BlockPortal.java index 6047e1a..1865837 100644 --- a/src/main/java/net/minecraft/block/BlockPortal.java +++ b/src/main/java/net/minecraft/block/BlockPortal.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemMonsterPlacer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -314,6 +315,33 @@ public class BlockPortal extends BlockBreakable { } } + /** + * 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; + } + } + public static class Size { private final World world; private final EnumFacing.Axis axis; diff --git a/src/main/java/net/minecraft/block/BlockPumpkin.java b/src/main/java/net/minecraft/block/BlockPumpkin.java index f029f49..2cddfcf 100644 --- a/src/main/java/net/minecraft/block/BlockPumpkin.java +++ b/src/main/java/net/minecraft/block/BlockPumpkin.java @@ -18,6 +18,8 @@ import net.minecraft.entity.monster.EntitySnowman; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -140,6 +142,24 @@ public class BlockPumpkin extends BlockDirectional { && World.doesBlockHaveSolidTopSurface(world, blockpos.down()); } + /** + * 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))); + } + /** * + * Called by ItemBlocks just before a block is actually set in diff --git a/src/main/java/net/minecraft/block/BlockQuartz.java b/src/main/java/net/minecraft/block/BlockQuartz.java index da5f0d7..0b24df4 100644 --- a/src/main/java/net/minecraft/block/BlockQuartz.java +++ b/src/main/java/net/minecraft/block/BlockQuartz.java @@ -14,6 +14,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; 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/main/java/net/minecraft/block/BlockRail.java b/src/main/java/net/minecraft/block/BlockRail.java index 375abf4..7b3cf86 100644 --- a/src/main/java/net/minecraft/block/BlockRail.java +++ b/src/main/java/net/minecraft/block/BlockRail.java @@ -4,6 +4,8 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -77,6 +79,183 @@ public class BlockRail extends BlockRailBase { return ((BlockRailBase.EnumRailDirection) iblockstate.getValue(SHAPE)).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 ((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/main/java/net/minecraft/block/BlockRailDetector.java b/src/main/java/net/minecraft/block/BlockRailDetector.java index 58c1fac..bd40445 100644 --- a/src/main/java/net/minecraft/block/BlockRailDetector.java +++ b/src/main/java/net/minecraft/block/BlockRailDetector.java @@ -17,6 +17,8 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.util.EntitySelectors; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -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/main/java/net/minecraft/block/BlockRailPowered.java b/src/main/java/net/minecraft/block/BlockRailPowered.java index 763eb2b..c6350e2 100644 --- a/src/main/java/net/minecraft/block/BlockRailPowered.java +++ b/src/main/java/net/minecraft/block/BlockRailPowered.java @@ -7,6 +7,8 @@ import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; 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/main/java/net/minecraft/block/BlockRedstoneComparator.java b/src/main/java/net/minecraft/block/BlockRedstoneComparator.java index 1e6bdd0..392aec4 100644 --- a/src/main/java/net/minecraft/block/BlockRedstoneComparator.java +++ b/src/main/java/net/minecraft/block/BlockRedstoneComparator.java @@ -22,6 +22,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityComparator; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; @@ -303,6 +305,24 @@ 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/main/java/net/minecraft/block/BlockRedstoneRepeater.java b/src/main/java/net/minecraft/block/BlockRedstoneRepeater.java index 6770a30..40b9eba 100644 --- a/src/main/java/net/minecraft/block/BlockRedstoneRepeater.java +++ b/src/main/java/net/minecraft/block/BlockRedstoneRepeater.java @@ -13,6 +13,8 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.IBlockAccess; @@ -76,6 +78,24 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode { return iblockstate.withProperty(LOCKED, Boolean.valueOf(this.isLocked(iblockaccess, blockpos, 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 onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer, EnumFacing var5, float var6, float var7, float var8) { if (!entityplayer.capabilities.allowEdit) { diff --git a/src/main/java/net/minecraft/block/BlockRedstoneWire.java b/src/main/java/net/minecraft/block/BlockRedstoneWire.java index c283e7c..8d800ea 100644 --- a/src/main/java/net/minecraft/block/BlockRedstoneWire.java +++ b/src/main/java/net/minecraft/block/BlockRedstoneWire.java @@ -21,6 +21,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -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/main/java/net/minecraft/block/BlockRotatedPillar.java b/src/main/java/net/minecraft/block/BlockRotatedPillar.java index c02d640..a37f95e 100644 --- a/src/main/java/net/minecraft/block/BlockRotatedPillar.java +++ b/src/main/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.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.block.state.IBlockState; @@ -51,6 +52,47 @@ public class BlockRotatedPillar extends Block { super(materialIn, materialIn.getMaterialMapColor()); } + /** + * 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; + } + } + + /** + * Convert the given metadata into a BlockState for this Block + */ + public IBlockState getStateFromMeta(int meta) { + EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Y; + int i = meta & 12; + + if (i == 4) { + enumfacing$axis = EnumFacing.Axis.X; + } else if (i == 8) { + enumfacing$axis = EnumFacing.Axis.Z; + } + + return this.getDefaultState().withProperty(AXIS, enumfacing$axis); + } + protected BlockRotatedPillar(Material parMaterial, MapColor parMapColor) { super(parMaterial, parMapColor); } diff --git a/src/main/java/net/minecraft/block/BlockSkull.java b/src/main/java/net/minecraft/block/BlockSkull.java index 6cd480d..5779128 100644 --- a/src/main/java/net/minecraft/block/BlockSkull.java +++ b/src/main/java/net/minecraft/block/BlockSkull.java @@ -30,6 +30,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; @@ -294,6 +296,24 @@ 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/main/java/net/minecraft/block/BlockStainedGlassPane.java b/src/main/java/net/minecraft/block/BlockStainedGlassPane.java index 7347c2e..213604d 100644 --- a/src/main/java/net/minecraft/block/BlockStainedGlassPane.java +++ b/src/main/java/net/minecraft/block/BlockStainedGlassPane.java @@ -13,6 +13,8 @@ import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -108,6 +110,47 @@ public class BlockStainedGlassPane extends BlockPane { 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/main/java/net/minecraft/block/BlockStairs.java b/src/main/java/net/minecraft/block/BlockStairs.java index 97bf45d..5973daa 100644 --- a/src/main/java/net/minecraft/block/BlockStairs.java +++ b/src/main/java/net/minecraft/block/BlockStairs.java @@ -20,6 +20,8 @@ import net.minecraft.server.MinecraftServer; 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.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -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/main/java/net/minecraft/block/BlockStandingSign.java b/src/main/java/net/minecraft/block/BlockStandingSign.java index a793d10..4dac4d7 100644 --- a/src/main/java/net/minecraft/block/BlockStandingSign.java +++ b/src/main/java/net/minecraft/block/BlockStandingSign.java @@ -4,6 +4,8 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -72,6 +74,24 @@ 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/main/java/net/minecraft/block/BlockTorch.java b/src/main/java/net/minecraft/block/BlockTorch.java index 2764f69..cce5424 100644 --- a/src/main/java/net/minecraft/block/BlockTorch.java +++ b/src/main/java/net/minecraft/block/BlockTorch.java @@ -15,6 +15,8 @@ import net.minecraft.init.Blocks; 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.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -282,6 +284,24 @@ 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/main/java/net/minecraft/block/BlockTrapDoor.java b/src/main/java/net/minecraft/block/BlockTrapDoor.java index 73b87ac..c56ecb1 100644 --- a/src/main/java/net/minecraft/block/BlockTrapDoor.java +++ b/src/main/java/net/minecraft/block/BlockTrapDoor.java @@ -14,6 +14,8 @@ import net.minecraft.init.Blocks; 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.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -278,6 +280,24 @@ 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/main/java/net/minecraft/block/BlockTripWire.java b/src/main/java/net/minecraft/block/BlockTripWire.java index 58cf596..234a833 100644 --- a/src/main/java/net/minecraft/block/BlockTripWire.java +++ b/src/main/java/net/minecraft/block/BlockTripWire.java @@ -15,6 +15,8 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -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/main/java/net/minecraft/block/BlockTripWireHook.java b/src/main/java/net/minecraft/block/BlockTripWireHook.java index 320be30..75f195e 100644 --- a/src/main/java/net/minecraft/block/BlockTripWireHook.java +++ b/src/main/java/net/minecraft/block/BlockTripWireHook.java @@ -16,6 +16,8 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -360,6 +362,24 @@ 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/main/java/net/minecraft/block/BlockVine.java b/src/main/java/net/minecraft/block/BlockVine.java index 305278b..b5de3cd 100644 --- a/src/main/java/net/minecraft/block/BlockVine.java +++ b/src/main/java/net/minecraft/block/BlockVine.java @@ -18,6 +18,8 @@ import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.ColorizerFoliage; @@ -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/main/java/net/minecraft/block/BlockWallSign.java b/src/main/java/net/minecraft/block/BlockWallSign.java index fda1433..24be29a 100644 --- a/src/main/java/net/minecraft/block/BlockWallSign.java +++ b/src/main/java/net/minecraft/block/BlockWallSign.java @@ -5,6 +5,8 @@ import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -104,6 +106,24 @@ 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/main/java/net/minecraft/block/state/BlockState.java b/src/main/java/net/minecraft/block/state/BlockState.java index 98a0e7d..1508d17 100644 --- a/src/main/java/net/minecraft/block/state/BlockState.java +++ b/src/main/java/net/minecraft/block/state/BlockState.java @@ -33,6 +33,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.MapPopulator; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Cartesian; @@ -294,6 +295,11 @@ public class BlockState implements ILightInfoProvider { return this.block.getMapColor(this); } + public IBlockState withRotation(Rotation rot) + { + return this.block.withRotation(this, rot); + } + public boolean isFullCube() { return this.block.isFullCube(); } diff --git a/src/main/java/net/minecraft/block/state/IBlockProperties.java b/src/main/java/net/minecraft/block/state/IBlockProperties.java index d68ad35..27016cf 100644 --- a/src/main/java/net/minecraft/block/state/IBlockProperties.java +++ b/src/main/java/net/minecraft/block/state/IBlockProperties.java @@ -7,6 +7,7 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -29,6 +30,8 @@ public interface IBlockProperties { MapColor getMapColor(); + IBlockState withRotation(Rotation rot); + boolean isFullCube(); int getRenderType(); diff --git a/src/main/java/net/minecraft/entity/Entity.java b/src/main/java/net/minecraft/entity/Entity.java index 2ffa715..e8e98d6 100644 --- a/src/main/java/net/minecraft/entity/Entity.java +++ b/src/main/java/net/minecraft/entity/Entity.java @@ -2166,6 +2166,10 @@ public abstract class Entity implements ICommandSender { Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ) }); } + public void setEntityInvulnerable(boolean isInvulnerable) { + this.invulnerable = isInvulnerable; + } + public boolean isEntityInvulnerable(DamageSource source) { return this.invulnerable && source != DamageSource.outOfWorld && !source.isCreativePlayer(); } @@ -2288,13 +2292,13 @@ public abstract class Entity implements ICommandSender { return Entity.this.getName(); } }); - category.addCrashSection("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", - new Object[] { Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ) })); - category.addCrashSection("Entity\'s Block location", - CrashReportCategory.getCoordinateInfo((double) MathHelper.floor_double(this.posX), - (double) MathHelper.floor_double(this.posY), (double) MathHelper.floor_double(this.posZ))); - category.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { - Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ) })); + // category.addCrashSection("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", + // new Object[] { Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ) })); + // category.addCrashSection("Entity\'s Block location", + // CrashReportCategory.getCoordinateInfo((double) MathHelper.floor_double(this.posX), + // (double) MathHelper.floor_double(this.posY), (double) MathHelper.floor_double(this.posZ))); + // category.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { + // Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ) })); category.addCrashSectionCallable("Entity\'s Rider", new Callable() { public String call() throws Exception { return Entity.this.riddenByEntity.toString(); diff --git a/src/main/java/net/minecraft/util/Mirror.java b/src/main/java/net/minecraft/util/Mirror.java new file mode 100644 index 0000000..a060af8 --- /dev/null +++ b/src/main/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/main/java/net/minecraft/util/Rotation.java b/src/main/java/net/minecraft/util/Rotation.java new file mode 100644 index 0000000..22716a0 --- /dev/null +++ b/src/main/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; + } + } +} diff --git a/src/main/java/net/minecraft/world/WorldProviderEnd.java b/src/main/java/net/minecraft/world/WorldProviderEnd.java index 1cb4a2e..bb8cc9e 100644 --- a/src/main/java/net/minecraft/world/WorldProviderEnd.java +++ b/src/main/java/net/minecraft/world/WorldProviderEnd.java @@ -54,7 +54,7 @@ public class WorldProviderEnd extends WorldProvider { * world */ public IChunkProvider createChunkGenerator() { - return new ChunkProviderEnd(this.worldObj, this.worldObj.getSeed()); + return new ChunkProviderEnd(this.worldObj, this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.worldObj.getSeed()); } /** diff --git a/src/main/java/net/minecraft/world/biome/BiomeDecorator.java b/src/main/java/net/minecraft/world/biome/BiomeDecorator.java index 2a70fb1..4536782 100644 --- a/src/main/java/net/minecraft/world/biome/BiomeDecorator.java +++ b/src/main/java/net/minecraft/world/biome/BiomeDecorator.java @@ -195,13 +195,13 @@ public class BiomeDecorator { this.chunkProviderSettings.diamondSize); this.lapisGen = new WorldGenMinable(Blocks.lapis_ore.getDefaultState(), this.chunkProviderSettings.lapisSize); - this.genDecorations(parBiomeGenBase); + this.genDecorations(parBiomeGenBase, worldIn, random); this.currentWorld = null; this.randomGenerator = null; } } - protected void genDecorations(BiomeGenBase biomeGenBaseIn) { + protected void genDecorations(BiomeGenBase biomeGenBaseIn, World worldIn, EaglercraftRandom random) { this.generateOres(); for (int i = 0; i < this.sandPerChunk2; ++i) { diff --git a/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java b/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java index 4524dbe..6d4ad2e 100644 --- a/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java +++ b/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java @@ -1,9 +1,20 @@ package net.minecraft.world.biome; -import net.minecraft.entity.boss.EntityDragon; -import net.minecraft.init.Blocks; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import com.google.common.collect.ContiguousSet; +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.Lists; +import com.google.common.collect.Range; + +import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenSpikes; -import net.minecraft.world.gen.feature.WorldGenerator; /** * + @@ -36,22 +47,52 @@ import net.minecraft.world.gen.feature.WorldGenerator; */ public class BiomeEndDecorator extends BiomeDecorator { - protected WorldGenerator spikeGen = new WorldGenSpikes(Blocks.end_stone); + private static final Map SPIKE_CACHE = new HashMap<>(); + private final WorldGenSpikes spikeGen = new WorldGenSpikes(); - protected void genDecorations(BiomeGenBase var1) { + protected void genDecorations(BiomeGenBase var1, World var2, EaglercraftRandom var3) { this.generateOres(); - if (this.randomGenerator.nextInt(5) == 0) { - int i = this.randomGenerator.nextInt(16) + 8; - int j = this.randomGenerator.nextInt(16) + 8; - this.spikeGen.generate(this.currentWorld, this.randomGenerator, - this.currentWorld.getTopSolidOrLiquidBlock(this.field_180294_c.add(i, 0, j))); - } - - if (this.field_180294_c.getX() == 0 && this.field_180294_c.getZ() == 0) { - EntityDragon entitydragon = new EntityDragon(this.currentWorld); - entitydragon.setLocationAndAngles(0.0D, 128.0D, 0.0D, this.randomGenerator.nextFloat() * 360.0F, 0.0F); - this.currentWorld.spawnEntityInWorld(entitydragon); - } + WorldGenSpikes.EndSpike[] aworldgenspikes$endspike = getSpikesForWorld(var2); + for (WorldGenSpikes.EndSpike worldgenspikes$endspike : aworldgenspikes$endspike) + { + if (worldgenspikes$endspike.doesStartInChunk(this.field_180294_c)) + { + this.spikeGen.setSpike(worldgenspikes$endspike); + this.spikeGen.generate(var2, var3, new BlockPos(worldgenspikes$endspike.getCenterX(), 45, worldgenspikes$endspike.getCenterZ())); + } + } } + + public static WorldGenSpikes.EndSpike[] getSpikesForWorld(World world) + { + Random random = new Random(world.getSeed()); + long key = random.nextLong() & 65535L; + + if (!SPIKE_CACHE.containsKey(key)) { + SPIKE_CACHE.put(key, generateSpikes(key)); + } + + return SPIKE_CACHE.get(key); + } + + private static WorldGenSpikes.EndSpike[] generateSpikes(long seed) + { + List list = Lists.newArrayList(ContiguousSet.create(Range.closedOpen(0, 10), DiscreteDomain.integers())); + Collections.shuffle(list, new Random(seed)); + WorldGenSpikes.EndSpike[] spikes = new WorldGenSpikes.EndSpike[10]; + + for (int i = 0; i < 10; ++i) + { + int j = (int)(42.0D * Math.cos(2.0D * (-Math.PI + (Math.PI / 10D) * i))); + int k = (int)(42.0D * Math.sin(2.0D * (-Math.PI + (Math.PI / 10D) * i))); + int l = list.get(i); + int i1 = 2 + l / 3; + int j1 = 76 + l * 3; + boolean flag = l == 1 || l == 2; + spikes[i] = new WorldGenSpikes.EndSpike(j, k, i1, j1, flag); + } + + return spikes; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java b/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java index c596c3d..18135ef 100644 --- a/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java +++ b/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java @@ -1,7 +1,9 @@ package net.minecraft.world.gen; import java.util.List; + import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +import net.minecraft.block.BlockChorusFlower; import net.minecraft.block.BlockFalling; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -10,11 +12,13 @@ import net.minecraft.init.Blocks; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenEndIsland; /** * + @@ -46,125 +50,160 @@ import net.minecraft.world.chunk.IChunkProvider; * */ public class ChunkProviderEnd implements IChunkProvider { - private EaglercraftRandom endRNG; - private NoiseGeneratorOctaves noiseGen1; - private NoiseGeneratorOctaves noiseGen2; - private NoiseGeneratorOctaves noiseGen3; - public NoiseGeneratorOctaves noiseGen4; - public NoiseGeneratorOctaves noiseGen5; + private EaglercraftRandom rand; + protected static final IBlockState END_STONE = Blocks.end_stone.getDefaultState(); + protected static final IBlockState AIR = Blocks.air.getDefaultState(); + private final NoiseGeneratorOctaves lperlinNoise1; + private final NoiseGeneratorOctaves lperlinNoise2; + private final NoiseGeneratorOctaves perlinNoise1; + + /** A NoiseGeneratorOctaves used in generating terrain */ + public NoiseGeneratorOctaves noiseGen5; + + /** A NoiseGeneratorOctaves used in generating terrain */ + public NoiseGeneratorOctaves noiseGen6; + private World endWorld; - private double[] densities; + + /** are map structures going to be generated (e.g. strongholds) */ + private final boolean mapFeaturesEnabled; + private final NoiseGeneratorSimplex islandNoise; + private double[] buffer; + private BiomeGenBase[] biomesForGeneration; - double[] noiseData1; - double[] noiseData2; - double[] noiseData3; - double[] noiseData4; - double[] noiseData5; + double[] pnr; + double[] ar; + double[] br; + private final WorldGenEndIsland endIslands = new WorldGenEndIsland(); - public ChunkProviderEnd(World worldIn, long parLong1) { - this.endWorld = worldIn; - this.endRNG = new EaglercraftRandom(parLong1, !worldIn.getWorldInfo().isOldEaglercraftRandom()); - this.noiseGen1 = new NoiseGeneratorOctaves(this.endRNG, 16); - this.noiseGen2 = new NoiseGeneratorOctaves(this.endRNG, 16); - this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8); - this.noiseGen4 = new NoiseGeneratorOctaves(this.endRNG, 10); - this.noiseGen5 = new NoiseGeneratorOctaves(this.endRNG, 16); + + public ChunkProviderEnd(World worldObjIn, boolean mapFeaturesEnabledIn, long seed) { + this.endWorld = worldObjIn; + this.mapFeaturesEnabled = mapFeaturesEnabledIn; + this.rand = new EaglercraftRandom(seed); + this.lperlinNoise1 = new NoiseGeneratorOctaves(this.rand, 16); + this.lperlinNoise2 = new NoiseGeneratorOctaves(this.rand, 16); + this.perlinNoise1 = new NoiseGeneratorOctaves(this.rand, 8); + this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); + this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); + this.islandNoise = new NoiseGeneratorSimplex(this.rand); } - public void func_180520_a(int parInt1, int parInt2, ChunkPrimer parChunkPrimer) { - byte b0 = 2; - int i = b0 + 1; - byte b1 = 33; - int j = b0 + 1; - this.densities = this.initializeNoiseField(this.densities, parInt1 * b0, 0, parInt2 * b0, i, b1, j); + public void func_180520_a(int x, int z, ChunkPrimer primer) { + int i = 2; + int j = i + 1; + int k = 33; + int l = i + 1; + this.buffer = this.initializeNoiseField(this.buffer, x * i, 0, z * i, j, k, l); - for (int k = 0; k < b0; ++k) { - for (int l = 0; l < b0; ++l) { - for (int i1 = 0; i1 < 32; ++i1) { - double d0 = 0.25D; - double d1 = this.densities[((k + 0) * j + l + 0) * b1 + i1 + 0]; - double d2 = this.densities[((k + 0) * j + l + 1) * b1 + i1 + 0]; - double d3 = this.densities[((k + 1) * j + l + 0) * b1 + i1 + 0]; - double d4 = this.densities[((k + 1) * j + l + 1) * b1 + i1 + 0]; - double d5 = (this.densities[((k + 0) * j + l + 0) * b1 + i1 + 1] - d1) * d0; - double d6 = (this.densities[((k + 0) * j + l + 1) * b1 + i1 + 1] - d2) * d0; - double d7 = (this.densities[((k + 1) * j + l + 0) * b1 + i1 + 1] - d3) * d0; - double d8 = (this.densities[((k + 1) * j + l + 1) * b1 + i1 + 1] - d4) * d0; + for (int i1 = 0; i1 < i; ++i1) + { + for (int j1 = 0; j1 < i; ++j1) + { + for (int k1 = 0; k1 < 32; ++k1) + { + double d0 = 0.25D; + double d1 = this.buffer[((i1 + 0) * l + j1 + 0) * k + k1 + 0]; + double d2 = this.buffer[((i1 + 0) * l + j1 + 1) * k + k1 + 0]; + double d3 = this.buffer[((i1 + 1) * l + j1 + 0) * k + k1 + 0]; + double d4 = this.buffer[((i1 + 1) * l + j1 + 1) * k + k1 + 0]; + double d5 = (this.buffer[((i1 + 0) * l + j1 + 0) * k + k1 + 1] - d1) * d0; + double d6 = (this.buffer[((i1 + 0) * l + j1 + 1) * k + k1 + 1] - d2) * d0; + double d7 = (this.buffer[((i1 + 1) * l + j1 + 0) * k + k1 + 1] - d3) * d0; + double d8 = (this.buffer[((i1 + 1) * l + j1 + 1) * k + k1 + 1] - d4) * d0; - for (int j1 = 0; j1 < 4; ++j1) { - double d9 = 0.125D; - double d10 = d1; - double d11 = d2; - double d12 = (d3 - d1) * d9; - double d13 = (d4 - d2) * d9; + for (int l1 = 0; l1 < 4; ++l1) + { + double d9 = 0.125D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; - for (int k1 = 0; k1 < 8; ++k1) { - double d14 = 0.125D; - double d15 = d10; - double d16 = (d11 - d10) * d14; + for (int i2 = 0; i2 < 8; ++i2) + { + double d14 = 0.125D; + double d15 = d10; + double d16 = (d11 - d10) * d14; - for (int l1 = 0; l1 < 8; ++l1) { - IBlockState iblockstate = null; - if (d15 > 0.0D) { - iblockstate = Blocks.end_stone.getDefaultState(); - } + for (int j2 = 0; j2 < 8; ++j2) + { + IBlockState iblockstate = AIR; - int i2 = k1 + k * 8; - int j2 = j1 + i1 * 4; - int k2 = l1 + l * 8; - parChunkPrimer.setBlockState(i2, j2, k2, iblockstate); - d15 += d16; - } + if (d15 > 0.0D) + { + iblockstate = END_STONE; + } - d10 += d12; - d11 += d13; - } + int k2 = i2 + i1 * 8; + int l2 = l1 + k1 * 4; + int i3 = j2 + j1 * 8; + primer.setBlockState(k2, l2, i3, iblockstate); + d15 += d16; + } - d1 += d5; - d2 += d6; - d3 += d7; - d4 += d8; - } - } - } - } + d10 += d12; + d11 += d13; + } + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } } - public void func_180519_a(ChunkPrimer parChunkPrimer) { - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - byte b0 = 1; - int k = -1; - IBlockState iblockstate = Blocks.end_stone.getDefaultState(); - IBlockState iblockstate1 = Blocks.end_stone.getDefaultState(); + public void func_180519_a(ChunkPrimer primer) { + for (int i = 0; i < 16; ++i) + { + for (int j = 0; j < 16; ++j) + { + int k = 1; + int l = -1; + IBlockState iblockstate = END_STONE; + IBlockState iblockstate1 = END_STONE; - for (int l = 127; l >= 0; --l) { - IBlockState iblockstate2 = parChunkPrimer.getBlockState(i, l, j); - if (iblockstate2.getBlock().getMaterial() == Material.air) { - k = -1; - } else if (iblockstate2.getBlock() == Blocks.stone) { - if (k == -1) { - if (b0 <= 0) { - iblockstate = Blocks.air.getDefaultState(); - iblockstate1 = Blocks.end_stone.getDefaultState(); - } + for (int i1 = 127; i1 >= 0; --i1) + { + IBlockState iblockstate2 = primer.getBlockState(i, i1, j); - k = b0; - if (l >= 0) { - parChunkPrimer.setBlockState(i, l, j, iblockstate); - } else { - parChunkPrimer.setBlockState(i, l, j, iblockstate1); - } - } else if (k > 0) { - --k; - parChunkPrimer.setBlockState(i, l, j, iblockstate1); - } - } - } - } - } + if (iblockstate2.getMaterial() == Material.air) + { + l = -1; + } + else if (iblockstate2.getBlock() == Blocks.stone) + { + if (l == -1) + { + if (k <= 0) + { + iblockstate = AIR; + iblockstate1 = END_STONE; + } + l = k; + + if (i1 >= 0) + { + primer.setBlockState(i, i1, j, iblockstate); + } + else + { + primer.setBlockState(i, i1, j, iblockstate1); + } + } + else if (l > 0) + { + --l; + primer.setBlockState(i, i1, j, iblockstate1); + } + } + } + } + } } /** @@ -173,103 +212,164 @@ public class ChunkProviderEnd implements IChunkProvider { * MP client it will generates all the blocks for the specified * chunk from the map seed and chunk seed */ - public Chunk provideChunk(int i, int j) { - this.endRNG.setSeed((long) i * 341873128712L + (long) j * 132897987541L); - ChunkPrimer chunkprimer = new ChunkPrimer(); - this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, - i * 16, j * 16, 16, 16); - this.func_180520_a(i, j, chunkprimer); - this.func_180519_a(chunkprimer); - Chunk chunk = new Chunk(this.endWorld, chunkprimer, i, j); - byte[] abyte = chunk.getBiomeArray(); + public Chunk provideChunk(int x, int z) { + this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L); + ChunkPrimer chunkprimer = new ChunkPrimer(); + this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16); + this.func_180520_a(x, z, chunkprimer); + this.func_180519_a(chunkprimer); - for (int k = 0; k < abyte.length; ++k) { - abyte[k] = (byte) this.biomesForGeneration[k].biomeID; - } + // if (this.mapFeaturesEnabled) + // { + // this.endCityGen.generate(this.worldObj, x, z, chunkprimer); + // } - chunk.generateSkylightMap(); - return chunk; + Chunk chunk = new Chunk(this.endWorld, chunkprimer, x, z); + byte[] abyte = chunk.getBiomeArray(); + + for (int i = 0; i < abyte.length; ++i) + { + abyte[i] = (byte) this.biomesForGeneration[i].biomeID; + } + + chunk.generateSkylightMap(); + return chunk; } public Chunk getLoadedChunk(int parInt1, int parInt2) { return this.provideChunk(parInt1, parInt2); } + private float getIslandHeightValue(int p_185960_1_, int p_185960_2_, int p_185960_3_, int p_185960_4_) + { + float f = (float)(p_185960_1_ * 2 + p_185960_3_); + float f1 = (float)(p_185960_2_ * 2 + p_185960_4_); + float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F; + + if (f2 > 80.0F) + { + f2 = 80.0F; + } + + if (f2 < -100.0F) + { + f2 = -100.0F; + } + + for (int i = -12; i <= 12; ++i) + { + for (int j = -12; j <= 12; ++j) + { + long k = (long)(p_185960_1_ + i); + long l = (long)(p_185960_2_ + j); + + if (k * k + l * l > 4096L && this.islandNoise.func_151605_a((double)k, (double)l) < -0.8999999761581421D) + { + float f3 = (MathHelper.abs((float)k) * 3439.0F + MathHelper.abs((float)l) * 147.0F) % 13.0F + 9.0F; + f = (float)(p_185960_3_ - i * 2); + f1 = (float)(p_185960_4_ - j * 2); + float f4 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * f3; + + if (f4 > 80.0F) + { + f4 = 80.0F; + } + + if (f4 < -100.0F) + { + f4 = -100.0F; + } + + if (f4 > f2) + { + f2 = f4; + } + } + } + } + + return f2; + } + + public boolean isIslandChunk(int p_185961_1_, int p_185961_2_) + { + return (long)p_185961_1_ * (long)p_185961_1_ + (long)p_185961_2_ * (long)p_185961_2_ > 4096L && this.getIslandHeightValue(p_185961_1_, p_185961_2_, 1, 1) >= 0.0F; + } + /** * + * generates a subset of the level's terrain data. Takes 7 * arguments: the [empty] noise array, the position, and the * size. */ - private double[] initializeNoiseField(double[] parArrayOfDouble, int parInt1, int parInt2, int parInt3, int parInt4, - int parInt5, int parInt6) { - if (parArrayOfDouble == null) { - parArrayOfDouble = new double[parInt4 * parInt5 * parInt6]; + private double[] initializeNoiseField(double[] p_185963_1_, int p_185963_2_, int p_185963_3_, int p_185963_4_, int p_185963_5_, int p_185963_6_, int p_185963_7_) { + if (p_185963_1_ == null) + { + p_185963_1_ = new double[p_185963_5_ * p_185963_6_ * p_185963_7_]; } double d0 = 684.412D; double d1 = 684.412D; - this.noiseData4 = this.noiseGen4.generateNoiseOctaves(this.noiseData4, parInt1, parInt3, parInt4, parInt6, - 1.121D, 1.121D, 0.5D); - this.noiseData5 = this.noiseGen5.generateNoiseOctaves(this.noiseData5, parInt1, parInt3, parInt4, parInt6, - 200.0D, 200.0D, 0.5D); d0 = d0 * 2.0D; - this.noiseData1 = this.noiseGen3.generateNoiseOctaves(this.noiseData1, parInt1, parInt2, parInt3, parInt4, - parInt5, parInt6, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D); - this.noiseData2 = this.noiseGen1.generateNoiseOctaves(this.noiseData2, parInt1, parInt2, parInt3, parInt4, - parInt5, parInt6, d0, d1, d0); - this.noiseData3 = this.noiseGen2.generateNoiseOctaves(this.noiseData3, parInt1, parInt2, parInt3, parInt4, - parInt5, parInt6, d0, d1, d0); - int i = 0; + this.pnr = this.perlinNoise1.generateNoiseOctaves(this.pnr, p_185963_2_, p_185963_3_, p_185963_4_, p_185963_5_, p_185963_6_, p_185963_7_, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D); + this.ar = this.lperlinNoise1.generateNoiseOctaves(this.ar, p_185963_2_, p_185963_3_, p_185963_4_, p_185963_5_, p_185963_6_, p_185963_7_, d0, d1, d0); + this.br = this.lperlinNoise2.generateNoiseOctaves(this.br, p_185963_2_, p_185963_3_, p_185963_4_, p_185963_5_, p_185963_6_, p_185963_7_, d0, d1, d0); + int i = p_185963_2_ / 2; + int j = p_185963_4_ / 2; + int k = 0; - for (int j = 0; j < parInt4; ++j) { - for (int k = 0; k < parInt6; ++k) { - float f = (float) (j + parInt1) / 1.0F; - float f1 = (float) (k + parInt3) / 1.0F; - float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F; - if (f2 > 80.0F) { - f2 = 80.0F; - } + for (int l = 0; l < p_185963_5_; ++l) + { + for (int i1 = 0; i1 < p_185963_7_; ++i1) + { + float f = this.getIslandHeightValue(i, j, l, i1); - if (f2 < -100.0F) { - f2 = -100.0F; - } - - for (int l = 0; l < parInt5; ++l) { + for (int j1 = 0; j1 < p_185963_6_; ++j1) + { double d2 = 0.0D; - double d3 = this.noiseData2[i] / 512.0D; - double d4 = this.noiseData3[i] / 512.0D; - double d5 = (this.noiseData1[i] / 10.0D + 1.0D) / 2.0D; - if (d5 < 0.0D) { + double d3 = this.ar[k] / 512.0D; + double d4 = this.br[k] / 512.0D; + double d5 = (this.pnr[k] / 10.0D + 1.0D) / 2.0D; + + if (d5 < 0.0D) + { d2 = d3; - } else if (d5 > 1.0D) { + } + else if (d5 > 1.0D) + { d2 = d4; - } else { + } + else + { d2 = d3 + (d4 - d3) * d5; } d2 = d2 - 8.0D; - d2 = d2 + (double) f2; - byte b0 = 2; - if (l > parInt5 / 2 - b0) { - double d6 = (double) ((float) (l - (parInt5 / 2 - b0)) / 64.0F); + d2 = d2 + (double)f; + int k1 = 2; + + if (j1 > p_185963_6_ / 2 - k1) + { + double d6 = (double)((float)(j1 - (p_185963_6_ / 2 - k1)) / 64.0F); d6 = MathHelper.clamp_double(d6, 0.0D, 1.0D); d2 = d2 * (1.0D - d6) + -3000.0D * d6; } - b0 = 8; - if (l < b0) { - double d7 = (double) ((float) (b0 - l) / ((float) b0 - 1.0F)); + k1 = 8; + + if (j1 < k1) + { + double d7 = (double)((float)(k1 - j1) / ((float)k1 - 1.0F)); d2 = d2 * (1.0D - d7) + -30.0D * d7; } - parArrayOfDouble[i] = d2; - ++i; + p_185963_1_[k] = d2; + ++k; } } } - return parArrayOfDouble; + return p_185963_1_; } /** @@ -284,12 +384,56 @@ public class ChunkProviderEnd implements IChunkProvider { * + * Populates chunk with ores etc etc */ - public void populate(IChunkProvider var1, int i, int j) { + public void populate(IChunkProvider var1, int x, int z) { BlockFalling.fallInstantly = true; - BlockPos blockpos = new BlockPos(i * 16, 0, j * 16); - this.endWorld.getBiomeGenForCoords(blockpos.add(16, 0, 16)).decorate(this.endWorld, this.endWorld.rand, - blockpos); - BlockFalling.fallInstantly = false; + BlockPos blockpos = new BlockPos(x * 16, 0, z * 16); + + // if (this.mapFeaturesEnabled) + // { + // this.endCityGen.generateStructure(this.endWorld, this.rand, new ChunkCoordIntPair(x, z)); + // } + + this.endWorld.getBiomeGenForCoords(blockpos.add(16, 0, 16)).decorate(this.endWorld, this.endWorld.rand, blockpos); + long i = (long)x * (long)x + (long)z * (long)z; + + if (i > 4096L) + { + float f = this.getIslandHeightValue(x, z, 1, 1); + + if (f < -20.0F && this.rand.nextInt(14) == 0) + { + this.endIslands.generate(this.endWorld, this.rand, blockpos.add(this.rand.nextInt(16) + 8, 55 + this.rand.nextInt(16), this.rand.nextInt(16) + 8)); + + if (this.rand.nextInt(4) == 0) + { + this.endIslands.generate(this.endWorld, this.rand, blockpos.add(this.rand.nextInt(16) + 8, 55 + this.rand.nextInt(16), this.rand.nextInt(16) + 8)); + } + } + + if (this.getIslandHeightValue(x, z, 1, 1) > 40.0F) + { + int j = this.rand.nextInt(5); + + for (int k = 0; k < j; ++k) + { + int l = this.rand.nextInt(16) + 8; + int i1 = this.rand.nextInt(16) + 8; + int j1 = this.endWorld.getHeight(blockpos.add(l, 0, i1)).getY(); + + if (j1 > 0) + { + int k1 = j1 - 1; + + if (this.endWorld.isAirBlock(blockpos.add(l, k1 + 1, i1)) && this.endWorld.getBlockState(blockpos.add(l, k1, i1)).getBlock() == Blocks.end_stone) + { + BlockChorusFlower.generatePlant(this.endWorld, blockpos.add(l, k1 + 1, i1), this.rand, 8); + } + } + } + } + } + + BlockFalling.fallInstantly = false; } public boolean func_177460_a(IChunkProvider var1, Chunk var2, int var3, int var4) { diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenEndIsland.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenEndIsland.java new file mode 100644 index 0000000..91a82fc --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenEndIsland.java @@ -0,0 +1,33 @@ +package net.minecraft.world.gen.feature; + +import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; + +public class WorldGenEndIsland extends WorldGenerator +{ + public boolean generate(World worldIn, EaglercraftRandom rand, BlockPos position) + { + float f = (float)(rand.nextInt(3) + 4); + + for (int i = 0; f > 0.5F; --i) + { + for (int j = MathHelper.floor_float(-f); j <= MathHelper.ceiling_float_int(f); ++j) + { + for (int k = MathHelper.floor_float(-f); k <= MathHelper.ceiling_float_int(f); ++k) + { + if ((float)(j * j + k * k) <= (f + 1.0F) * (f + 1.0F)) + { + this.setBlockAndNotifyAdequately(worldIn, position.add(j, i, k), Blocks.end_stone.getDefaultState()); + } + } + } + + f = (float)((double)f - ((double)rand.nextInt(2) + 0.5D)); + } + + return true; + } +} diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java index 2892143..3b7d632 100644 --- a/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java @@ -1,10 +1,13 @@ package net.minecraft.world.gen.feature; +import javax.annotation.Nullable; + import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; -import net.minecraft.block.Block; import net.minecraft.entity.item.EntityEnderCrystal; import net.minecraft.init.Blocks; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; /** @@ -37,51 +40,129 @@ import net.minecraft.world.World; * */ public class WorldGenSpikes extends WorldGenerator { - private Block baseBlockRequired; + private boolean crystalInvulnerable = false; + private WorldGenSpikes.EndSpike spike = null; + private BlockPos beamTarget; - public WorldGenSpikes(Block parBlock) { - this.baseBlockRequired = parBlock; - } + public void setSpike(WorldGenSpikes.EndSpike p_186143_1_) + { + this.spike = p_186143_1_; + } - public boolean generate(World world, EaglercraftRandom random, BlockPos blockpos) { - if (world.isAirBlock(blockpos) && world.getBlockState(blockpos.down()).getBlock() == this.baseBlockRequired) { - int i = random.nextInt(32) + 6; - int j = random.nextInt(4) + 1; - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + public void setCrystalInvulnerable(boolean p_186144_1_) + { + this.crystalInvulnerable = p_186144_1_; + } - for (int k = blockpos.getX() - j; k <= blockpos.getX() + j; ++k) { - for (int l = blockpos.getZ() - j; l <= blockpos.getZ() + j; ++l) { - int i1 = k - blockpos.getX(); - int j1 = l - blockpos.getZ(); - if (i1 * i1 + j1 * j1 <= j * j + 1 - && world.getBlockState(blockpos$mutableblockpos.func_181079_c(k, blockpos.getY() - 1, l)) - .getBlock() != this.baseBlockRequired) { - return false; - } - } - } + public boolean generate(World worldIn, EaglercraftRandom rand, BlockPos position) + { + if (this.spike == null) + { + throw new IllegalStateException("Decoration requires priming with a spike"); + } + else + { + int i = this.spike.getRadius(); - for (int l1 = blockpos.getY(); l1 < blockpos.getY() + i && l1 < 256; ++l1) { - for (int i2 = blockpos.getX() - j; i2 <= blockpos.getX() + j; ++i2) { - for (int j2 = blockpos.getZ() - j; j2 <= blockpos.getZ() + j; ++j2) { - int k2 = i2 - blockpos.getX(); - int k1 = j2 - blockpos.getZ(); - if (k2 * k2 + k1 * k1 <= j * j + 1) { - world.setBlockState(new BlockPos(i2, l1, j2), Blocks.obsidian.getDefaultState(), 2); - } - } - } - } + for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(new BlockPos(position.getX() - i, 0, position.getZ() - i), new BlockPos(position.getX() + i, this.spike.getHeight() + 10, position.getZ() + i))) + { + if (blockpos$mutableblockpos.distanceSq((double)position.getX(), (double)blockpos$mutableblockpos.getY(), (double)position.getZ()) <= (double)(i * i + 1) && blockpos$mutableblockpos.getY() < this.spike.getHeight()) + { + this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.obsidian.getDefaultState()); + } + else if (blockpos$mutableblockpos.getY() > 65) + { + this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.air.getDefaultState()); + } + } - EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world); - entityendercrystal.setLocationAndAngles((double) ((float) blockpos.getX() + 0.5F), - (double) (blockpos.getY() + i), (double) ((float) blockpos.getZ() + 0.5F), - random.nextFloat() * 360.0F, 0.0F); - world.spawnEntityInWorld(entityendercrystal); - world.setBlockState(blockpos.up(i), Blocks.bedrock.getDefaultState(), 2); - return true; - } else { - return false; - } - } + if (this.spike.isGuarded()) + { + for (int j = -2; j <= 2; ++j) + { + for (int k = -2; k <= 2; ++k) + { + if (MathHelper.abs_int(j) == 2 || MathHelper.abs_int(k) == 2) + { + this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight(), position.getZ() + k), Blocks.iron_bars.getDefaultState()); + this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight() + 1, position.getZ() + k), Blocks.iron_bars.getDefaultState()); + this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight() + 2, position.getZ() + k), Blocks.iron_bars.getDefaultState()); + } + + this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight() + 3, position.getZ() + k), Blocks.iron_bars.getDefaultState()); + } + } + } + + EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(worldIn); + entityendercrystal.setBeamTarget(this.beamTarget); + entityendercrystal.setEntityInvulnerable(this.crystalInvulnerable); + entityendercrystal.setLocationAndAngles((double)((float)position.getX() + 0.5F), (double)(this.spike.getHeight() + 1), (double)((float)position.getZ() + 0.5F), rand.nextFloat() * 360.0F, 0.0F); + worldIn.spawnEntityInWorld(entityendercrystal); + this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX(), this.spike.getHeight(), position.getZ()), Blocks.bedrock.getDefaultState()); + return true; + } + } + + public void setBeamTarget(@Nullable BlockPos pos) + { + this.beamTarget = pos; + } + + public static class EndSpike + { + private final int centerX; + private final int centerZ; + private final int radius; + private final int height; + private final boolean guarded; + private final AxisAlignedBB topBoundingBox; + + public EndSpike(int p_i47020_1_, int p_i47020_2_, int p_i47020_3_, int p_i47020_4_, boolean p_i47020_5_) + { + this.centerX = p_i47020_1_; + this.centerZ = p_i47020_2_; + this.radius = p_i47020_3_; + this.height = p_i47020_4_; + this.guarded = p_i47020_5_; + this.topBoundingBox = new AxisAlignedBB((double)(p_i47020_1_ - p_i47020_3_), 0.0D, (double)(p_i47020_2_ - p_i47020_3_), (double)(p_i47020_1_ + p_i47020_3_), 256.0D, (double)(p_i47020_2_ + p_i47020_3_)); + } + + public boolean doesStartInChunk(BlockPos p_186154_1_) + { + int i = this.centerX - this.radius; + int j = this.centerZ - this.radius; + return p_186154_1_.getX() == (i & -16) && p_186154_1_.getZ() == (j & -16); + } + + public int getCenterX() + { + return this.centerX; + } + + public int getCenterZ() + { + return this.centerZ; + } + + public int getRadius() + { + return this.radius; + } + + public int getHeight() + { + return this.height; + } + + public boolean isGuarded() + { + return this.guarded; + } + + public AxisAlignedBB getTopBoundingBox() + { + return this.topBoundingBox; + } + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureEndCityPieces.java b/src/main/java/net/minecraft/world/gen/structure/StructureEndCityPieces.java new file mode 100644 index 0000000..12c7fb5 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureEndCityPieces.java @@ -0,0 +1,5 @@ +package net.minecraft.world.gen.structure; + +public class StructureEndCityPieces { + +}