Add mirror and rotation.

This commit is contained in:
HoosierTransfer 2024-07-29 10:38:31 -04:00
parent b568c8aadb
commit 02de227668
58 changed files with 2638 additions and 235 deletions

View File

@ -31,8 +31,10 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.Mirror;
import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.ObjectIntIdentityMap;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -282,6 +284,28 @@ public class Block implements ILitBlock {
return iblockstate; 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) { public Block(Material parMaterial, MapColor parMapColor) {
this.enableStats = true; this.enableStats = true;
this.stepSound = soundTypeStone; this.stepSound = soundTypeStone;

View File

@ -19,6 +19,7 @@ import net.minecraft.inventory.ContainerRepair;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
@ -173,6 +174,16 @@ public class BlockAnvil extends BlockFalling {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, DAMAGE }); return new BlockState(this, new IProperty[] { FACING, DAMAGE });
} }

View File

@ -16,6 +16,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.tileentity.TileEntityBanner;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.translation.I18n; 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)); 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) { public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, BlockPos blockpos) {
EnumFacing enumfacing = (EnumFacing) iblockaccess.getBlockState(blockpos).getValue(FACING); EnumFacing enumfacing = (EnumFacing) iblockaccess.getBlockState(blockpos).getValue(FACING);
float f = 0.0F; float f = 0.0F;
@ -226,6 +238,16 @@ public class BlockBanner extends BlockContainer {
this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, Integer.valueOf(0))); 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) { public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
if (!worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid()) { if (!worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid()) {
this.dropBlockAsItem(worldIn, pos, state, 0); this.dropBlockAsItem(worldIn, pos, state, 0);

View File

@ -18,6 +18,8 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable; 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.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -302,6 +304,24 @@ public class BlockBed extends BlockDirectional {
} }
/** /**
* 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 * Convert the BlockState into the correct metadata value
*/ */

View File

@ -14,6 +14,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -373,6 +375,24 @@ public abstract class BlockButton extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, POWERED }); return new BlockState(this, new IProperty[] { FACING, POWERED });
} }

View File

@ -21,6 +21,8 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -519,6 +521,24 @@ public class BlockChest extends BlockContainer {
return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING }); return new BlockState(this, new IProperty[] { FACING });
} }

View File

@ -270,7 +270,7 @@ public class BlockChorusFlower extends Block {
if (!flag) { if (!flag) {
worldIn.setBlockState(p_185601_1_.up(i), 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); 2);
} }
} }

View File

@ -15,6 +15,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; 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 * Called by ItemBlocks after a block is set in the world, to

View File

@ -19,6 +19,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -271,6 +273,24 @@ public class BlockCommandBlock extends BlockContainer {
| (((Boolean) state.getValue(CONDITIONAL)).booleanValue() ? 8 : 0); | (((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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, CONDITIONAL }); return new BlockState(this, new IProperty[] { FACING, CONDITIONAL });
} }

View File

@ -25,6 +25,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.tileentity.TileEntityDispenser;
import net.minecraft.tileentity.TileEntityDropper; import net.minecraft.tileentity.TileEntityDropper;
import net.minecraft.util.EnumFacing; 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.math.BlockPos;
import net.minecraft.util.registry.RegistryDefaulted; import net.minecraft.util.registry.RegistryDefaulted;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -289,6 +291,24 @@ public class BlockDispenser extends BlockContainer {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, TRIGGERED }); return new BlockState(this, new IProperty[] { FACING, TRIGGERED });
} }

View File

@ -16,6 +16,8 @@ import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -335,6 +337,24 @@ public class BlockDoor extends Block {
return iblockstate; 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 * Convert the given metadata into a BlockState for this Block

View File

@ -14,6 +14,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -141,6 +143,24 @@ public class BlockEndPortalFrame extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, EYE }); return new BlockState(this, new IProperty[] { FACING, EYE });
} }

View File

@ -12,6 +12,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -26,6 +28,24 @@ public class BlockEndRod extends Block {
this.setCreativeTab(CreativeTabs.tabDecorations); 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) { public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos blockpos, IBlockState iblockstate) {
this.setBlockBoundsBasedOnState(world, blockpos); this.setBlockBoundsBasedOnState(world, blockpos);
return super.getCollisionBoundingBox(world, blockpos, iblockstate); return super.getCollisionBoundingBox(world, blockpos, iblockstate);

View File

@ -19,6 +19,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEnderChest; import net.minecraft.tileentity.TileEntityEnderChest;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; 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.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -189,6 +191,24 @@ public class BlockEnderChest extends BlockContainer {
return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING }); return new BlockState(this, new IProperty[] { FACING });
} }

View File

@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemLead; import net.minecraft.item.ItemLead;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -222,6 +224,47 @@ public class BlockFence extends Block {
.withProperty(WEST, Boolean.valueOf(this.canConnectTo(iblockaccess, blockpos.west()))); .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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH }); return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH });
} }

View File

@ -10,6 +10,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -76,6 +78,24 @@ public class BlockFenceGate extends BlockDirectional {
return iblockstate; 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) { public boolean canPlaceBlockAt(World world, BlockPos blockpos) {
return world.getBlockState(blockpos.down()).getBlock().getMaterial().isSolid() return world.getBlockState(blockpos.down()).getBlock().getMaterial().isSolid()
? super.canPlaceBlockAt(world, blockpos) ? super.canPlaceBlockAt(world, blockpos)

View File

@ -19,6 +19,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; 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.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -267,6 +269,24 @@ public class BlockFurnace extends BlockContainer {
return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING }); return new BlockState(this, new IProperty[] { FACING });
} }

View File

@ -23,6 +23,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityHopper; import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -259,6 +261,24 @@ public class BlockHopper extends BlockContainer {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, ENABLED }); return new BlockState(this, new IProperty[] { FACING, ENABLED });
} }

View File

@ -12,6 +12,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; 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.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -122,6 +124,191 @@ public class BlockHugeMushroom extends Block {
return ((BlockHugeMushroom.EnumType) iblockstate.getValue(VARIANT)).getMetadata(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { VARIANT }); return new BlockState(this, new IProperty[] { VARIANT });
} }

View File

@ -9,6 +9,8 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -169,6 +171,24 @@ public class BlockLadder extends Block {
return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING }); return new BlockState(this, new IProperty[] { FACING });
} }

View File

@ -11,6 +11,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -269,6 +271,103 @@ public class BlockLever extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, POWERED }); return new BlockState(this, new IProperty[] { FACING, POWERED });
} }

View File

@ -7,6 +7,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -80,6 +81,33 @@ public abstract class BlockLog extends BlockRotatedPillar {
BlockLog.EnumAxis.fromFacingAxis(enumfacing.getAxis())); 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 { public static enum EnumAxis implements IStringSerializable {
X("x"), Y("y"), Z("z"), NONE("none"); X("x"), Y("y"), Z("z"), NONE("none");

View File

@ -14,6 +14,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -217,6 +219,47 @@ public class BlockPane extends Block {
return 0; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH }); return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH });
} }

View File

@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.tileentity.TileEntityPiston;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -458,6 +460,24 @@ public class BlockPistonBase extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, EXTENDED }); return new BlockState(this, new IProperty[] { FACING, EXTENDED });
} }

View File

@ -16,6 +16,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -257,6 +259,24 @@ public class BlockPistonExtension extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, TYPE, SHORT }); return new BlockState(this, new IProperty[] { FACING, TYPE, SHORT });
} }

View File

@ -14,6 +14,8 @@ import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.tileentity.TileEntityPiston;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -295,6 +297,24 @@ public class BlockPistonMoving extends BlockContainer {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, TYPE }); return new BlockState(this, new IProperty[] { FACING, TYPE });
} }

View File

@ -17,6 +17,7 @@ import net.minecraft.item.ItemMonsterPlacer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; 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 { public static class Size {
private final World world; private final World world;
private final EnumFacing.Axis axis; private final EnumFacing.Axis axis;

View File

@ -18,6 +18,8 @@ import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; 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.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -140,6 +142,24 @@ public class BlockPumpkin extends BlockDirectional {
&& World.doesBlockHaveSolidTopSurface(world, blockpos.down()); && 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 * Called by ItemBlocks just before a block is actually set in

View File

@ -14,6 +14,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -139,6 +140,33 @@ public class BlockQuartz extends Block {
return ((BlockQuartz.EnumType) iblockstate.getValue(VARIANT)).getMetadata(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { VARIANT }); return new BlockState(this, new IProperty[] { VARIANT });
} }

View File

@ -4,6 +4,8 @@ import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState; 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.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -77,6 +79,183 @@ public class BlockRail extends BlockRailBase {
return ((BlockRailBase.EnumRailDirection) iblockstate.getValue(SHAPE)).getMetadata(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { SHAPE }); return new BlockState(this, new IProperty[] { SHAPE });
} }

View File

@ -17,6 +17,8 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.util.EntitySelectors; import net.minecraft.util.EntitySelectors;
import net.minecraft.util.EnumFacing; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -221,6 +223,185 @@ public class BlockRailDetector extends BlockRailBase {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { SHAPE, POWERED }); return new BlockState(this, new IProperty[] { SHAPE, POWERED });
} }

View File

@ -7,6 +7,8 @@ import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState; 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.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -206,6 +208,185 @@ public class BlockRailPowered extends BlockRailBase {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { SHAPE, POWERED }); return new BlockState(this, new IProperty[] { SHAPE, POWERED });
} }

View File

@ -22,6 +22,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityComparator; import net.minecraft.tileentity.TileEntityComparator;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
@ -303,6 +305,24 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, MODE, POWERED }); return new BlockState(this, new IProperty[] { FACING, MODE, POWERED });
} }

View File

@ -13,6 +13,8 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; 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.math.BlockPos;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.IBlockAccess; 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))); 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, public boolean onBlockActivated(World world, BlockPos blockpos, IBlockState iblockstate, EntityPlayer entityplayer,
EnumFacing var5, float var6, float var7, float var8) { EnumFacing var5, float var6, float var7, float var8) {
if (!entityplayer.capabilities.allowEdit) { if (!entityplayer.capabilities.allowEdit) {

View File

@ -21,6 +21,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -479,6 +481,47 @@ public class BlockRedstoneWire extends Block {
return ((Integer) iblockstate.getValue(POWER)).intValue(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { NORTH, EAST, SOUTH, WEST, POWER }); return new BlockState(this, new IProperty[] { NORTH, EAST, SOUTH, WEST, POWER });
} }

View File

@ -4,6 +4,7 @@ import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -51,6 +52,47 @@ public class BlockRotatedPillar extends Block {
super(materialIn, materialIn.getMaterialMapColor()); 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) { protected BlockRotatedPillar(Material parMaterial, MapColor parMapColor) {
super(parMaterial, parMapColor); super(parMaterial, parMapColor);
} }

View File

@ -30,6 +30,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
@ -294,6 +296,24 @@ public class BlockSkull extends BlockContainer {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, NODROP }); return new BlockState(this, new IProperty[] { FACING, NODROP });
} }

View File

@ -13,6 +13,8 @@ import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -108,6 +110,47 @@ public class BlockStainedGlassPane extends BlockPane {
return ((EnumDyeColor) iblockstate.getValue(COLOR)).getMetadata(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH, COLOR }); return new BlockState(this, new IProperty[] { NORTH, EAST, WEST, SOUTH, COLOR });
} }

View File

@ -20,6 +20,8 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -693,6 +695,78 @@ public class BlockStairs extends Block {
return iblockstate; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, HALF, SHAPE }); return new BlockState(this, new IProperty[] { FACING, HALF, SHAPE });
} }

View File

@ -4,6 +4,8 @@ import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState; 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.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -72,6 +74,24 @@ public class BlockStandingSign extends BlockSign {
return ((Integer) iblockstate.getValue(ROTATION)).intValue(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { ROTATION }); return new BlockState(this, new IProperty[] { ROTATION });
} }

View File

@ -15,6 +15,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -282,6 +284,24 @@ public class BlockTorch extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING }); return new BlockState(this, new IProperty[] { FACING });
} }

View File

@ -14,6 +14,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -278,6 +280,24 @@ public class BlockTrapDoor extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, OPEN, HALF }); return new BlockState(this, new IProperty[] { FACING, OPEN, HALF });
} }

View File

@ -15,6 +15,8 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -298,6 +300,47 @@ public class BlockTripWire extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, return new BlockState(this,
new IProperty[] { POWERED, SUSPENDED, ATTACHED, DISARMED, NORTH, EAST, WEST, SOUTH }); new IProperty[] { POWERED, SUSPENDED, ATTACHED, DISARMED, NORTH, EAST, WEST, SOUTH });

View File

@ -16,6 +16,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -360,6 +362,24 @@ public class BlockTripWireHook extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, POWERED, ATTACHED, SUSPENDED }); return new BlockState(this, new IProperty[] { FACING, POWERED, ATTACHED, SUSPENDED });
} }

View File

@ -18,6 +18,8 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerFoliage;
@ -462,6 +464,47 @@ public class BlockVine extends Block {
return i; 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { UP, NORTH, EAST, SOUTH, WEST }); return new BlockState(this, new IProperty[] { UP, NORTH, EAST, SOUTH, WEST });
} }

View File

@ -5,6 +5,8 @@ import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing; 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.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -104,6 +106,24 @@ public class BlockWallSign extends BlockSign {
return ((EnumFacing) iblockstate.getValue(FACING)).getIndex(); 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() { protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING }); return new BlockState(this, new IProperty[] { FACING });
} }

View File

@ -33,6 +33,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MapPopulator; import net.minecraft.util.MapPopulator;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Cartesian; import net.minecraft.util.math.Cartesian;
@ -294,6 +295,11 @@ public class BlockState implements ILightInfoProvider {
return this.block.getMapColor(this); return this.block.getMapColor(this);
} }
public IBlockState withRotation(Rotation rot)
{
return this.block.withRotation(this, rot);
}
public boolean isFullCube() { public boolean isFullCube() {
return this.block.isFullCube(); return this.block.isFullCube();
} }

View File

@ -7,6 +7,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -29,6 +30,8 @@ public interface IBlockProperties {
MapColor getMapColor(); MapColor getMapColor();
IBlockState withRotation(Rotation rot);
boolean isFullCube(); boolean isFullCube();
int getRenderType(); int getRenderType();

View File

@ -2166,6 +2166,10 @@ public abstract class Entity implements ICommandSender {
Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ) }); 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) { public boolean isEntityInvulnerable(DamageSource source) {
return this.invulnerable && source != DamageSource.outOfWorld && !source.isCreativePlayer(); return this.invulnerable && source != DamageSource.outOfWorld && !source.isCreativePlayer();
} }
@ -2288,13 +2292,13 @@ public abstract class Entity implements ICommandSender {
return Entity.this.getName(); return Entity.this.getName();
} }
}); });
category.addCrashSection("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", // 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) })); // new Object[] { Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ) }));
category.addCrashSection("Entity\'s Block location", // category.addCrashSection("Entity\'s Block location",
CrashReportCategory.getCoordinateInfo((double) MathHelper.floor_double(this.posX), // CrashReportCategory.getCoordinateInfo((double) MathHelper.floor_double(this.posX),
(double) MathHelper.floor_double(this.posY), (double) MathHelper.floor_double(this.posZ))); // (double) MathHelper.floor_double(this.posY), (double) MathHelper.floor_double(this.posZ)));
category.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { // category.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] {
Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ) })); // Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ) }));
category.addCrashSectionCallable("Entity\'s Rider", new Callable<String>() { category.addCrashSectionCallable("Entity\'s Rider", new Callable<String>() {
public String call() throws Exception { public String call() throws Exception {
return Entity.this.riddenByEntity.toString(); return Entity.this.riddenByEntity.toString();

View File

@ -0,0 +1,98 @@
package net.minecraft.util;
public enum Mirror
{
NONE("no_mirror"),
LEFT_RIGHT("mirror_left_right"),
FRONT_BACK("mirror_front_back");
private final String name;
private static String[] mirrorNames = new String[values().length];
private Mirror(String nameIn)
{
this.name = nameIn;
}
/**
* Mirrors the given rotation like specified by this mirror. rotations start at 0 and go up to rotationCount-1. 0 is
* front, rotationCount/2 is back.
*/
public int mirrorRotation(int rotationIn, int rotationCount)
{
int i = rotationCount / 2;
int j = rotationIn > i ? rotationIn - rotationCount : rotationIn;
switch (this)
{
case LEFT_RIGHT:
return (rotationCount - j) % rotationCount;
case FRONT_BACK:
return (i - j + rotationCount) % rotationCount;
default:
return rotationIn;
}
}
/**
* Determines the rotation that is equivalent to this mirror if the rotating object faces in the given direction
*/
public Rotation toRotation(EnumFacing facing)
{
EnumFacing.Axis enumfacing$axis = facing.getAxis();
return (this != LEFT_RIGHT || enumfacing$axis != EnumFacing.Axis.Z) && (this != FRONT_BACK || enumfacing$axis != EnumFacing.Axis.X) ? Rotation.NONE : Rotation.CLOCKWISE_180;
}
/**
* Mirror the given facing according to this mirror
*/
public EnumFacing mirror(EnumFacing facing)
{
switch (this)
{
case LEFT_RIGHT:
if (facing == EnumFacing.WEST)
{
return EnumFacing.EAST;
}
else
{
if (facing == EnumFacing.EAST)
{
return EnumFacing.WEST;
}
return facing;
}
case FRONT_BACK:
if (facing == EnumFacing.NORTH)
{
return EnumFacing.SOUTH;
}
else
{
if (facing == EnumFacing.SOUTH)
{
return EnumFacing.NORTH;
}
return facing;
}
default:
return facing;
}
}
static {
int i = 0;
for (Mirror mirror : values())
{
mirrorNames[i++] = mirror.name;
}
}
}

View File

@ -0,0 +1,126 @@
package net.minecraft.util;
public enum Rotation
{
NONE("rotate_0"),
CLOCKWISE_90("rotate_90"),
CLOCKWISE_180("rotate_180"),
COUNTERCLOCKWISE_90("rotate_270");
private final String name;
private static String[] rotationNames = new String[values().length];
private Rotation(String nameIn)
{
this.name = nameIn;
}
public Rotation add(Rotation rotation)
{
switch (rotation)
{
case CLOCKWISE_180:
switch (this)
{
case NONE:
return CLOCKWISE_180;
case CLOCKWISE_90:
return COUNTERCLOCKWISE_90;
case CLOCKWISE_180:
return NONE;
case COUNTERCLOCKWISE_90:
return CLOCKWISE_90;
}
case COUNTERCLOCKWISE_90:
switch (this)
{
case NONE:
return COUNTERCLOCKWISE_90;
case CLOCKWISE_90:
return NONE;
case CLOCKWISE_180:
return CLOCKWISE_90;
case COUNTERCLOCKWISE_90:
return CLOCKWISE_180;
}
case CLOCKWISE_90:
switch (this)
{
case NONE:
return CLOCKWISE_90;
case CLOCKWISE_90:
return CLOCKWISE_180;
case CLOCKWISE_180:
return COUNTERCLOCKWISE_90;
case COUNTERCLOCKWISE_90:
return NONE;
}
default:
return this;
}
}
public EnumFacing rotate(EnumFacing facing)
{
if (facing.getAxis() == EnumFacing.Axis.Y)
{
return facing;
}
else
{
switch (this)
{
case CLOCKWISE_90:
return facing.rotateY();
case CLOCKWISE_180:
return facing.getOpposite();
case COUNTERCLOCKWISE_90:
return facing.rotateYCCW();
default:
return facing;
}
}
}
public int rotate(int p_185833_1_, int p_185833_2_)
{
switch (this)
{
case CLOCKWISE_90:
return (p_185833_1_ + p_185833_2_ / 4) % p_185833_2_;
case CLOCKWISE_180:
return (p_185833_1_ + p_185833_2_ / 2) % p_185833_2_;
case COUNTERCLOCKWISE_90:
return (p_185833_1_ + p_185833_2_ * 3 / 4) % p_185833_2_;
default:
return p_185833_1_;
}
}
static {
int i = 0;
for (Rotation rotation : values())
{
rotationNames[i++] = rotation.name;
}
}
}

View File

@ -54,7 +54,7 @@ public class WorldProviderEnd extends WorldProvider {
* world * world
*/ */
public IChunkProvider createChunkGenerator() { public IChunkProvider createChunkGenerator() {
return new ChunkProviderEnd(this.worldObj, this.worldObj.getSeed()); return new ChunkProviderEnd(this.worldObj, this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.worldObj.getSeed());
} }
/** /**

View File

@ -195,13 +195,13 @@ public class BiomeDecorator {
this.chunkProviderSettings.diamondSize); this.chunkProviderSettings.diamondSize);
this.lapisGen = new WorldGenMinable(Blocks.lapis_ore.getDefaultState(), this.lapisGen = new WorldGenMinable(Blocks.lapis_ore.getDefaultState(),
this.chunkProviderSettings.lapisSize); this.chunkProviderSettings.lapisSize);
this.genDecorations(parBiomeGenBase); this.genDecorations(parBiomeGenBase, worldIn, random);
this.currentWorld = null; this.currentWorld = null;
this.randomGenerator = null; this.randomGenerator = null;
} }
} }
protected void genDecorations(BiomeGenBase biomeGenBaseIn) { protected void genDecorations(BiomeGenBase biomeGenBaseIn, World worldIn, EaglercraftRandom random) {
this.generateOres(); this.generateOres();
for (int i = 0; i < this.sandPerChunk2; ++i) { for (int i = 0; i < this.sandPerChunk2; ++i) {

View File

@ -1,9 +1,20 @@
package net.minecraft.world.biome; package net.minecraft.world.biome;
import net.minecraft.entity.boss.EntityDragon; import java.util.Collections;
import net.minecraft.init.Blocks; 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.WorldGenSpikes;
import net.minecraft.world.gen.feature.WorldGenerator;
/** /**
* + * +
@ -36,22 +47,52 @@ import net.minecraft.world.gen.feature.WorldGenerator;
*/ */
public class BiomeEndDecorator extends BiomeDecorator { public class BiomeEndDecorator extends BiomeDecorator {
protected WorldGenerator spikeGen = new WorldGenSpikes(Blocks.end_stone); private static final Map<Long, WorldGenSpikes.EndSpike[]> 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(); this.generateOres();
if (this.randomGenerator.nextInt(5) == 0) { WorldGenSpikes.EndSpike[] aworldgenspikes$endspike = getSpikesForWorld(var2);
int i = this.randomGenerator.nextInt(16) + 8;
int j = this.randomGenerator.nextInt(16) + 8; for (WorldGenSpikes.EndSpike worldgenspikes$endspike : aworldgenspikes$endspike)
this.spikeGen.generate(this.currentWorld, this.randomGenerator, {
this.currentWorld.getTopSolidOrLiquidBlock(this.field_180294_c.add(i, 0, j))); 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()));
}
}
} }
if (this.field_180294_c.getX() == 0 && this.field_180294_c.getZ() == 0) { public static WorldGenSpikes.EndSpike[] getSpikesForWorld(World world)
EntityDragon entitydragon = new EntityDragon(this.currentWorld); {
entitydragon.setLocationAndAngles(0.0D, 128.0D, 0.0D, this.randomGenerator.nextFloat() * 360.0F, 0.0F); Random random = new Random(world.getSeed());
this.currentWorld.spawnEntityInWorld(entitydragon); 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<Integer> 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;
} }
} }

View File

@ -1,7 +1,9 @@
package net.minecraft.world.gen; package net.minecraft.world.gen;
import java.util.List; import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.minecraft.block.BlockChorusFlower;
import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -10,11 +12,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.IProgressUpdate; import net.minecraft.util.IProgressUpdate;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenEndIsland;
/** /**
* + * +
@ -46,73 +50,95 @@ import net.minecraft.world.chunk.IChunkProvider;
* *
*/ */
public class ChunkProviderEnd implements IChunkProvider { public class ChunkProviderEnd implements IChunkProvider {
private EaglercraftRandom endRNG; private EaglercraftRandom rand;
private NoiseGeneratorOctaves noiseGen1; protected static final IBlockState END_STONE = Blocks.end_stone.getDefaultState();
private NoiseGeneratorOctaves noiseGen2; protected static final IBlockState AIR = Blocks.air.getDefaultState();
private NoiseGeneratorOctaves noiseGen3; private final NoiseGeneratorOctaves lperlinNoise1;
public NoiseGeneratorOctaves noiseGen4; private final NoiseGeneratorOctaves lperlinNoise2;
public NoiseGeneratorOctaves noiseGen5; private final NoiseGeneratorOctaves perlinNoise1;
private World endWorld;
private double[] densities;
private BiomeGenBase[] biomesForGeneration;
double[] noiseData1;
double[] noiseData2;
double[] noiseData3;
double[] noiseData4;
double[] noiseData5;
public ChunkProviderEnd(World worldIn, long parLong1) { /** A NoiseGeneratorOctaves used in generating terrain */
this.endWorld = worldIn; public NoiseGeneratorOctaves noiseGen5;
this.endRNG = new EaglercraftRandom(parLong1, !worldIn.getWorldInfo().isOldEaglercraftRandom());
this.noiseGen1 = new NoiseGeneratorOctaves(this.endRNG, 16); /** A NoiseGeneratorOctaves used in generating terrain */
this.noiseGen2 = new NoiseGeneratorOctaves(this.endRNG, 16); public NoiseGeneratorOctaves noiseGen6;
this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8);
this.noiseGen4 = new NoiseGeneratorOctaves(this.endRNG, 10); private World endWorld;
this.noiseGen5 = new NoiseGeneratorOctaves(this.endRNG, 16);
/** 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[] pnr;
double[] ar;
double[] br;
private final WorldGenEndIsland endIslands = new WorldGenEndIsland();
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) { public void func_180520_a(int x, int z, ChunkPrimer primer) {
byte b0 = 2; int i = 2;
int i = b0 + 1; int j = i + 1;
byte b1 = 33; int k = 33;
int j = b0 + 1; int l = i + 1;
this.densities = this.initializeNoiseField(this.densities, parInt1 * b0, 0, parInt2 * b0, i, b1, j); this.buffer = this.initializeNoiseField(this.buffer, x * i, 0, z * i, j, k, l);
for (int k = 0; k < b0; ++k) { for (int i1 = 0; i1 < i; ++i1)
for (int l = 0; l < b0; ++l) { {
for (int i1 = 0; i1 < 32; ++i1) { for (int j1 = 0; j1 < i; ++j1)
{
for (int k1 = 0; k1 < 32; ++k1)
{
double d0 = 0.25D; double d0 = 0.25D;
double d1 = this.densities[((k + 0) * j + l + 0) * b1 + i1 + 0]; double d1 = this.buffer[((i1 + 0) * l + j1 + 0) * k + k1 + 0];
double d2 = this.densities[((k + 0) * j + l + 1) * b1 + i1 + 0]; double d2 = this.buffer[((i1 + 0) * l + j1 + 1) * k + k1 + 0];
double d3 = this.densities[((k + 1) * j + l + 0) * b1 + i1 + 0]; double d3 = this.buffer[((i1 + 1) * l + j1 + 0) * k + k1 + 0];
double d4 = this.densities[((k + 1) * j + l + 1) * b1 + i1 + 0]; double d4 = this.buffer[((i1 + 1) * l + j1 + 1) * k + k1 + 0];
double d5 = (this.densities[((k + 0) * j + l + 0) * b1 + i1 + 1] - d1) * d0; double d5 = (this.buffer[((i1 + 0) * l + j1 + 0) * k + k1 + 1] - d1) * d0;
double d6 = (this.densities[((k + 0) * j + l + 1) * b1 + i1 + 1] - d2) * d0; double d6 = (this.buffer[((i1 + 0) * l + j1 + 1) * k + k1 + 1] - d2) * d0;
double d7 = (this.densities[((k + 1) * j + l + 0) * b1 + i1 + 1] - d3) * d0; double d7 = (this.buffer[((i1 + 1) * l + j1 + 0) * k + k1 + 1] - d3) * d0;
double d8 = (this.densities[((k + 1) * j + l + 1) * b1 + i1 + 1] - d4) * d0; double d8 = (this.buffer[((i1 + 1) * l + j1 + 1) * k + k1 + 1] - d4) * d0;
for (int j1 = 0; j1 < 4; ++j1) { for (int l1 = 0; l1 < 4; ++l1)
{
double d9 = 0.125D; double d9 = 0.125D;
double d10 = d1; double d10 = d1;
double d11 = d2; double d11 = d2;
double d12 = (d3 - d1) * d9; double d12 = (d3 - d1) * d9;
double d13 = (d4 - d2) * d9; double d13 = (d4 - d2) * d9;
for (int k1 = 0; k1 < 8; ++k1) { for (int i2 = 0; i2 < 8; ++i2)
{
double d14 = 0.125D; double d14 = 0.125D;
double d15 = d10; double d15 = d10;
double d16 = (d11 - d10) * d14; double d16 = (d11 - d10) * d14;
for (int l1 = 0; l1 < 8; ++l1) { for (int j2 = 0; j2 < 8; ++j2)
IBlockState iblockstate = null; {
if (d15 > 0.0D) { IBlockState iblockstate = AIR;
iblockstate = Blocks.end_stone.getDefaultState();
if (d15 > 0.0D)
{
iblockstate = END_STONE;
} }
int i2 = k1 + k * 8; int k2 = i2 + i1 * 8;
int j2 = j1 + i1 * 4; int l2 = l1 + k1 * 4;
int k2 = l1 + l * 8; int i3 = j2 + j1 * 8;
parChunkPrimer.setBlockState(i2, j2, k2, iblockstate); primer.setBlockState(k2, l2, i3, iblockstate);
d15 += d16; d15 += d16;
} }
@ -128,43 +154,56 @@ public class ChunkProviderEnd implements IChunkProvider {
} }
} }
} }
} }
public void func_180519_a(ChunkPrimer parChunkPrimer) { public void func_180519_a(ChunkPrimer primer) {
for (int i = 0; i < 16; ++i) { for (int i = 0; i < 16; ++i)
for (int j = 0; j < 16; ++j) { {
byte b0 = 1; for (int j = 0; j < 16; ++j)
int k = -1; {
IBlockState iblockstate = Blocks.end_stone.getDefaultState(); int k = 1;
IBlockState iblockstate1 = Blocks.end_stone.getDefaultState(); int l = -1;
IBlockState iblockstate = END_STONE;
IBlockState iblockstate1 = END_STONE;
for (int l = 127; l >= 0; --l) { for (int i1 = 127; i1 >= 0; --i1)
IBlockState iblockstate2 = parChunkPrimer.getBlockState(i, l, j); {
if (iblockstate2.getBlock().getMaterial() == Material.air) { IBlockState iblockstate2 = primer.getBlockState(i, i1, j);
k = -1;
} else if (iblockstate2.getBlock() == Blocks.stone) { if (iblockstate2.getMaterial() == Material.air)
if (k == -1) { {
if (b0 <= 0) { l = -1;
iblockstate = Blocks.air.getDefaultState(); }
iblockstate1 = Blocks.end_stone.getDefaultState(); else if (iblockstate2.getBlock() == Blocks.stone)
{
if (l == -1)
{
if (k <= 0)
{
iblockstate = AIR;
iblockstate1 = END_STONE;
} }
k = b0; l = k;
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 (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,18 +212,24 @@ public class ChunkProviderEnd implements IChunkProvider {
* MP client it will generates all the blocks for the specified * MP client it will generates all the blocks for the specified
* chunk from the map seed and chunk seed * chunk from the map seed and chunk seed
*/ */
public Chunk provideChunk(int i, int j) { public Chunk provideChunk(int x, int z) {
this.endRNG.setSeed((long) i * 341873128712L + (long) j * 132897987541L); this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer(); ChunkPrimer chunkprimer = new ChunkPrimer();
this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
i * 16, j * 16, 16, 16); this.func_180520_a(x, z, chunkprimer);
this.func_180520_a(i, j, chunkprimer);
this.func_180519_a(chunkprimer); this.func_180519_a(chunkprimer);
Chunk chunk = new Chunk(this.endWorld, chunkprimer, i, j);
// if (this.mapFeaturesEnabled)
// {
// this.endCityGen.generate(this.worldObj, x, z, chunkprimer);
// }
Chunk chunk = new Chunk(this.endWorld, chunkprimer, x, z);
byte[] abyte = chunk.getBiomeArray(); byte[] abyte = chunk.getBiomeArray();
for (int k = 0; k < abyte.length; ++k) { for (int i = 0; i < abyte.length; ++i)
abyte[k] = (byte) this.biomesForGeneration[k].biomeID; {
abyte[i] = (byte) this.biomesForGeneration[i].biomeID;
} }
chunk.generateSkylightMap(); chunk.generateSkylightMap();
@ -195,81 +240,136 @@ public class ChunkProviderEnd implements IChunkProvider {
return this.provideChunk(parInt1, 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 * generates a subset of the level's terrain data. Takes 7
* arguments: the [empty] noise array, the position, and the * arguments: the [empty] noise array, the position, and the
* size. * size.
*/ */
private double[] initializeNoiseField(double[] parArrayOfDouble, int parInt1, int parInt2, int parInt3, int parInt4, 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_) {
int parInt5, int parInt6) { if (p_185963_1_ == null)
if (parArrayOfDouble == null) { {
parArrayOfDouble = new double[parInt4 * parInt5 * parInt6]; p_185963_1_ = new double[p_185963_5_ * p_185963_6_ * p_185963_7_];
} }
double d0 = 684.412D; double d0 = 684.412D;
double d1 = 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; d0 = d0 * 2.0D;
this.noiseData1 = this.noiseGen3.generateNoiseOctaves(this.noiseData1, parInt1, parInt2, parInt3, parInt4, 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);
parInt5, parInt6, 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.noiseData2 = this.noiseGen1.generateNoiseOctaves(this.noiseData2, parInt1, parInt2, parInt3, parInt4, 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);
parInt5, parInt6, d0, d1, d0); int i = p_185963_2_ / 2;
this.noiseData3 = this.noiseGen2.generateNoiseOctaves(this.noiseData3, parInt1, parInt2, parInt3, parInt4, int j = p_185963_4_ / 2;
parInt5, parInt6, d0, d1, d0); int k = 0;
int i = 0;
for (int j = 0; j < parInt4; ++j) { for (int l = 0; l < p_185963_5_; ++l)
for (int k = 0; k < parInt6; ++k) { {
float f = (float) (j + parInt1) / 1.0F; for (int i1 = 0; i1 < p_185963_7_; ++i1)
float f1 = (float) (k + parInt3) / 1.0F; {
float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F; float f = this.getIslandHeightValue(i, j, l, i1);
if (f2 > 80.0F) {
f2 = 80.0F;
}
if (f2 < -100.0F) { for (int j1 = 0; j1 < p_185963_6_; ++j1)
f2 = -100.0F; {
}
for (int l = 0; l < parInt5; ++l) {
double d2 = 0.0D; double d2 = 0.0D;
double d3 = this.noiseData2[i] / 512.0D; double d3 = this.ar[k] / 512.0D;
double d4 = this.noiseData3[i] / 512.0D; double d4 = this.br[k] / 512.0D;
double d5 = (this.noiseData1[i] / 10.0D + 1.0D) / 2.0D; double d5 = (this.pnr[k] / 10.0D + 1.0D) / 2.0D;
if (d5 < 0.0D) {
if (d5 < 0.0D)
{
d2 = d3; d2 = d3;
} else if (d5 > 1.0D) { }
else if (d5 > 1.0D)
{
d2 = d4; d2 = d4;
} else { }
else
{
d2 = d3 + (d4 - d3) * d5; d2 = d3 + (d4 - d3) * d5;
} }
d2 = d2 - 8.0D; d2 = d2 - 8.0D;
d2 = d2 + (double) f2; d2 = d2 + (double)f;
byte b0 = 2; int k1 = 2;
if (l > parInt5 / 2 - b0) {
double d6 = (double) ((float) (l - (parInt5 / 2 - b0)) / 64.0F); 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); d6 = MathHelper.clamp_double(d6, 0.0D, 1.0D);
d2 = d2 * (1.0D - d6) + -3000.0D * d6; d2 = d2 * (1.0D - d6) + -3000.0D * d6;
} }
b0 = 8; k1 = 8;
if (l < b0) {
double d7 = (double) ((float) (b0 - l) / ((float) b0 - 1.0F)); if (j1 < k1)
{
double d7 = (double)((float)(k1 - j1) / ((float)k1 - 1.0F));
d2 = d2 * (1.0D - d7) + -30.0D * d7; d2 = d2 * (1.0D - d7) + -30.0D * d7;
} }
parArrayOfDouble[i] = d2; p_185963_1_[k] = d2;
++i; ++k;
} }
} }
} }
return parArrayOfDouble; return p_185963_1_;
} }
/** /**
@ -284,11 +384,55 @@ public class ChunkProviderEnd implements IChunkProvider {
* + * +
* Populates chunk with ores etc etc * 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; BlockFalling.fallInstantly = true;
BlockPos blockpos = new BlockPos(i * 16, 0, j * 16); BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);
this.endWorld.getBiomeGenForCoords(blockpos.add(16, 0, 16)).decorate(this.endWorld, this.endWorld.rand,
blockpos); // 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; BlockFalling.fallInstantly = false;
} }

View File

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

View File

@ -1,10 +1,13 @@
package net.minecraft.world.gen.feature; package net.minecraft.world.gen.feature;
import javax.annotation.Nullable;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityEnderCrystal; import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
@ -37,51 +40,129 @@ import net.minecraft.world.World;
* *
*/ */
public class WorldGenSpikes extends WorldGenerator { public class WorldGenSpikes extends WorldGenerator {
private Block baseBlockRequired; private boolean crystalInvulnerable = false;
private WorldGenSpikes.EndSpike spike = null;
private BlockPos beamTarget;
public WorldGenSpikes(Block parBlock) { public void setSpike(WorldGenSpikes.EndSpike p_186143_1_)
this.baseBlockRequired = parBlock; {
this.spike = p_186143_1_;
} }
public boolean generate(World world, EaglercraftRandom random, BlockPos blockpos) { public void setCrystalInvulnerable(boolean p_186144_1_)
if (world.isAirBlock(blockpos) && world.getBlockState(blockpos.down()).getBlock() == this.baseBlockRequired) { {
int i = random.nextInt(32) + 6; this.crystalInvulnerable = p_186144_1_;
int j = random.nextInt(4) + 1; }
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int k = blockpos.getX() - j; k <= blockpos.getX() + j; ++k) { public boolean generate(World worldIn, EaglercraftRandom rand, BlockPos position)
for (int l = blockpos.getZ() - j; l <= blockpos.getZ() + j; ++l) { {
int i1 = k - blockpos.getX(); if (this.spike == null)
int j1 = l - blockpos.getZ(); {
if (i1 * i1 + j1 * j1 <= j * j + 1 throw new IllegalStateException("Decoration requires priming with a spike");
&& world.getBlockState(blockpos$mutableblockpos.func_181079_c(k, blockpos.getY() - 1, l)) }
.getBlock() != this.baseBlockRequired) { else
return false; {
int i = this.spike.getRadius();
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());
}
}
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());
} }
} }
} }
for (int l1 = blockpos.getY(); l1 < blockpos.getY() + i && l1 < 256; ++l1) { EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(worldIn);
for (int i2 = blockpos.getX() - j; i2 <= blockpos.getX() + j; ++i2) { entityendercrystal.setBeamTarget(this.beamTarget);
for (int j2 = blockpos.getZ() - j; j2 <= blockpos.getZ() + j; ++j2) { entityendercrystal.setEntityInvulnerable(this.crystalInvulnerable);
int k2 = i2 - blockpos.getX(); 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);
int k1 = j2 - blockpos.getZ(); worldIn.spawnEntityInWorld(entityendercrystal);
if (k2 * k2 + k1 * k1 <= j * j + 1) { this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX(), this.spike.getHeight(), position.getZ()), Blocks.bedrock.getDefaultState());
world.setBlockState(new BlockPos(i2, l1, j2), Blocks.obsidian.getDefaultState(), 2);
}
}
}
}
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; return true;
} else { }
return false; }
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;
} }
} }
} }

View File

@ -0,0 +1,5 @@
package net.minecraft.world.gen.structure;
public class StructureEndCityPieces {
}