Compare commits

...

2 commits

Author SHA1 Message Date
Sen
ea76cecba3
more block data fixes 2025-06-23 11:41:33 +02:00
Sen
eb815a8e21
block data fixes 2025-06-23 10:18:24 +02:00
74 changed files with 281 additions and 448 deletions

View file

@ -1930,7 +1930,7 @@ public class Client implements IThreadListener {
String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ()) String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ())
); );
for(Entry<Property, Comparable> entry : block.getProperties().entrySet()) { for(Entry<Property, Comparable> entry : block.getProperties().entrySet()) {
str.append("\n" + entry.getKey().getName() + ": " + entry.getValue().toString()); str.append("\n" + (block.getSavedProperties().contains(entry.getKey()) ? TextColor.NEON : TextColor.LGRAY) + entry.getKey().getName() + TextColor.RESET + ": " + (entry.getValue() instanceof Boolean bool ? (bool ? TextColor.GREEN : TextColor.RED) + "" + entry.getValue() + TextColor.RESET : entry.getValue()));
} }
return str.toString(); return str.toString();

View file

@ -774,8 +774,8 @@ public class Block {
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn) { public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn) {
} }
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) { public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getStateFromMeta(meta); return this.getState();
} }
public void onBlockClicked(World worldIn, BlockPos pos, EntityNPC playerIn) { public void onBlockClicked(World worldIn, BlockPos pos, EntityNPC playerIn) {

View file

@ -108,7 +108,7 @@ public class BlockFenceGate extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)); return this.getState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false));
} }

View file

@ -75,8 +75,8 @@ public class BlockHay extends BlockRotatedPillar
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(AXIS, facing.getAxis()); return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, placer).withProperty(AXIS, facing.getAxis());
} }
} }

View file

@ -90,7 +90,7 @@ public class BlockLadder extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
if (facing.getAxis().isHorizontal() && this.canBlockStay(worldIn, pos, facing)) if (facing.getAxis().isHorizontal() && this.canBlockStay(worldIn, pos, facing))
{ {

View file

@ -19,8 +19,12 @@ public class BlockMetalBlock extends Block {
this.setRadiation(metal.radioactivity * 2.0f); this.setRadiation(metal.radioactivity * 2.0f);
this.setTab(CheatTab.GEMS); this.setTab(CheatTab.GEMS);
} }
public MetalType getMetal() {
return this.metal;
}
protected Item getItemToRegister() { protected Item getItemToRegister() {
return new ItemMetalBlock(this, this.metal, false); return new ItemMetalBlock(this);
} }
} }

View file

@ -92,7 +92,7 @@ public class BlockPortalFrame extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(ORB, Boolean.valueOf(false)); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(ORB, Boolean.valueOf(false));
} }

View file

@ -29,7 +29,7 @@ public class BlockQuartzPillar extends BlockRotatedPillar
return this.dark; return this.dark;
} }
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(AXIS, facing.getAxis()); return this.getState().withProperty(AXIS, facing.getAxis());
} }

View file

@ -30,7 +30,7 @@ public class BlockSkull extends Block implements Rotatable {
return world.getState(pos).getBlock().getMaterial().isReplaceable() && world.isBlockSolid(pos.down()); return world.getState(pos).getBlock().getMaterial().isReplaceable() && world.isBlockSolid(pos.down());
} }
public State onBlockPlaced(World world, BlockPos pos, Facing face, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) { public State onBlockPlaced(World world, BlockPos pos, Facing face, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
} }

View file

@ -103,7 +103,7 @@ public class BlockSlab extends Block implements Directional
} }
} }
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
State iblockstate = this.getState().withProperty(FACING, Facing.DOWN); State iblockstate = this.getState().withProperty(FACING, Facing.DOWN);
return facing != Facing.DOWN && (facing == Facing.UP || (double)hitY <= 0.5D) ? iblockstate : return facing != Facing.DOWN && (facing == Facing.UP || (double)hitY <= 0.5D) ? iblockstate :

View file

@ -682,9 +682,9 @@ public class BlockStairs extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
State iblockstate = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer); State iblockstate = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, placer);
iblockstate = iblockstate.withProperty(FACING, placer.getHorizontalFacing()).withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT); iblockstate = iblockstate.withProperty(FACING, placer.getHorizontalFacing()).withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT);
return facing != Facing.DOWN && (facing == Facing.UP || (double)hitY <= 0.5D) ? iblockstate.withProperty(HALF, BlockStairs.EnumHalf.BOTTOM) : iblockstate.withProperty(HALF, BlockStairs.EnumHalf.TOP); return facing != Facing.DOWN && (facing == Facing.UP || (double)hitY <= 0.5D) ? iblockstate.withProperty(HALF, BlockStairs.EnumHalf.BOTTOM) : iblockstate.withProperty(HALF, BlockStairs.EnumHalf.TOP);
} }

View file

@ -188,7 +188,7 @@ public class BlockTrapDoor extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
State iblockstate = this.getState(); State iblockstate = this.getState();

View file

@ -126,7 +126,7 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
if (!facing.getAxis().isHorizontal()) if (!facing.getAxis().isHorizontal())
{ {

View file

@ -4,7 +4,6 @@ import common.block.Block;
import common.block.Material; import common.block.Material;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.item.Item; import common.item.Item;
import common.item.block.ItemBlock;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.Property;
@ -75,7 +74,7 @@ public class BlockHugeMushroom extends Block
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState(); return this.getState();
} }
@ -141,10 +140,6 @@ public class BlockHugeMushroom extends Block
.w(name + "_cap").e(name + "_inside"); .w(name + "_cap").e(name + "_inside");
} }
} }
protected Item getItemToRegister() {
return new ItemBlock(this, 14);
}
public static enum EnumType implements Identifyable public static enum EnumType implements Identifyable
{ {

View file

@ -8,6 +8,7 @@ import common.block.SoundType;
import common.collect.Lists; import common.collect.Lists;
import common.color.Colorizer; import common.color.Colorizer;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Blocks; import common.init.Blocks;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.init.WoodType; import common.init.WoodType;
@ -24,6 +25,7 @@ import common.properties.PropertyBool;
import common.rng.Random; import common.rng.Random;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing;
import common.vars.Vars; import common.vars.Vars;
import common.world.IWorldAccess; import common.world.IWorldAccess;
import common.world.AWorldClient; import common.world.AWorldClient;
@ -326,6 +328,10 @@ public class BlockLeaves extends BlockLeavesBase
super.harvestBlock(worldIn, player, pos, state, te); super.harvestBlock(worldIn, player, pos, state, te);
} }
} }
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getState().withProperty(DECAY, false);
}
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
return this.subType.isTinted() ? provider.getModel(name).add().all().tint() : return this.subType.isTinted() ? provider.getModel(name).add().all().tint() :
@ -337,6 +343,6 @@ public class BlockLeaves extends BlockLeavesBase
} }
protected Item getItemToRegister() { protected Item getItemToRegister() {
return new ItemColored(this, 8); return new ItemColored(this);
} }
} }

View file

@ -102,7 +102,7 @@ public class BlockLilyPad extends BlockBush implements Rotatable
return new Property[] {FACING}; return new Property[] {FACING};
} }
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
} }

View file

@ -54,9 +54,9 @@ public class BlockLog extends BlockRotatedPillar
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(facing.getAxis())); return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, placer).withProperty(LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(facing.getAxis()));
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -25,7 +25,7 @@ public class BlockPumpkin extends Block implements Rotatable {
return world.getState(pos).getBlock().getMaterial().isReplaceable() && world.isBlockSolid(pos.down()); return world.getState(pos).getBlock().getMaterial().isReplaceable() && world.isBlockSolid(pos.down());
} }
public State onBlockPlaced(World world, BlockPos pos, Facing face, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) { public State onBlockPlaced(World world, BlockPos pos, Facing face, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
} }

View file

@ -401,7 +401,7 @@ public class BlockVine extends Block
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
State iblockstate = this.getState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)); State iblockstate = this.getState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false));
return facing.getAxis().isHorizontal() ? iblockstate.withProperty(getPropertyFor(facing.getOpposite()), Boolean.valueOf(true)) : iblockstate; return facing.getAxis().isHorizontal() ? iblockstate.withProperty(getPropertyFor(facing.getOpposite()), Boolean.valueOf(true)) : iblockstate;

View file

@ -14,8 +14,12 @@ public class BlockMetalOre extends BlockOre {
this.setLightLevel(metal.radioactivity > 0.0F ? 0.25F : 0.0F); this.setLightLevel(metal.radioactivity > 0.0F ? 0.25F : 0.0F);
this.setRadiation(metal.radioactivity * 0.5f); this.setRadiation(metal.radioactivity * 0.5f);
} }
public MetalType getMetal() {
return this.metal;
}
protected Item getItemToRegister() { protected Item getItemToRegister() {
return new ItemMetalBlock(this, this.metal, true); return new ItemMetalBlock(this);
} }
} }

View file

@ -68,10 +68,10 @@ public class BlockAnvil extends BlockFalling implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
Facing enumfacing = placer.getHorizontalFacing().rotateY(); Facing enumfacing = placer.getHorizontalFacing().rotateY();
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, enumfacing); return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, placer).withProperty(FACING, enumfacing);
} }
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)

View file

@ -107,7 +107,7 @@ public class BlockButton extends Block implements Directional
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return canPlaceButtonOn(worldIn, pos, facing.getOpposite()) ? this.getState().withProperty(FACING, facing).withProperty(POWERED, Boolean.valueOf(false)) : this.getState().withProperty(FACING, Facing.DOWN).withProperty(POWERED, Boolean.valueOf(false)); return canPlaceButtonOn(worldIn, pos, facing.getOpposite()) ? this.getState().withProperty(FACING, facing).withProperty(POWERED, Boolean.valueOf(false)) : this.getState().withProperty(FACING, Facing.DOWN).withProperty(POWERED, Boolean.valueOf(false));
} }

View file

@ -113,7 +113,7 @@ public class BlockChest extends BlockContainer implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing()); return this.getState().withProperty(FACING, placer.getHorizontalFacing());
} }

View file

@ -10,9 +10,7 @@ import common.entity.types.EntityLiving;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.InventoryHelper; import common.inventory.InventoryHelper;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.block.ItemBlock;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.ModelRotation; import common.model.ModelRotation;
@ -201,7 +199,7 @@ public class BlockDispenser extends BlockContainer implements Directional
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)).withProperty(TRIGGERED, Boolean.valueOf(false)); return this.getState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)).withProperty(TRIGGERED, Boolean.valueOf(false));
} }
@ -321,8 +319,4 @@ public class BlockDispenser extends BlockContainer implements Directional
public Property<?>[] getIgnoredProperties() { public Property<?>[] getIgnoredProperties() {
return new Property[] {TRIGGERED}; return new Property[] {TRIGGERED};
} }
protected Item getItemToRegister() {
return new ItemBlock(this, 2);
}
} }

View file

@ -177,7 +177,7 @@ public class BlockFurnace extends BlockContainer implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
} }

View file

@ -122,7 +122,7 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
Facing enumfacing = facing.getOpposite(); Facing enumfacing = facing.getOpposite();

View file

@ -83,7 +83,7 @@ public class BlockLever extends Block
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
State iblockstate = this.getState().withProperty(POWERED, Boolean.valueOf(false)); State iblockstate = this.getState().withProperty(POWERED, Boolean.valueOf(false));

View file

@ -81,8 +81,7 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam); return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
} }
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
EntityLiving placer) {
return this.getState().withProperty(FACING, placer.getHorizontalFacing()); return this.getState().withProperty(FACING, placer.getHorizontalFacing());
} }

View file

@ -307,7 +307,7 @@ public class BlockPistonBase extends Block implements Directional
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)).withProperty(EXTENDED, Boolean.valueOf(false)); return this.getState().withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)).withProperty(EXTENDED, Boolean.valueOf(false));
} }
@ -632,7 +632,6 @@ public class BlockPistonBase extends Block implements Directional
BlockPos blockpos2 = (BlockPos)list.get(k); BlockPos blockpos2 = (BlockPos)list.get(k);
State iblockstate = worldIn.getState(blockpos2); State iblockstate = worldIn.getState(blockpos2);
Block block1 = iblockstate.getBlock(); Block block1 = iblockstate.getBlock();
block1.getMetaFromState(iblockstate);
worldIn.setBlockToAir(blockpos2); worldIn.setBlockToAir(blockpos2);
blockpos2 = blockpos2.offset(enumfacing); blockpos2 = blockpos2.offset(enumfacing);
worldIn.setState(blockpos2, Blocks.piston_extension.getState().withProperty(FACING, direction), 4); worldIn.setState(blockpos2, Blocks.piston_extension.getState().withProperty(FACING, direction), 4);

View file

@ -312,7 +312,7 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, BlockRedstoneComparator.Mode.COMPARE); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, BlockRedstoneComparator.Mode.COMPARE);
} }

View file

@ -191,7 +191,7 @@ public abstract class BlockRedstoneDiode extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
} }

View file

@ -98,7 +98,7 @@ public class BlockTorch extends Block implements DirectionalUp
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
if (this.canPlaceAt(worldIn, pos, facing)) if (this.canPlaceAt(worldIn, pos, facing))
{ {

View file

@ -91,7 +91,7 @@ public class BlockTripWireHook extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
State iblockstate = this.getState().withProperty(POWERED, Boolean.valueOf(false)).withProperty(ATTACHED, Boolean.valueOf(false)).withProperty(SUSPENDED, Boolean.valueOf(false)); State iblockstate = this.getState().withProperty(POWERED, Boolean.valueOf(false)).withProperty(ATTACHED, Boolean.valueOf(false)).withProperty(SUSPENDED, Boolean.valueOf(false));

View file

@ -83,7 +83,7 @@ public class BlockWarpChest extends Block implements Rotatable
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate * IBlockstate
*/ */
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer) public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
} }

View file

@ -222,39 +222,21 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
private long seed = 0L; private long seed = 0L;
public static void writeState(TagObject tag, String name, String dname, State state) {
if(state == null)
return;
tag.setString(name, BlockRegistry.getNameFromBlock(state.getBlock()));
if(state != state.getBlock().getState())
tag.setByte(dname, (byte)state.getBlock().getMetaFromState(state));
}
public static void writeState(TagObject tag, String name, State state) { public static void writeState(TagObject tag, String name, State state) {
writeState(tag, name, name + "Data", state); if(state != null)
tag.setString(name, state.getId());
} }
public static void writeState(TagObject tag, State state) { public static void writeState(TagObject tag, State state) {
writeState(tag, "Block", "Data", state); writeState(tag, "Block", state);
}
public static State readState(TagObject tag, String name, String dname, State def) {
if(!tag.hasString(name))
return def;
Block block = BlockRegistry.getRegisteredBlock(tag.getString(name));
if(tag.hasByte(dname)) {
byte data = tag.getByte(dname);
return data < 0 || data >= 16 ? block.getState() : block.getStateFromMeta(data);
}
return block.getState();
} }
public static State readState(TagObject tag, String name, State def) { public static State readState(TagObject tag, String name, State def) {
return readState(tag, name, name + "Data", def); return tag.hasString(name) ? State.getState(tag.getString(name), def) : def;
} }
public static State readState(TagObject tag, State def) { public static State readState(TagObject tag, State def) {
return readState(tag, "Block", "Data", def); return readState(tag, "Block", def);
} }
public Dimension(int id, String name) { public Dimension(int id, String name) {
@ -956,12 +938,9 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.caveFiller = readState(tag, "CaveFillBlock", Blocks.lava.getState()); this.caveFiller = readState(tag, "CaveFillBlock", Blocks.lava.getState());
if(tag.hasStringArray("Layers")) { if(tag.hasStringArray("Layers")) {
String[] list = tag.getStringArray("Layers"); String[] list = tag.getStringArray("Layers");
byte[] data = tag.hasByteArray("LayerData") ? tag.getByteArray("LayerData") : null;
data = data != null && data.length != list.length ? null : data;
this.layers = new State[list.length]; this.layers = new State[list.length];
for(int z = 0; z < this.layers.length; z++) { for(int z = 0; z < this.layers.length; z++) {
Block block = BlockRegistry.getRegisteredBlock(list[z]); this.layers[z] = State.getState(list[z], Blocks.air.getState());
this.layers[z] = data == null ? block.getState() : block.getStateFromMeta(data[z]);
} }
} }
else { else {
@ -1197,18 +1176,11 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
writeState(tag, "AltBlock2", this.alt2); writeState(tag, "AltBlock2", this.alt2);
writeState(tag, "CaveFillBlock", this.caveFiller); writeState(tag, "CaveFillBlock", this.caveFiller);
if(this.layers != null) { if(this.layers != null) {
boolean dataUsed = false;
String[] list = new String[this.layers.length]; String[] list = new String[this.layers.length];
byte[] data = new byte[this.layers.length];
for(int z = 0; z < this.layers.length; z++) { for(int z = 0; z < this.layers.length; z++) {
State state = this.layers[z]; list[z] = this.layers[z].getId();
list[z] = BlockRegistry.getNameFromBlock(state.getBlock());
data[z] = (byte)state.getBlock().getMetaFromState(state);
dataUsed |= state.getBlock().getState() != state;
} }
tag.setStringArray("Layers", list); tag.setStringArray("Layers", list);
if(dataUsed)
tag.setByteArray("LayerData", data);
} }
if(this.addBiomes != null) { if(this.addBiomes != null) {
String[] list = new String[this.addBiomes.length]; String[] list = new String[this.addBiomes.length];

View file

@ -1061,7 +1061,7 @@ public abstract class Entity
if (block.getMaterial().isColdLiquid()) if (block.getMaterial().isColdLiquid())
{ {
float f = BlockLiquid.getLiquidHeightPercent(iblockstate.getBlock().getMetaFromState(iblockstate)) - 0.11111111F; float f = BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL)) - 0.11111111F;
float f1 = (float)(blockpos.getY() + 1) - f; float f1 = (float)(blockpos.getY() + 1) - f;
boolean flag = d0 < (double)f1; boolean flag = d0 < (double)f1;
return !flag && this.isPlayer() ? false : flag; return !flag && this.isPlayer() ? false : flag;

View file

@ -1,13 +1,11 @@
package common.entity.item; package common.entity.item;
import common.block.Block;
import common.block.tech.BlockRailBase; import common.block.tech.BlockRailBase;
import common.block.tech.BlockRailPowered; import common.block.tech.BlockRailPowered;
import common.entity.DamageSource; import common.entity.DamageSource;
import common.entity.Entity; import common.entity.Entity;
import common.entity.EntityType; import common.entity.EntityType;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;
import common.item.Item; import common.item.Item;
@ -89,9 +87,6 @@ public abstract class EntityCart extends Entity implements IWorldNameable
this.dataWatcher.addObject(17, 0); this.dataWatcher.addObject(17, 0);
this.dataWatcher.addObject(18, 1); this.dataWatcher.addObject(18, 1);
this.dataWatcher.addObject(19, 0); this.dataWatcher.addObject(19, 0);
this.dataWatcher.addObject(20, 0);
this.dataWatcher.addObject(21, 6);
this.dataWatcher.addObject(22, Byte.valueOf((byte)0));
} }
/** /**
@ -755,24 +750,6 @@ public abstract class EntityCart extends Entity implements IWorldNameable
*/ */
protected void readEntity(TagObject tagCompund) protected void readEntity(TagObject tagCompund)
{ {
if (tagCompund.getBool("CustomDisplayTile"))
{
int i = tagCompund.getInt("DisplayData");
if (tagCompund.hasString("DisplayTile"))
{
Block block = BlockRegistry.getRegisteredBlock(tagCompund.getString("DisplayTile"));
this.func_174899_a(block.getStateFromMeta(i));
}
else
{
this.func_174899_a(Blocks.air.getState());
}
this.setDisplayTileOffset(tagCompund.getInt("DisplayOffset"));
}
if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0) if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0)
{ {
this.entityName = tagCompund.getString("CustomName"); this.entityName = tagCompund.getString("CustomName");
@ -784,16 +761,6 @@ public abstract class EntityCart extends Entity implements IWorldNameable
*/ */
protected void writeEntity(TagObject tagCompound) protected void writeEntity(TagObject tagCompound)
{ {
if (this.hasDisplayTile())
{
tagCompound.setBool("CustomDisplayTile", true);
State iblockstate = this.getDisplayTile();
String resourcelocation = BlockRegistry.getNameFromBlock(iblockstate.getBlock());
tagCompound.setString("DisplayTile", resourcelocation == null ? "" : resourcelocation);
tagCompound.setInt("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
tagCompound.setInt("DisplayOffset", this.getDisplayTileOffset());
}
if (this.entityName != null && this.entityName.length() > 0) if (this.entityName != null && this.entityName.length() > 0)
{ {
tagCompound.setString("CustomName", this.entityName); tagCompound.setString("CustomName", this.entityName);
@ -972,47 +939,15 @@ public abstract class EntityCart extends Entity implements IWorldNameable
public abstract EntityCart.EnumMinecartType getMinecartType(); public abstract EntityCart.EnumMinecartType getMinecartType();
public State getDisplayTile() public State getDisplayTile()
{
return !this.hasDisplayTile() ? this.getDefaultDisplayTile() : BlockRegistry.getStateById(this.getDataWatcher().getWatchableObjectInt(20));
}
public State getDefaultDisplayTile()
{ {
return Blocks.air.getState(); return Blocks.air.getState();
} }
public int getDisplayTileOffset() public int getDisplayTileOffset()
{
return !this.hasDisplayTile() ? this.getDefaultDisplayTileOffset() : this.getDataWatcher().getWatchableObjectInt(21);
}
public int getDefaultDisplayTileOffset()
{ {
return 6; return 6;
} }
public void func_174899_a(State p_174899_1_)
{
this.getDataWatcher().updateObject(20, Integer.valueOf(BlockRegistry.getStateId(p_174899_1_)));
this.setHasDisplayTile(true);
}
public void setDisplayTileOffset(int p_94086_1_)
{
this.getDataWatcher().updateObject(21, Integer.valueOf(p_94086_1_));
this.setHasDisplayTile(true);
}
public boolean hasDisplayTile()
{
return this.getDataWatcher().getWatchableObjectByte(22) == 1;
}
public void setHasDisplayTile(boolean p_94096_1_)
{
this.getDataWatcher().updateObject(22, Byte.valueOf((byte)(p_94096_1_ ? 1 : 0)));
}
/** /**
* Sets the custom name tag for this entity * Sets the custom name tag for this entity
*/ */

View file

@ -48,12 +48,12 @@ public class EntityChestCart extends EntityCartContainer
return EntityCart.EnumMinecartType.CHEST; return EntityCart.EnumMinecartType.CHEST;
} }
public State getDefaultDisplayTile() public State getDisplayTile()
{ {
return Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.NORTH); return Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.NORTH);
} }
public int getDefaultDisplayTileOffset() public int getDisplayTileOffset()
{ {
return 8; return 8;
} }

View file

@ -203,10 +203,7 @@ public class EntityFalling extends Entity implements IObjectData
*/ */
protected void writeEntity(TagObject tagCompound) protected void writeEntity(TagObject tagCompound)
{ {
Block block = this.fallTile != null ? this.fallTile.getBlock() : Blocks.air; tagCompound.setString("Block", (this.fallTile != null ? this.fallTile : Blocks.air.getState()).getId());
String resourcelocation = BlockRegistry.getNameFromBlock(block);
tagCompound.setString("Block", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("Data", (byte)block.getMetaFromState(this.fallTile));
tagCompound.setByte("Time", (byte)this.fallTime); tagCompound.setByte("Time", (byte)this.fallTime);
tagCompound.setBool("DropItem", this.shouldDropItem); tagCompound.setBool("DropItem", this.shouldDropItem);
tagCompound.setBool("HurtEntities", this.hurtEntities); tagCompound.setBool("HurtEntities", this.hurtEntities);
@ -219,11 +216,9 @@ public class EntityFalling extends Entity implements IObjectData
*/ */
protected void readEntity(TagObject tagCompund) protected void readEntity(TagObject tagCompund)
{ {
int i = tagCompund.getByte("Data") & 255;
if (tagCompund.hasString("Block")) if (tagCompund.hasString("Block"))
{ {
this.fallTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("Block")).getStateFromMeta(i); this.fallTile = State.getState(tagCompund.getString("Block"), Blocks.sand.getState());
} }
else else
{ {

View file

@ -40,12 +40,12 @@ public class EntityHopperCart extends EntityCartContainer implements IHopper
return EntityCart.EnumMinecartType.HOPPER; return EntityCart.EnumMinecartType.HOPPER;
} }
public State getDefaultDisplayTile() public State getDisplayTile()
{ {
return Blocks.hopper.getState(); return Blocks.hopper.getState();
} }
public int getDefaultDisplayTileOffset() public int getDisplayTileOffset()
{ {
return 1; return 1;
} }

View file

@ -35,7 +35,7 @@ public class EntityTntCart extends EntityCart
return EntityCart.EnumMinecartType.TNT; return EntityCart.EnumMinecartType.TNT;
} }
public State getDefaultDisplayTile() public State getDisplayTile()
{ {
return Blocks.tnt.getState(); return Blocks.tnt.getState();
} }

View file

@ -11,7 +11,6 @@ import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.entity.types.IObjectData; import common.entity.types.IObjectData;
import common.entity.types.IProjectile; import common.entity.types.IProjectile;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent; import common.init.SoundEvent;
@ -32,8 +31,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
private int xTile = -1; private int xTile = -1;
private int yTile = -1; private int yTile = -1;
private int zTile = -1; private int zTile = -1;
private Block inTile; private State inTile;
private int inData;
private boolean inGround; private boolean inGround;
/** 1 if the player can pick up the arrow */ /** 1 if the player can pick up the arrow */
@ -219,9 +217,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
if (this.inGround) if (this.inGround)
{ {
int j = block.getMetaFromState(iblockstate); if (iblockstate == this.inTile)
if (block == this.inTile && j == this.inData)
{ {
++this.ticksInGround; ++this.ticksInGround;
@ -383,8 +379,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
this.yTile = blockpos1.getY(); this.yTile = blockpos1.getY();
this.zTile = blockpos1.getZ(); this.zTile = blockpos1.getZ();
State iblockstate1 = this.worldObj.getState(blockpos1); State iblockstate1 = this.worldObj.getState(blockpos1);
this.inTile = iblockstate1.getBlock(); this.inTile = iblockstate1;
this.inData = this.inTile.getMetaFromState(iblockstate1);
this.motionX = (double)((float)(movingobjectposition.vec.xCoord - this.posX)); this.motionX = (double)((float)(movingobjectposition.vec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.vec.yCoord - this.posY)); this.motionY = (double)((float)(movingobjectposition.vec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.vec.zCoord - this.posZ)); this.motionZ = (double)((float)(movingobjectposition.vec.zCoord - this.posZ));
@ -397,9 +392,9 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
this.arrowShake = 7; this.arrowShake = 7;
this.setIsCritical(false); this.setIsCritical(false);
if (this.inTile != Blocks.air) if (this.inTile.getBlock() != Blocks.air)
{ {
this.inTile.onEntityCollidedWithBlock(this.worldObj, blockpos1, iblockstate1, this); this.inTile.getBlock().onEntityCollidedWithBlock(this.worldObj, blockpos1, iblockstate1, this);
} }
} }
} }
@ -478,10 +473,8 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
tagCompound.setShort("zTile", (short)this.zTile); tagCompound.setShort("zTile", (short)this.zTile);
tagCompound.setShort("life", (short)this.ticksInGround); tagCompound.setShort("life", (short)this.ticksInGround);
if(this.inTile != null) { if(this.inTile != null) {
String id = BlockRegistry.getNameFromBlock(this.inTile); tagCompound.setString("inTile", this.inTile.getId());
tagCompound.setString("inTile", id == null ? "" : id.toString());
} }
tagCompound.setByte("inData", (byte)this.inData);
tagCompound.setByte("shake", (byte)this.arrowShake); tagCompound.setByte("shake", (byte)this.arrowShake);
tagCompound.setBool("inGround", this.inGround); tagCompound.setBool("inGround", this.inGround);
tagCompound.setByte("pickup", (byte)this.canBePickedUp); tagCompound.setByte("pickup", (byte)this.canBePickedUp);
@ -500,14 +493,13 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
if (tagCompund.hasString("inTile")) if (tagCompund.hasString("inTile"))
{ {
this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile")); this.inTile = State.getState(tagCompund.getString("inTile"), null);
} }
else else
{ {
this.inTile = null; this.inTile = null;
} }
this.inData = tagCompund.getByte("inData") & 255;
this.arrowShake = tagCompund.getByte("shake") & 255; this.arrowShake = tagCompund.getByte("shake") & 255;
this.inGround = tagCompund.getBool("inGround"); this.inGround = tagCompund.getBool("inGround");

View file

@ -132,14 +132,12 @@ import common.color.DyeColor;
import common.item.CheatTab; import common.item.CheatTab;
import common.log.Log; import common.log.Log;
import common.model.TextureAnimation; import common.model.TextureAnimation;
import common.util.IdMap;
import common.util.Mapping; import common.util.Mapping;
import common.util.Util; import common.util.Util;
import common.world.State; import common.world.State;
public abstract class BlockRegistry { public abstract class BlockRegistry {
public static final Mapping<Block> REGISTRY = new Mapping("air"); public static final Mapping<Block> REGISTRY = new Mapping("air");
public static final IdMap<State> STATEMAP = new IdMap();
private static int nextBlockId = 0; private static int nextBlockId = 0;
@ -147,56 +145,29 @@ public abstract class BlockRegistry {
return REGISTRY.getId(block); return REGISTRY.getId(block);
} }
public static Block getBlockById(int id) {
return REGISTRY.byId(id);
}
public static String getNameFromBlock(Block block) { public static String getNameFromBlock(Block block) {
return REGISTRY.getName(block); return REGISTRY.getName(block);
} }
public static Block getRegisteredBlock(String name) {
return REGISTRY.byName(name);
}
public static int getStateId(State state) { public static int getStateId(State state) {
Block block = state.getBlock(); Block block = state.getBlock();
return getIdFromBlock(block) + (block.getMetaFromState(state) << 12); return getIdFromBlock(block) + (block.getMetaFromState(state) << 12);
} }
public static Block getBlockById(int id) {
return REGISTRY.byId(id);
}
public static State getStateById(int id) { public static State getStateById(int id) {
int i = id & 4095; int i = id & 4095;
int j = id >> 12 & 15; int j = id >> 12 & 15;
return getBlockById(i).getStateFromMeta(j); return getBlockById(i).getStateFromMeta(j);
} }
public static State getFromIdName(String name, State def) {
if(name == null)
return def;
String[] tok = name.split(":");
if(tok.length < 1 || tok.length > 2)
return def;
Block block = REGISTRY.byNameExact(tok[0]);
if(block == null)
return def;
byte data;
if(tok.length == 2) {
try {
int i = Integer.parseUnsignedInt(tok[1]);
if(i >= 16)
return def;
data = (byte)i;
}
catch(NumberFormatException e) {
return def;
}
}
else {
data = (byte)block.getMetaFromState(block.getState());
}
return block.getStateFromMeta(data);
}
public static Block getRegisteredBlock(String name) {
return REGISTRY.byName(name);
}
private static void registerBlock(String name, Block block) { private static void registerBlock(String name, Block block) {
REGISTRY.register(nextBlockId++, name, block); REGISTRY.register(nextBlockId++, name, block);
} }
@ -651,7 +622,7 @@ public abstract class BlockRegistry {
for(Block block : REGISTRY) { for(Block block : REGISTRY) {
for(State state : block.getValidStates()) { for(State state : block.getValidStates()) {
STATEMAP.put(state, REGISTRY.getId(block) << 4 | block.getMetaFromState(state)); state.buildSaved();
} }
} }

View file

@ -93,25 +93,16 @@ public abstract class ItemRegistry {
return item == null ? 0 : REGISTRY.getId(item); return item == null ? 0 : REGISTRY.getId(item);
} }
public static String getNameFromItem(Item item) {
return REGISTRY.getName(item);
}
public static Item getItemById(int id) { public static Item getItemById(int id) {
return REGISTRY.byId(id); return REGISTRY.byId(id);
} }
public static Item getRegisteredItem(String name) { public static String getNameFromItem(Item item) {
return REGISTRY.byName(name); return REGISTRY.getName(item);
} }
public static ItemStack getFromIdName(String name, ItemStack def) { public static Item getRegisteredItem(String name) {
if(name == null) return REGISTRY.byName(name);
return def;
Item item = REGISTRY.byName(name);
if(item == null)
return def;
return new ItemStack(item);
} }
private static void registerItem(String name, Item item) { private static void registerItem(String name, Item item) {

View file

@ -1,6 +1,7 @@
package common.item; package common.item;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -67,6 +68,17 @@ public final class ItemStack
return itemstack.getItem() != null ? itemstack : null; return itemstack.getItem() != null ? itemstack : null;
} }
public static ItemStack getStack(String name, ItemStack def) {
if(name == null)
return def;
Item item = ItemRegistry.REGISTRY.byNameExact(name);
return item == null ? def : new ItemStack(item);
}
public static Collection<String> getKeys() {
return ItemRegistry.REGISTRY.getKeys();
}
private ItemStack() private ItemStack()
{ {
} }

View file

@ -3,7 +3,7 @@ package common.item.block;
import java.util.List; import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.tile.BlockBanner; import common.block.tile.BlockBannerStanding;
import common.block.tile.BlockStandingSign; import common.block.tile.BlockStandingSign;
import common.block.tile.BlockWallSign; import common.block.tile.BlockWallSign;
import common.color.DyeColor; import common.color.DyeColor;
@ -26,9 +26,9 @@ import common.world.World;
public class ItemBanner extends Item public class ItemBanner extends Item
{ {
private final BlockBanner block; private final BlockBannerStanding block;
public ItemBanner(BlockBanner block) public ItemBanner(BlockBannerStanding block)
{ {
this.block = block; this.block = block;
this.setTab(CheatTab.DECORATION); this.setTab(CheatTab.DECORATION);

View file

@ -23,33 +23,21 @@ public class ItemBlock extends Item
{ {
protected final Block block; protected final Block block;
protected final String flatTexture; protected final String flatTexture;
protected final int fixedMeta;
public ItemBlock(Block block, String flatTexture, int fixedMeta)
{
this.block = block;
this.flatTexture = flatTexture;
this.fixedMeta = fixedMeta;
}
public ItemBlock(Block block, int fixedMeta)
{
this(block, null, fixedMeta);
}
public ItemBlock(Block block, String flatTexture) public ItemBlock(Block block, String flatTexture)
{ {
this(block, flatTexture, 0); this.block = block;
this.flatTexture = flatTexture;
} }
public ItemBlock(Block block, String flatTexture, boolean item) public ItemBlock(Block block, String flatTexture, boolean item)
{ {
this(block, (item ? "items" : "blocks") + "/" + flatTexture, 0); this(block, (item ? "items" : "blocks") + "/" + flatTexture);
} }
public ItemBlock(Block block) public ItemBlock(Block block)
{ {
this(block, null, 0); this(block, null);
} }
public ItemBlock setDisplay(String unlocalizedName) public ItemBlock setDisplay(String unlocalizedName)
@ -87,7 +75,7 @@ public class ItemBlock extends Item
} }
else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack)) else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
{ {
State iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, this.fixedMeta, playerIn); State iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, playerIn);
if (worldIn.setState(pos, iblockstate1, 3)) if (worldIn.setState(pos, iblockstate1, 3))
{ {
@ -224,8 +212,8 @@ public class ItemBlock extends Item
public Model getModel(ModelProvider provider, String name) { public Model getModel(ModelProvider provider, String name) {
return this.flatTexture != null ? provider.getModel(this.getTransform(), !this.flatTexture.isEmpty() ? this.flatTexture : return this.flatTexture != null ? provider.getModel(this.getTransform(), !this.flatTexture.isEmpty() ? this.flatTexture :
this.block.getModel(provider, this.block.getModel(provider,
BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.fixedMeta)).getPrimary() /* "blocks/" + name */) : BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getState()).getPrimary() /* "blocks/" + name */) :
provider.getModel(this.block.getModel(provider, provider.getModel(this.block.getModel(provider,
BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.fixedMeta)), this.getTransform()); BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getState()), this.getTransform());
} }
} }

View file

@ -1,12 +1,12 @@
package common.item.block; package common.item.block;
import common.block.Block; import common.block.tech.BlockChest;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.Transforms; import common.model.Transforms;
public class ItemChest extends ItemBlock { public class ItemChest extends ItemBlock {
public ItemChest(Block block) { public ItemChest(BlockChest block) {
super(block); super(block);
} }

View file

@ -1,27 +0,0 @@
package common.item.block;
import common.block.Block;
import common.color.DyeColor;
import common.model.Model;
import common.model.ModelProvider;
public class ItemCloth extends ItemBlock
{
private final DyeColor color;
public ItemCloth(Block block, String flatTexture, DyeColor color)
{
super(block, flatTexture);
this.color = color;
}
public ItemCloth(Block block, DyeColor color)
{
this(block, null, color);
}
public Model getModel(ModelProvider provider, String name) {
return this.flatTexture != null ? provider.getModel(this.getTransform(), "blocks/" + this.color.getName() + "_" +
this.flatTexture) : super.getModel(provider, name);
}
}

View file

@ -10,11 +10,6 @@ public class ItemColored extends ItemBlock
super(block, flatTexture); super(block, flatTexture);
} }
public ItemColored(Block block, int fixedMeta)
{
super(block, fixedMeta);
}
public ItemColored(Block block) public ItemColored(Block block)
{ {
super(block); super(block);

View file

@ -15,9 +15,9 @@ import common.world.World;
public class ItemDoor extends Item public class ItemDoor extends Item
{ {
private Block block; private final BlockDoor block;
public ItemDoor(Block block) public ItemDoor(BlockDoor block)
{ {
this.block = block; this.block = block;
this.setTab(block.getMaterial() == Material.WOOD ? CheatTab.WOOD : CheatTab.TECHNOLOGY); this.setTab(block.getMaterial() == Material.WOOD ? CheatTab.WOOD : CheatTab.TECHNOLOGY);

View file

@ -1,12 +1,11 @@
package common.item.block; package common.item.block;
import common.block.Block;
import common.block.artificial.BlockFence; import common.block.artificial.BlockFence;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
public class ItemFence extends ItemBlock { public class ItemFence extends ItemBlock {
public ItemFence(Block block) { public ItemFence(BlockFence block) {
super(block); super(block);
} }

View file

@ -1,6 +1,5 @@
package common.item.block; package common.item.block;
import common.block.Block;
import common.block.foliage.BlockLilyPad; import common.block.foliage.BlockLilyPad;
import common.block.liquid.BlockLiquid; import common.block.liquid.BlockLiquid;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
@ -13,7 +12,7 @@ import common.world.World;
public class ItemLilyPad extends ItemColored public class ItemLilyPad extends ItemColored
{ {
public ItemLilyPad(Block block) public ItemLilyPad(BlockLilyPad block)
{ {
super(block, ""); super(block, "");
} }

View file

@ -5,6 +5,8 @@ import java.util.Map;
import common.attributes.Attribute; import common.attributes.Attribute;
import common.attributes.UsageSlot; import common.attributes.UsageSlot;
import common.block.Block; import common.block.Block;
import common.block.artificial.BlockMetalBlock;
import common.block.natural.BlockMetalOre;
import common.color.TextColor; import common.color.TextColor;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.MetalType; import common.init.MetalType;
@ -14,7 +16,7 @@ public class ItemMetalBlock extends ItemBlock {
private final MetalType metal; private final MetalType metal;
private final boolean ore; private final boolean ore;
public ItemMetalBlock(Block block, MetalType metal, boolean ore) { private ItemMetalBlock(Block block, MetalType metal, boolean ore) {
super(block); super(block);
this.metal = metal; this.metal = metal;
this.ore = ore; this.ore = ore;
@ -22,6 +24,14 @@ public class ItemMetalBlock extends ItemBlock {
this.setColor(TextColor.GREEN); this.setColor(TextColor.GREEN);
} }
public ItemMetalBlock(BlockMetalBlock block) {
this(block, block.getMetal(), false);
}
public ItemMetalBlock(BlockMetalOre block) {
this(block, block.getMetal(), true);
}
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip) public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{ {
tooltip.add(this.metal.formatSymbol()); tooltip.add(this.metal.formatSymbol());
@ -30,11 +40,6 @@ public class ItemMetalBlock extends ItemBlock {
} }
tooltip.add(this.metal.formatRarity()); tooltip.add(this.metal.formatRarity());
} }
// public ChatFormat getColor(ItemStack stack)
// {
// return this.metal.radioactivity > 0.0f ? ChatFormat.GREEN : super.getColor(stack);
// }
public void getModifiers(Map<Attribute, Float> map, UsageSlot slot) public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
{ {

View file

@ -1,15 +1,15 @@
package common.item.block; package common.item.block;
import common.block.Block; import common.block.tech.BlockPistonBase;
import common.init.Blocks; import common.init.Blocks;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
public class ItemPiston extends ItemBlock public class ItemPiston extends ItemBlock
{ {
public ItemPiston(Block block) public ItemPiston(BlockPistonBase block)
{ {
super(block, 7); super(block);
} }
public boolean isMagnetic() { public boolean isMagnetic() {

View file

@ -1,12 +1,11 @@
package common.item.block; package common.item.block;
import common.block.Block;
import common.block.tech.BlockBasePressurePlate; import common.block.tech.BlockBasePressurePlate;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
public class ItemPressurePlate extends ItemBlock { public class ItemPressurePlate extends ItemBlock {
public ItemPressurePlate(Block block) { public ItemPressurePlate(BlockBasePressurePlate block) {
super(block); super(block);
} }

View file

@ -1,6 +1,7 @@
package common.item.block; package common.item.block;
import common.block.Block; import common.block.Block;
import common.block.foliage.BlockCrops;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.ItemStack; import common.item.ItemStack;
@ -11,16 +12,14 @@ import common.world.World;
public class ItemSeedFood extends ItemFood public class ItemSeedFood extends ItemFood
{ {
private Block crops; private BlockCrops crops;
private Block soil;
/** Block ID of the soil this seed food should be planted on. */ public ItemSeedFood(int healAmount, BlockCrops crops, Block soil)
private Block soilId;
public ItemSeedFood(int healAmount, Block crops, Block soil)
{ {
super(healAmount, false); super(healAmount, false);
this.crops = crops; this.crops = crops;
this.soilId = soil; this.soil = soil;
this.setTab(CheatTab.PLANTS); this.setTab(CheatTab.PLANTS);
} }
@ -42,7 +41,7 @@ public class ItemSeedFood extends ItemFood
{ {
return false; return false;
} }
else if (worldIn.getState(pos).getBlock() == this.soilId && worldIn.isAirBlock(pos.up())) else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up()))
{ {
worldIn.setState(pos.up(), this.crops.getState()); worldIn.setState(pos.up(), this.crops.getState());
--stack.size; --stack.size;

View file

@ -1,6 +1,7 @@
package common.item.block; package common.item.block;
import common.block.Block; import common.block.Block;
import common.block.foliage.BlockBush;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item; import common.item.Item;
@ -12,15 +13,13 @@ import common.world.World;
public class ItemSeeds extends Item public class ItemSeeds extends Item
{ {
private Block crops; private BlockBush crops;
private Block soil;
/** BlockID of the block the seeds can be planted on. */ public ItemSeeds(BlockBush crops, Block soil)
private Block soilBlockID;
public ItemSeeds(Block crops, Block soil)
{ {
this.crops = crops; this.crops = crops;
this.soilBlockID = soil; this.soil = soil;
this.setTab(CheatTab.PLANTS); this.setTab(CheatTab.PLANTS);
} }
@ -42,7 +41,7 @@ public class ItemSeeds extends Item
{ {
return false; return false;
} }
else if (worldIn.getState(pos).getBlock() == this.soilBlockID && worldIn.isAirBlock(pos.up())) else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up()))
{ {
worldIn.setState(pos.up(), this.crops.getState()); worldIn.setState(pos.up(), this.crops.getState());
--stack.size; --stack.size;

View file

@ -1,7 +1,6 @@
package common.item.block; package common.item.block;
import common.block.Block; import common.block.Block;
import common.block.tile.BlockSign;
import common.block.tile.BlockStandingSign; import common.block.tile.BlockStandingSign;
import common.block.tile.BlockWallSign; import common.block.tile.BlockWallSign;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
@ -18,9 +17,9 @@ import common.world.World;
public class ItemSign extends Item public class ItemSign extends Item
{ {
private final BlockSign block; private final BlockStandingSign block;
public ItemSign(BlockSign block) public ItemSign(BlockStandingSign block)
{ {
this.block = block; this.block = block;
this.setTab(CheatTab.DECORATION); this.setTab(CheatTab.DECORATION);
@ -84,17 +83,4 @@ public class ItemSign extends Item
} }
} }
} }
// public Set<String> getValidTags() {
// return Sets.newHashSet("BlockEntityTag");
// }
//
// protected boolean validateNbt(NBTTagCompound tag) {
// if(tag.hasKey("BlockEntityTag")) {
// if(!tag.hasTag("BlockEntityTag")) {
// return false;
// }
// }
// return true;
// }
} }

View file

@ -34,7 +34,7 @@ public class ItemSmallBlock extends Item {
if(!player.canPlayerEdit(pos, side, stack) || stack.size == 0) if(!player.canPlayerEdit(pos, side, stack) || stack.size == 0)
return false; return false;
if(world.canBlockBePlaced(this.block, pos, false, side, null, stack)) { if(world.canBlockBePlaced(this.block, pos, false, side, null, stack)) {
State newState = this.block.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, 0, player); State newState = this.block.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, player);
if(world.setState(pos, newState, 3)) { if(world.setState(pos, newState, 3)) {
newState = world.getState(pos); newState = world.getState(pos);

View file

@ -12,7 +12,7 @@ import common.world.World;
public class ItemSnow extends ItemBlock public class ItemSnow extends ItemBlock
{ {
public ItemSnow(Block block) public ItemSnow(BlockSnow block)
{ {
super(block); super(block);
} }

View file

@ -90,7 +90,7 @@ public class ItemDye extends Item
if (worldIn.isAirBlock(pos)) if (worldIn.isAirBlock(pos))
{ {
State iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn); State iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, playerIn);
worldIn.setState(pos, iblockstate1, 2); worldIn.setState(pos, iblockstate1, 2);
// if (!playerIn.creative) // if (!playerIn.creative)

View file

@ -2,7 +2,6 @@ package common.packet;
import java.io.IOException; import java.io.IOException;
import common.init.BlockRegistry;
import common.network.IClientPlayer; import common.network.IClientPlayer;
import common.network.Packet; import common.network.Packet;
import common.network.PacketBuffer; import common.network.PacketBuffer;
@ -31,7 +30,7 @@ public class SPacketBlockChange implements Packet<IClientPlayer>
public void readPacketData(PacketBuffer buf) throws IOException public void readPacketData(PacketBuffer buf) throws IOException
{ {
this.blockPosition = buf.readBlockPos(); this.blockPosition = buf.readBlockPos();
this.blockState = (State)BlockRegistry.STATEMAP.getByValue(buf.readVarInt()); this.blockState = (State)State.ID_MAP.getByValue(buf.readVarInt());
} }
/** /**
@ -40,7 +39,7 @@ public class SPacketBlockChange implements Packet<IClientPlayer>
public void writePacketData(PacketBuffer buf) throws IOException public void writePacketData(PacketBuffer buf) throws IOException
{ {
buf.writeBlockPos(this.blockPosition); buf.writeBlockPos(this.blockPosition);
buf.writeVarInt(BlockRegistry.STATEMAP.get(this.blockState)); buf.writeVarInt(State.ID_MAP.get(this.blockState));
} }
/** /**

View file

@ -2,7 +2,6 @@ package common.packet;
import java.io.IOException; import java.io.IOException;
import common.init.BlockRegistry;
import common.network.IClientPlayer; import common.network.IClientPlayer;
import common.network.Packet; import common.network.Packet;
import common.network.PacketBuffer; import common.network.PacketBuffer;
@ -39,7 +38,7 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
for (int i = 0; i < this.changedBlocks.length; ++i) for (int i = 0; i < this.changedBlocks.length; ++i)
{ {
this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), (State)BlockRegistry.STATEMAP.getByValue(buf.readVarInt())); this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), (State)State.ID_MAP.getByValue(buf.readVarInt()));
} }
} }
@ -55,7 +54,7 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
for (SPacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : this.changedBlocks) for (SPacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : this.changedBlocks)
{ {
buf.writeLong(s22packetmultiblockchange$blockupdatedata.getRawPos()); buf.writeLong(s22packetmultiblockchange$blockupdatedata.getRawPos());
buf.writeVarInt(BlockRegistry.STATEMAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState())); buf.writeVarInt(State.ID_MAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState()));
} }
} }

View file

@ -4,7 +4,6 @@ import java.util.List;
import common.collect.Lists; import common.collect.Lists;
import common.entity.Entity; import common.entity.Entity;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.tags.TagObject; import common.tags.TagObject;
import common.util.BoundingBox; import common.util.BoundingBox;
@ -201,7 +200,7 @@ public class TileEntityPiston extends TileEntity implements ITickable
public void readTags(TagObject compound) public void readTags(TagObject compound)
{ {
super.readTags(compound); super.readTags(compound);
this.pistonState = BlockRegistry.getRegisteredBlock(compound.getString("blockId")).getStateFromMeta(compound.getInt("blockData")); this.pistonState = State.getState(compound.getString("block"), Blocks.air.getState());
this.pistonFacing = Facing.getFront(compound.getInt("facing")); this.pistonFacing = Facing.getFront(compound.getInt("facing"));
this.lastProgress = this.progress = compound.getFloat("progress"); this.lastProgress = this.progress = compound.getFloat("progress");
this.extending = compound.getBool("extending"); this.extending = compound.getBool("extending");
@ -210,8 +209,7 @@ public class TileEntityPiston extends TileEntity implements ITickable
public void writeTags(TagObject compound) public void writeTags(TagObject compound)
{ {
super.writeTags(compound); super.writeTags(compound);
compound.setString("blockId", BlockRegistry.getNameFromBlock(this.pistonState.getBlock())); compound.setString("block", this.pistonState.getId());
compound.setInt("blockData", this.pistonState.getBlock().getMetaFromState(this.pistonState));
compound.setInt("facing", this.pistonFacing.getIndex()); compound.setInt("facing", this.pistonFacing.getIndex());
compound.setFloat("progress", this.lastProgress); compound.setFloat("progress", this.lastProgress);
compound.setBool("extending", this.extending); compound.setBool("extending", this.extending);

View file

@ -3,7 +3,6 @@ package common.world;
import java.util.Arrays; import java.util.Arrays;
import common.block.Block; import common.block.Block;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.util.NibbleArray; import common.util.NibbleArray;
@ -22,14 +21,14 @@ public class BlockArray {
if(sky) if(sky)
this.skylight = new NibbleArray(); this.skylight = new NibbleArray();
if(filler != null && filler.getBlock() != Blocks.air) { if(filler != null && filler.getBlock() != Blocks.air) {
Arrays.fill(this.data, (char)BlockRegistry.STATEMAP.get(filler)); Arrays.fill(this.data, (char)State.ID_MAP.get(filler));
this.blocks = this.data.length; this.blocks = this.data.length;
this.ticked = filler.getBlock().getTickRandomly() ? this.data.length : 0; this.ticked = filler.getBlock().getTickRandomly() ? this.data.length : 0;
} }
} }
public State get(int x, int y, int z) { public State get(int x, int y, int z) {
State iblockstate = BlockRegistry.STATEMAP.getByValue(this.data[y << 8 | z << 4 | x]); State iblockstate = State.ID_MAP.getByValue(this.data[y << 8 | z << 4 | x]);
return iblockstate != null ? iblockstate : Blocks.air.getState(); return iblockstate != null ? iblockstate : Blocks.air.getState();
} }
@ -47,18 +46,13 @@ public class BlockArray {
if(block.getTickRandomly()) if(block.getTickRandomly())
++this.ticked; ++this.ticked;
} }
this.data[y << 8 | z << 4 | x] = (char)BlockRegistry.STATEMAP.get(state); this.data[y << 8 | z << 4 | x] = (char)State.ID_MAP.get(state);
} }
public Block getBlock(int x, int y, int z) { public Block getBlock(int x, int y, int z) {
return this.get(x, y, z).getBlock(); return this.get(x, y, z).getBlock();
} }
public int getMeta(int x, int y, int z) {
State state = this.get(x, y, z);
return state.getBlock().getMetaFromState(state);
}
public boolean isEmpty() { public boolean isEmpty() {
return this.blocks == 0; return this.blocks == 0;
} }

View file

@ -4,21 +4,24 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.function.Function; import java.util.function.Function;
import common.block.Block; import common.block.Block;
import common.collect.ImmutableMap; import common.collect.ImmutableMap;
import common.collect.ImmutableSet;
import common.collect.ImmutableTable; import common.collect.ImmutableTable;
import common.collect.Iterables; import common.collect.Iterables;
import common.collect.Maps; import common.collect.Maps;
import common.collect.Sets;
import common.collect.StandardTable; import common.collect.StandardTable;
import common.collect.Table; import common.collect.Table;
import common.init.BlockRegistry; import common.init.BlockRegistry;
import common.properties.Property; import common.properties.Property;
import common.util.IdMap;
public class State { public class State {
// private static final Joiner COMMA_JOINER = Joiner.on(',');
private static final Function<Entry<Property, Comparable>, String> MAP_ENTRY_TO_STRING = private static final Function<Entry<Property, Comparable>, String> MAP_ENTRY_TO_STRING =
new Function<Entry<Property, Comparable>, String>() { new Function<Entry<Property, Comparable>, String>() {
public String apply(Entry<Property, Comparable> entry) { public String apply(Entry<Property, Comparable> entry) {
@ -31,10 +34,68 @@ public class State {
} }
} }
}; };
private static final Map<String, State> NAME_MAP = Maps.newLinkedHashMap();
public static final IdMap<State> ID_MAP = new IdMap();
private final Block block; private final Block block;
private final ImmutableMap<Property, Comparable> properties; private final ImmutableMap<Property, Comparable> properties;
private ImmutableTable<Property, Comparable, State> map; private ImmutableTable<Property, Comparable, State> map;
private ImmutableSet<Property> saved;
private String id;
private static Set<Property> getSavedProperties(Block block) {
Set<Property> stored = Sets.newHashSet();
Map<Property, Comparable> map = Maps.newHashMap();
for(int z = 0; z < 16; z++) {
State sub = block.getStateFromMeta(z);
for(Entry<Property, Comparable> entry : sub.getProperties().entrySet()) {
if(map.containsKey(entry.getKey())) {
if(!map.get(entry.getKey()).equals(entry.getValue()))
stored.add(entry.getKey());
}
else {
map.put(entry.getKey(), entry.getValue());
}
}
}
for(int z = 0; z < 16; z++) {
State sub = block.getStateFromMeta(z);
Map<Property, Comparable> smap = sub.getProperties();
for(Property prop : map.keySet()) {
if(!smap.containsKey(prop))
stored.add(prop);
}
}
return stored;
}
private static String filterProperties(State state, Set<Property> stored) {
StringBuilder sb = new StringBuilder(BlockRegistry.getNameFromBlock(state.getBlock()));
for(Entry<Property, Comparable> entry : state.getProperties().entrySet()) {
if(stored.contains(entry.getKey()))
sb.append(',').append(entry.getKey().getName()).append('=').append(entry.getKey().getName(entry.getValue()));
}
return sb.toString();
}
public static State getState(String name, State def) {
if(name == null)
return def;
State state = NAME_MAP.get(name);
if(state != null)
return state;
int idx = name.indexOf(",");
if(idx >= 0) {
Block block = BlockRegistry.REGISTRY.byNameExact(name.substring(0, idx));
if(block != null)
return block.getState();
}
return def;
}
public static Collection<String> getKeys() {
return NAME_MAP.keySet();
}
public State(Block block, ImmutableMap<Property, Comparable> properties) { public State(Block block, ImmutableMap<Property, Comparable> properties) {
this.block = block; this.block = block;
@ -58,6 +119,14 @@ public class State {
public Collection<Property> getPropertyNames() { public Collection<Property> getPropertyNames() {
return Collections.<Property>unmodifiableCollection(this.properties.keySet()); return Collections.<Property>unmodifiableCollection(this.properties.keySet());
} }
public Collection<Property> getSavedProperties() {
return this.saved;
}
public String getId() {
return this.id;
}
public <T extends Comparable<T>> T getValue(Property<T> property) { public <T extends Comparable<T>> T getValue(Property<T> property) {
if(!this.properties.containsKey(property)) { if(!this.properties.containsKey(property)) {
@ -118,21 +187,26 @@ public class State {
} }
public void buildTable(Map<Map<Property, Comparable>, State> map) { public void buildTable(Map<Map<Property, Comparable>, State> map) {
if(this.map != null) { if(this.map != null)
throw new IllegalStateException(); throw new IllegalStateException();
} Table<Property, Comparable, State> table = new StandardTable<Property, Comparable, State>();
else { for(Property<? extends Comparable> prop : this.properties.keySet()) {
Table<Property, Comparable, State> table = new StandardTable<Property, Comparable, State>(); for(Comparable value : prop.getStates()) {
for(Property<? extends Comparable> prop : this.properties.keySet()) { if(value != this.properties.get(prop)) {
for(Comparable value : prop.getStates()) { Map<Property, Comparable> props = Maps.<Property, Comparable>newHashMap(this.properties);
if(value != this.properties.get(prop)) { props.put(prop, value);
Map<Property, Comparable> props = Maps.<Property, Comparable>newHashMap(this.properties); table.put(prop, value, map.get(props));
props.put(prop, value);
table.put(prop, value, map.get(props));
}
} }
} }
this.map = ImmutableTable.<Property, Comparable, State>copyOf(table);
} }
this.map = ImmutableTable.<Property, Comparable, State>copyOf(table);
}
public void buildSaved() {
if(this.saved != null)
throw new IllegalStateException();
ID_MAP.put(this, BlockRegistry.getIdFromBlock(this.block) << 4 | this.block.getMetaFromState(this));
this.saved = ImmutableSet.copyOf(getSavedProperties(this.block));
NAME_MAP.put(this.id = filterProperties(this, this.saved), this);
} }
} }

View file

@ -1,7 +1,6 @@
package server.command.commands; package server.command.commands;
import java.util.Collection; import java.util.Collection;
import common.init.BlockRegistry;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.util.BlockPos; import common.util.BlockPos;
@ -19,7 +18,7 @@ public class CommandBlock extends Command {
this.addString("block", false, new StringCompleter() { this.addString("block", false, new StringCompleter() {
public Collection<String> complete(CommandEnvironment env) { public Collection<String> complete(CommandEnvironment env) {
return BlockRegistry.REGISTRY.getKeys(); return State.getKeys();
} }
}); });
this.addBlockPos("position", true); this.addBlockPos("position", true);
@ -30,7 +29,7 @@ public class CommandBlock extends Command {
} }
public Object exec(CommandEnvironment env, Executor exec, String block, BlockPos position, WorldServer world, TagObject tag) { public Object exec(CommandEnvironment env, Executor exec, String block, BlockPos position, WorldServer world, TagObject tag) {
State state = BlockRegistry.getFromIdName(block, null); State state = State.getState(block, null);
if(state == null) if(state == null)
throw new RunException("Block '%s' existiert nicht", block); throw new RunException("Block '%s' existiert nicht", block);
boolean success = world.setState(position, state); boolean success = world.setState(position, state);

View file

@ -4,7 +4,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.ItemRegistry;
import common.item.ItemStack; import common.item.ItemStack;
import common.tags.TagObject; import common.tags.TagObject;
import server.command.Command; import server.command.Command;
@ -20,7 +19,7 @@ public class CommandItem extends Command {
this.addString("item", false, new StringCompleter() { this.addString("item", false, new StringCompleter() {
public Collection<String> complete(CommandEnvironment env) { public Collection<String> complete(CommandEnvironment env) {
return ItemRegistry.REGISTRY.getKeys(); return ItemStack.getKeys();
} }
}); });
this.setParamsOptional(); this.setParamsOptional();
@ -31,7 +30,7 @@ public class CommandItem extends Command {
} }
public Object exec(CommandEnvironment env, Executor exec, String item, int amount, TagObject tag, List<EntityNPC> players) { public Object exec(CommandEnvironment env, Executor exec, String item, int amount, TagObject tag, List<EntityNPC> players) {
ItemStack stack = ItemRegistry.getFromIdName(item, null); ItemStack stack = ItemStack.getStack(item, null);
if(stack == null) if(stack == null)
throw new RunException("Gegenstand '%s' existiert nicht", item); throw new RunException("Gegenstand '%s' existiert nicht", item);
stack.setTagCompound(tag); stack.setTagCompound(tag);

View file

@ -5,7 +5,6 @@ import java.util.Set;
import common.biome.Biome; import common.biome.Biome;
import common.block.Block; import common.block.Block;
import common.entity.Entity; import common.entity.Entity;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.log.Log; import common.log.Log;
import common.rng.Random; import common.rng.Random;
@ -31,7 +30,7 @@ public class ChunkServer extends Chunk {
for(int bx = 0; bx < 16; ++bx) { for(int bx = 0; bx < 16; ++bx) {
for(int bz = 0; bz < 16; ++bz) { for(int bz = 0; bz < 16; ++bz) {
for(int by = 0; by < height; ++by) { for(int by = 0; by < height; ++by) {
State state = BlockRegistry.STATEMAP.getByValue(data[bx << 4 | bz | by << 8]); State state = State.ID_MAP.getByValue(data[bx << 4 | bz | by << 8]);
if(state != null && state.getBlock() != Blocks.air) { if(state != null && state.getBlock() != Blocks.air) {
int y = by >> 4; int y = by >> 4;
BlockArray arr = this.getArray(y); BlockArray arr = this.getArray(y);

View file

@ -51,7 +51,6 @@ import common.entity.animal.EntitySquid;
import common.entity.animal.EntityWolf; import common.entity.animal.EntityWolf;
import common.entity.item.EntityBoat; import common.entity.item.EntityBoat;
import common.entity.item.EntityMinecart; import common.entity.item.EntityMinecart;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.TileRegistry; import common.init.TileRegistry;
@ -272,7 +271,7 @@ public abstract class Converter {
} }
private static void mapBlock(State state, int id, int data) { private static void mapBlock(State state, int id, int data) {
BLOCK_MAP[(id << 4) | data] = (char)BlockRegistry.STATEMAP.get(state); BLOCK_MAP[(id << 4) | data] = (char)State.ID_MAP.get(state);
} }
private static void mapBlock(State state, int id) { private static void mapBlock(State state, int id) {

View file

@ -28,7 +28,6 @@ import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.log.Log; import common.log.Log;
import common.properties.Property;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.util.BlockPos; import common.util.BlockPos;
@ -38,41 +37,6 @@ import common.world.BlockArray;
import common.world.State; import common.world.State;
public class Region { public class Region {
private static Set<Property> getSavedProperties(Block block) {
Set<Property> stored = Sets.newHashSet();
Map<Property, Comparable> map = Maps.newHashMap();
for(int z = 0; z < 16; z++) {
State sub = block.getStateFromMeta(z);
for(Entry<Property, Comparable> entry : sub.getProperties().entrySet()) {
if(map.containsKey(entry.getKey())) {
if(!map.get(entry.getKey()).equals(entry.getValue()))
stored.add(entry.getKey());
}
else {
map.put(entry.getKey(), entry.getValue());
}
}
}
for(int z = 0; z < 16; z++) {
State sub = block.getStateFromMeta(z);
Map<Property, Comparable> smap = sub.getProperties();
for(Property prop : map.keySet()) {
if(!smap.containsKey(prop))
stored.add(prop);
}
}
return stored;
}
private static String filterProperties(State state, Set<Property> stored) {
StringBuilder sb = new StringBuilder(BlockRegistry.getNameFromBlock(state.getBlock()));
for(Entry<Property, Comparable> entry : state.getProperties().entrySet()) {
if(stored.contains(entry.getKey()))
sb.append(',').append(entry.getKey().getName()).append('=').append(entry.getKey().getName(entry.getValue()));
}
return sb.toString();
}
private static boolean makeMap(TagObject tag) { private static boolean makeMap(TagObject tag) {
Set<String> removed = Sets.newHashSet(); Set<String> removed = Sets.newHashSet();
for(String id : tag.keySet()) { for(String id : tag.keySet()) {
@ -86,12 +50,11 @@ public class Region {
for(int z = 0; z < 4096; z++) { for(int z = 0; z < 4096; z++) {
Block block = BlockRegistry.getBlockById(z); Block block = BlockRegistry.getBlockById(z);
if(block != Blocks.air) { if(block != Blocks.air) {
Set<Property> stored = getSavedProperties(block);
for(int n = 0; n < 16; n++) { for(int n = 0; n < 16; n++) {
State state = block.getStateFromMeta(n); State state = block.getStateFromMeta(n);
String id = filterProperties(state, stored); String id = state.getId();
List<Character> ids = current.get(id); List<Character> ids = current.get(id);
char mid = (char)BlockRegistry.STATEMAP.get(state); char mid = (char)State.ID_MAP.get(state);
if(ids == null) { if(ids == null) {
current.put(id, Lists.newArrayList(mid)); current.put(id, Lists.newArrayList(mid));
} }

View file

@ -1,6 +1,5 @@
package server.worldgen; package server.worldgen;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.world.State; import common.world.State;
@ -18,11 +17,11 @@ public class ChunkPrimer {
} }
public State get(int x, int y, int z) { public State get(int x, int y, int z) {
State state = BlockRegistry.STATEMAP.getByValue(this.data[x << 4 | z | y << 8]); State state = State.ID_MAP.getByValue(this.data[x << 4 | z | y << 8]);
return state != null ? state : Blocks.air.getState(); return state != null ? state : Blocks.air.getState();
} }
public void set(int x, int y, int z, State state) { public void set(int x, int y, int z, State state) {
this.data[x << 4 | z | y << 8] = (short)BlockRegistry.STATEMAP.get(state); this.data[x << 4 | z | y << 8] = (short)State.ID_MAP.get(state);
} }
} }

View file

@ -4,9 +4,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import common.biome.Biome; import common.biome.Biome;
import common.block.Block;
import common.block.artificial.BlockSlab; import common.block.artificial.BlockSlab;
import common.block.artificial.BlockStairs; import common.block.artificial.BlockStairs;
import common.block.foliage.BlockCrops;
import common.block.foliage.BlockLog; import common.block.foliage.BlockLog;
import common.block.tech.BlockTorch; import common.block.tech.BlockTorch;
import common.collect.Lists; import common.collect.Lists;
@ -381,10 +381,10 @@ public class StructureVillage
public static class Field1 extends StructureVillage.Village public static class Field1 extends StructureVillage.Village
{ {
private Block cropTypeA; private BlockCrops cropTypeA;
private Block cropTypeB; private BlockCrops cropTypeB;
private Block cropTypeC; private BlockCrops cropTypeC;
private Block cropTypeD; private BlockCrops cropTypeD;
public Field1() public Field1()
{ {
@ -413,13 +413,13 @@ public class StructureVillage
protected void readTags(TagObject tagCompound) protected void readTags(TagObject tagCompound)
{ {
super.readTags(tagCompound); super.readTags(tagCompound);
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")); this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat;
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")); this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat;
this.cropTypeC = BlockRegistry.getRegisteredBlock(tagCompound.getString("CC")); this.cropTypeC = BlockRegistry.getRegisteredBlock(tagCompound.getString("CC")) instanceof BlockCrops crops ? crops : Blocks.wheat;
this.cropTypeD = BlockRegistry.getRegisteredBlock(tagCompound.getString("CD")); this.cropTypeD = BlockRegistry.getRegisteredBlock(tagCompound.getString("CD")) instanceof BlockCrops crops ? crops : Blocks.wheat;
} }
private Block func_151559_a(Random rand) private BlockCrops func_151559_a(Random rand)
{ {
switch (rand.zrange(5)) switch (rand.zrange(5))
{ {
@ -469,14 +469,14 @@ public class StructureVillage
for (int i = 1; i <= 7; ++i) for (int i = 1; i <= 7; ++i)
{ {
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeC.getStateFromMeta(randomIn.range(2, 7)), 7, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeC.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 7, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeC.getStateFromMeta(randomIn.range(2, 7)), 8, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeC.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 8, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeD.getStateFromMeta(randomIn.range(2, 7)), 10, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeD.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 10, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeD.getStateFromMeta(randomIn.range(2, 7)), 11, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeD.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 11, 1, i, structureBoundingBoxIn);
} }
for (int k = 0; k < 9; ++k) for (int k = 0; k < 9; ++k)
@ -494,8 +494,8 @@ public class StructureVillage
public static class Field2 extends StructureVillage.Village public static class Field2 extends StructureVillage.Village
{ {
private Block cropTypeA; private BlockCrops cropTypeA;
private Block cropTypeB; private BlockCrops cropTypeB;
public Field2() public Field2()
{ {
@ -520,11 +520,11 @@ public class StructureVillage
protected void readTags(TagObject tagCompound) protected void readTags(TagObject tagCompound)
{ {
super.readTags(tagCompound); super.readTags(tagCompound);
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")); this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat;
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")); this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat;
} }
private Block func_151560_a(Random rand) private BlockCrops func_151560_a(Random rand)
{ {
switch (rand.zrange(5)) switch (rand.zrange(5))
{ {
@ -570,10 +570,10 @@ public class StructureVillage
for (int i = 1; i <= 7; ++i) for (int i = 1; i <= 7; ++i)
{ {
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn); this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn);
} }
for (int k = 0; k < 9; ++k) for (int k = 0; k < 9; ++k)