remove block metadata T2

This commit is contained in:
Sen 2025-06-27 18:04:17 +02:00
parent 2919d99126
commit 3db0dca073
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
77 changed files with 51 additions and 934 deletions

View file

@ -1930,7 +1930,7 @@ public class Client implements IThreadListener {
String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ())
);
for(Entry<Property, Comparable> entry : block.getProperties().entrySet()) {
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()));
str.append("\n" + (block.getBlock().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();

View file

@ -9,6 +9,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.Map.Entry;
import java.util.function.Function;
import common.block.artificial.BlockSlab;
@ -17,6 +19,7 @@ import common.collect.ImmutableMap;
import common.collect.Iterables;
import common.collect.Lists;
import common.collect.Maps;
import common.collect.Sets;
import common.collect.UnmodifiableIterator;
import common.enchantment.EnchantmentHelper;
import common.entity.Entity;
@ -43,6 +46,7 @@ import common.util.Facing;
import common.util.HitPosition;
import common.util.Vec3;
import common.util.HitPosition.ObjectType;
import common.util.Pair;
import common.vars.Vars;
import common.world.Explosion;
import common.world.IBlockAccess;
@ -289,6 +293,24 @@ public class Block {
}
return ImmutableList.<State>copyOf(list);
}
private static ImmutableList<State> getStateList(ImmutableList<Property> saved, ImmutableList<State> states) {
Set<List<Pair<Property, Comparable>>> uniq = Sets.newHashSet();
List<State> list = Lists.<State>newArrayList();
for(State state : states) {
List<Pair<Property, Comparable>> props = Lists.newArrayList();
for(Entry<Property, Comparable> entry : state.getProperties().entrySet()) {
if(saved.contains(entry.getKey()))
props.add(new Pair(entry.getKey(), entry.getValue()));
}
if(!uniq.contains(props)) {
uniq.add(props);
list.add(state);
}
}
uniq.clear();
return ImmutableList.<State>copyOf(list);
}
public Block(Material material) {
this.miningLevel = (material == Material.SOLID || material == Material.HEAVY) ? 0 : -1;
@ -306,7 +328,7 @@ public class Block {
this.states = getStateList(this.properties, this);
this.setDefaultState(this.getBaseState());
this.savedProps = getPropertyList(this.getProperties(), this.getUnsavedProperties());
this.saved = getStateList(this.savedProps, this);
this.saved = getStateList(this.savedProps, this.states);
}
public Block setStepSound(SoundType sound) {
@ -429,7 +451,7 @@ public class Block {
return this.states.get(0);
}
public Collection<Property> getPropertyMap() {
public Collection<Property> getSavedProperties() {
return this.savedProps;
}
@ -437,15 +459,6 @@ public class Block {
return this.getState();
}
public int getMetaFromState(State state) {
if(state != null && !state.getPropertyNames().isEmpty()) {
throw new IllegalArgumentException("Don\'t know how to convert " + state + " back into data...");
}
else {
return 0;
}
}
public State getActualState(State state, IWorldAccess worldIn, BlockPos pos) {
return state;
}

View file

@ -185,10 +185,6 @@ public class BlockBed extends Block implements Rotatable {
.withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state) {
return ((Facing)state.getValue(FACING)).getHorizontalIndex() | (state.getValue(PART) == BlockBed.EnumPartType.HEAD ? 8 : 0);
}
protected Property[] getProperties() {
return new Property[] {FACING, PART};
}

View file

@ -222,14 +222,6 @@ public class BlockCake extends Block
return this.getState().withProperty(BITES, Integer.valueOf(meta > 6 ? 0 : meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(BITES)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {BITES};

View file

@ -378,40 +378,6 @@ public class BlockDoor extends Block implements Rotatable
return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, Facing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
{
i = i | 8;
if (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT)
{
i |= 1;
}
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 2;
}
}
else
{
i = i | ((Facing)state.getValue(FACING)).rotateY().getHorizontalIndex();
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
i |= 4;
}
}
return i;
}
protected static int removeHalfBit(int meta)
{
return meta & 7;

View file

@ -181,14 +181,6 @@ public class BlockFence extends Block
return worldIn.client ? true : ItemLead.attachToFence(playerIn, worldIn, pos);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return 0;
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.

View file

@ -179,27 +179,6 @@ public class BlockFenceGate extends Block implements Rotatable
return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(POWERED, Boolean.valueOf((meta & 8) != 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
i |= 4;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, OPEN, POWERED, IN_WALL};

View file

@ -41,26 +41,6 @@ public class BlockHay extends BlockRotatedPillar
return this.getState().withProperty(AXIS, enumfacing$axis);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
Facing.Axis enumfacing$axis = (Facing.Axis)state.getValue(AXIS);
if (enumfacing$axis == Facing.Axis.X)
{
i |= 4;
}
else if (enumfacing$axis == Facing.Axis.Z)
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {AXIS};

View file

@ -151,14 +151,6 @@ public class BlockLadder extends Block implements Rotatable
return this.getState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -195,14 +195,6 @@ public class BlockPane extends Block
return BlockLayer.CUTOUT_MIPPED;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return 0;
}
protected Property[] getProperties()
{
return new Property[] {NORTH, EAST, WEST, SOUTH};

View file

@ -19,7 +19,6 @@ import common.rng.Random;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.Facing.Axis;
import common.world.IWorldAccess;
import common.world.AWorldClient;
import common.world.State;
@ -269,14 +268,6 @@ public class BlockPortal extends Block
.withProperty(DIM, meta & 7);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return (state.getValue(AXIS) == Axis.Z ? 8 : 0) | state.getValue(DIM);
}
protected Property[] getProperties()
{
return new Property[] {AXIS, DIM};

View file

@ -115,22 +115,6 @@ public class BlockPortalFrame extends Block implements Rotatable
return this.getState().withProperty(ORB, Boolean.valueOf((meta & 4) != 0)).withProperty(FACING, Facing.getHorizontal(meta & 3));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
if (((Boolean)state.getValue(ORB)).booleanValue())
{
i |= 4;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, ORB};

View file

@ -52,21 +52,6 @@ public class BlockQuartzPillar extends BlockRotatedPillar
return state;
}
public int getMetaFromState(State state)
{
int meta = 0;
switch (state.getValue(AXIS))
{
case X:
meta = 1;
break;
case Z:
meta = 2;
break;
}
return meta;
}
protected Property[] getProperties()
{
return new Property[] {AXIS};

View file

@ -38,10 +38,6 @@ public class BlockSkull extends Block implements Rotatable {
return this.getState().withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state) {
return state.getValue(FACING).getHorizontalIndex();
}
protected Property[] getProperties() {
return new Property[] {FACING};
}

View file

@ -63,14 +63,6 @@ public class BlockSlab extends Block implements Directional
.withProperty(FACING, (meta == 0 || meta >= 6) ? Facing.DOWN :
(meta == 1 ? Facing.UP : Facing.getHorizontal(meta - 2)));
}
public int getMetaFromState(State state)
{
if(state.getValue(DOUBLE))
return state.getValue(SEAMLESS) ? 7 : 6;
Facing dir = state.getValue(FACING);
return dir == Facing.DOWN ? 0 : (dir == Facing.UP ? 1 : (dir.getHorizontalIndex() + 2));
}
protected Property[] getProperties()
{

View file

@ -746,22 +746,6 @@ public class BlockStairs extends Block implements Rotatable
return iblockstate;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
if (state.getValue(HALF) == BlockStairs.EnumHalf.TOP)
{
i |= 4;
}
i = i | 5 - ((Facing)state.getValue(FACING)).getIndex();
return i;
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.

View file

@ -265,27 +265,6 @@ public class BlockTrapDoor extends Block implements Rotatable
return this.getState().withProperty(FACING, getFacing(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(HALF, (meta & 8) == 0 ? BlockTrapDoor.DoorHalf.BOTTOM : BlockTrapDoor.DoorHalf.TOP);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | getMetaForFacing((Facing)state.getValue(FACING));
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
i |= 4;
}
if (state.getValue(HALF) == BlockTrapDoor.DoorHalf.TOP)
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, OPEN, HALF};

View file

@ -142,10 +142,6 @@ public class BlockWall extends Block
return state.withProperty(UP, Boolean.valueOf(worldIn.getState(pos.up()).getBlock() != Blocks.air)).withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west())));
}
public int getMetaFromState(State state) {
return 0;
}
protected Property[] getProperties()
{
return new Property[] {UP, NORTH, EAST, WEST, SOUTH};

View file

@ -153,14 +153,6 @@ public class BlockCactus extends Block
return this.getState().withProperty(AGE, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {AGE};

View file

@ -208,17 +208,6 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable
return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(AGE, Integer.valueOf((meta & 12) == 12 ? 0 : ((meta & 12) >> 2)));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
i = i | ((Integer)state.getValue(AGE)).intValue() << 2;
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, AGE};

View file

@ -210,14 +210,6 @@ public class BlockCrops extends BlockBush implements IGrowable
return this.getState().withProperty(AGE, Integer.valueOf(meta > 7 ? 0 : meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {AGE};

View file

@ -1,7 +1,6 @@
package common.block.foliage;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.block.SoundType;
import common.color.Colorizer;
@ -20,7 +19,6 @@ import common.properties.PropertyEnum;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Identifyable;
import common.util.Facing.Axis;
import common.vars.Vars;
@ -266,14 +264,6 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 : 0;
}
protected Property[] getProperties()
{
return new Property[] {HALF};

View file

@ -164,14 +164,6 @@ public class BlockFarmland extends Block
return this.getState().withProperty(MOISTURE, Integer.valueOf(meta & 7));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(MOISTURE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {MOISTURE};

View file

@ -124,14 +124,6 @@ public class BlockGrass extends Block implements IGrowable
return BlockLayer.CUTOUT_MIPPED;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return 0;
}
protected Property[] getProperties()
{
return new Property[] {SNOWY};

View file

@ -87,14 +87,6 @@ public class BlockHugeMushroom extends Block
return this.getState().withProperty(VARIANT, BlockHugeMushroom.EnumType.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata();
}
protected Property[] getProperties()
{
return new Property[] {VARIANT};

View file

@ -308,16 +308,6 @@ public class BlockLeaves extends BlockLeavesBase
return this.getState().withProperty(DECAY, Boolean.valueOf((meta & 8) == 0));
}
public int getMetaFromState(State state) {
int i = 0;
if(!((Boolean)state.getValue(DECAY)).booleanValue()) {
i |= 8;
}
return i;
}
protected Property[] getProperties() {
return new Property[] {DECAY};
}

View file

@ -91,11 +91,6 @@ public class BlockLilyPad extends BlockBush implements Rotatable
{
return this.getState().withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getHorizontalIndex();
}
protected Property[] getProperties()
{

View file

@ -89,24 +89,6 @@ public class BlockLog extends BlockRotatedPillar
return state;
}
public int getMetaFromState(State state)
{
int meta = 0;
switch ((Facing.Axis)state.getValue(AXIS))
{
case X:
meta = 1;
break;
case Z:
meta = 2;
break;
}
return meta;
}
protected Property[] getProperties()
{
return new Property[] {AXIS};

View file

@ -87,14 +87,6 @@ public class BlockMycelium extends Block
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return 0;
}
protected Property[] getProperties()
{
return new Property[] {SNOWY};

View file

@ -33,10 +33,6 @@ public class BlockPumpkin extends Block implements Rotatable {
return this.getState().withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state) {
return state.getValue(FACING).getHorizontalIndex();
}
protected Property[] getProperties() {
return new Property[] {FACING};
}

View file

@ -173,14 +173,6 @@ public class BlockReed extends Block
return this.getState().withProperty(AGE, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {AGE};

View file

@ -122,17 +122,6 @@ public class BlockSapling extends BlockBush implements IGrowable
return this.getState() /* .withProperty(TYPE, BlockPlanks.EnumType.byMetadata(meta & 7)) */ .withProperty(STAGE, meta & 1);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
// int i = 0;
// i = i | ((BlockPlanks.EnumType)state.getValue(TYPE)).getMetadata();
// i = i | ((Integer)state.getValue(STAGE)).intValue() << 3;
return state.getValue(STAGE);
}
protected Property[] getProperties()
{
return new Property[] {STAGE};

View file

@ -221,14 +221,6 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable
return this.getState().withProperty(AGE, Integer.valueOf(meta > 7 ? 0 : meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {AGE, FACING};

View file

@ -36,11 +36,6 @@ public class BlockTianSoil extends Block
return Blocks.tian.getItemDropped(Blocks.tian.getState(), rand, fortune);
}
public int getMetaFromState(State state)
{
return 0;
}
protected Property[] getProperties()
{
return new Property[] {SNOWY};

View file

@ -449,36 +449,6 @@ public class BlockVine extends Block
return this.getState().withProperty(SOUTH, Boolean.valueOf((meta & 1) > 0)).withProperty(WEST, Boolean.valueOf((meta & 2) > 0)).withProperty(NORTH, Boolean.valueOf((meta & 4) > 0)).withProperty(EAST, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
if (((Boolean)state.getValue(SOUTH)).booleanValue())
{
i |= 1;
}
if (((Boolean)state.getValue(WEST)).booleanValue())
{
i |= 2;
}
if (((Boolean)state.getValue(NORTH)).booleanValue())
{
i |= 4;
}
if (((Boolean)state.getValue(EAST)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {UP, NORTH, EAST, SOUTH, WEST};

View file

@ -116,14 +116,6 @@ public class BlockWart extends BlockBush
return this.getState().withProperty(AGE, Integer.valueOf(meta > 3 ? 0 : meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {AGE};

View file

@ -386,14 +386,6 @@ public abstract class BlockLiquid extends Block
return this.getState().withProperty(LEVEL, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(LEVEL)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {LEVEL};

View file

@ -445,14 +445,6 @@ public class BlockFire extends Block
return this.getState().withProperty(AGE, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER, FLIP, ALT};

View file

@ -66,7 +66,7 @@ public class BlockOre extends Block
public int quantityDroppedWithBonus(int fortune, Random random)
{
if (fortune > 0 &&
this.getItem() != this.getItemDropped((State)this.getValidStates().iterator().next(), random, fortune))
this.getItem() != this.getItemDropped(this.getState(), random, fortune))
{
int i = random.zrange(fortune + 2) - 1;

View file

@ -29,10 +29,6 @@ public class BlockPodzol extends Block {
return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
}
public int getMetaFromState(State state) {
return 0;
}
protected Property[] getProperties() {
return new Property[] {SNOWY};
}

View file

@ -167,14 +167,6 @@ public class BlockSnow extends Block
return ((Integer)worldIn.getState(pos).getValue(LAYERS)).intValue() == 1;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(LAYERS)).intValue() - 1;
}
protected Property[] getProperties()
{
return new Property[] {LAYERS};

View file

@ -129,16 +129,6 @@ public class BlockAnvil extends BlockFalling implements Rotatable
return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -516,24 +516,6 @@ public class BlockBrewingStand extends BlockContainer
return iblockstate;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
for (int j = 0; j < 3; ++j)
{
if (((Boolean)state.getValue(HAS_BOTTLE[j])).booleanValue())
{
i |= 1 << j;
}
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]};

View file

@ -353,48 +353,6 @@ public class BlockButton extends Block implements Directional
return this.getState().withProperty(FACING, enumfacing).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i;
switch ((Facing)state.getValue(FACING))
{
case EAST:
i = 1;
break;
case WEST:
i = 2;
break;
case SOUTH:
i = 3;
break;
case NORTH:
i = 4;
break;
case UP:
default:
i = 5;
break;
case DOWN:
i = 0;
}
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, POWERED};

View file

@ -651,14 +651,6 @@ public class BlockCauldron extends Block
return this.getState().withProperty(LEVEL, Integer.valueOf(meta > 3 ? 0 : meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(LEVEL)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {LEVEL};

View file

@ -619,14 +619,6 @@ public class BlockChest extends BlockContainer implements Rotatable
return this.getState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -164,14 +164,6 @@ public class BlockDaylightDetector extends BlockContainer
return this.getState().withProperty(POWER, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(POWER)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {POWER};

View file

@ -282,22 +282,6 @@ public class BlockDispenser extends BlockContainer implements Directional
return this.getState().withProperty(FACING, getFacing(meta)).withProperty(TRIGGERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getIndex();
if (((Boolean)state.getValue(TRIGGERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, TRIGGERED};

View file

@ -262,14 +262,6 @@ public class BlockFurnace extends BlockContainer implements Rotatable
return this.getState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -279,22 +279,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
return this.getState().withProperty(FACING, getFacing(((meta & 7) == 1 || (meta & 7) > 5) ? 0 : meta)).withProperty(ENABLED, Boolean.valueOf(isEnabled(meta)));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getIndex();
if (!((Boolean)state.getValue(ENABLED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, ENABLED};

View file

@ -257,22 +257,6 @@ public class BlockLever extends Block
return this.getState().withProperty(FACING, BlockLever.EnumOrientation.byMetadata(meta & 7)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((BlockLever.EnumOrientation)state.getValue(FACING)).getMetadata();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, POWERED};

View file

@ -89,10 +89,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
return this.getState().withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state) {
return ((Facing)state.getValue(FACING)).getHorizontalIndex();
}
protected Property[] getProperties() {
return new Property[] {FACING};
}

View file

@ -687,22 +687,6 @@ public class BlockPistonBase extends Block implements Directional
return this.getState().withProperty(FACING, getFacing(meta)).withProperty(EXTENDED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getIndex();
if (((Boolean)state.getValue(EXTENDED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, EXTENDED};

View file

@ -238,22 +238,6 @@ public class BlockPistonHead extends Block implements Directional
return this.getState().withProperty(FACING, getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getIndex();
if (state.getValue(TYPE) == BlockPistonHead.EnumPistonType.STICKY)
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, TYPE, SHORT};

View file

@ -290,22 +290,6 @@ public class BlockPistonMoving extends BlockContainer
return this.getState().withProperty(FACING, BlockPistonHead.getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getIndex();
if (state.getValue(TYPE) == BlockPistonHead.EnumPistonType.STICKY)
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, TYPE};

View file

@ -75,14 +75,6 @@ public class BlockPressurePlate extends BlockBasePressurePlate
return this.getState().withProperty(POWERED, Boolean.valueOf(meta == 1));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 1 : 0;
}
protected Property[] getProperties()
{
return new Property[] {POWERED};

View file

@ -62,14 +62,6 @@ public class BlockPressurePlateWeighted extends BlockBasePressurePlate
return this.getState().withProperty(POWER, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(POWER)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {POWER};

View file

@ -38,14 +38,6 @@ public class BlockRail extends BlockRailBase
return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata();
}
protected Property[] getProperties()
{
return new Property[] {SHAPE};

View file

@ -184,22 +184,6 @@ public class BlockRailDetector extends BlockRailBase
return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata((meta & 7) > 5 ? 0 : (meta & 7))).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {SHAPE, POWERED};

View file

@ -171,22 +171,6 @@ public class BlockRailPowered extends BlockRailBase
return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata((meta & 7) > 5 ? 0 : (meta & 7))).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {SHAPE, POWERED};

View file

@ -282,27 +282,6 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile
return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(MODE, (meta & 4) > 0 ? BlockRedstoneComparator.Mode.SUBTRACT : BlockRedstoneComparator.Mode.COMPARE);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
if (state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT)
{
i |= 4;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, MODE, POWERED};

View file

@ -144,17 +144,6 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode
return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(LOCKED, Boolean.valueOf(false)).withProperty(DELAY, Integer.valueOf(1 + (meta >> 2)));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
i = i | ((Integer)state.getValue(DELAY)).intValue() - 1 << 2;
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, DELAY, LOCKED};

View file

@ -811,14 +811,6 @@ public class BlockRedstoneWire extends Block
return this.getState().withProperty(POWER, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(POWER)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {NORTH, EAST, SOUTH, WEST, POWER};

View file

@ -166,14 +166,6 @@ public class BlockTNT extends Block
return this.getState().withProperty(EXPLODE, Boolean.valueOf((meta & 1) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Boolean)state.getValue(EXPLODE)).booleanValue() ? 1 : 0;
}
protected Property[] getProperties()
{
return new Property[] {EXPLODE};

View file

@ -277,40 +277,6 @@ public class BlockTorch extends Block implements DirectionalUp
return iblockstate;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
switch ((Facing)state.getValue(FACING))
{
case EAST:
i = i | 1;
break;
case WEST:
i = i | 2;
break;
case SOUTH:
i = i | 3;
break;
case NORTH:
i = i | 4;
break;
case DOWN:
case UP:
default:
i = i | 5;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -272,36 +272,6 @@ public class BlockTripWire extends Block
return this.getState().withProperty(POWERED, Boolean.valueOf((meta & 1) > 0)).withProperty(SUSPENDED, Boolean.valueOf((meta & 2) > 0)).withProperty(ATTACHED, Boolean.valueOf((meta & 4) > 0)).withProperty(DISARMED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 1;
}
if (((Boolean)state.getValue(SUSPENDED)).booleanValue())
{
i |= 2;
}
if (((Boolean)state.getValue(ATTACHED)).booleanValue())
{
i |= 4;
}
if (((Boolean)state.getValue(DISARMED)).booleanValue())
{
i |= 8;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {POWERED, SUSPENDED, ATTACHED, DISARMED, NORTH, EAST, WEST, SOUTH};

View file

@ -350,27 +350,6 @@ public class BlockTripWireHook extends Block implements Rotatable
return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(ATTACHED, Boolean.valueOf((meta & 4) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
if (((Boolean)state.getValue(ATTACHED)).booleanValue())
{
i |= 4;
}
return i;
}
protected Property[] getProperties()
{
return new Property[] {FACING, POWERED, ATTACHED, SUSPENDED};

View file

@ -146,14 +146,6 @@ public class BlockWarpChest extends Block implements Rotatable
return this.getState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -71,11 +71,6 @@ public class BlockBannerHanging extends BlockBanner
return this.getState().withProperty(FACING, enumfacing);
}
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -34,11 +34,6 @@ public class BlockBannerStanding extends BlockBanner
return this.getState().withProperty(ROTATION, Integer.valueOf(meta));
}
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(ROTATION)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {ROTATION};

View file

@ -40,14 +40,6 @@ public class BlockStandingSign extends BlockSign
return this.getState().withProperty(ROTATION, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(ROTATION)).intValue();
}
protected Property[] getProperties()
{
return new Property[] {ROTATION};

View file

@ -78,14 +78,6 @@ public class BlockWallSign extends BlockSign implements Rotatable
return this.getState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected Property[] getProperties()
{
return new Property[] {FACING};

View file

@ -4,7 +4,6 @@ import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import common.block.*;
@ -139,12 +138,10 @@ import common.collect.BiMap;
import common.collect.HashBiMap;
import common.collect.Lists;
import common.collect.Maps;
import common.collect.Sets;
import common.color.DyeColor;
import common.item.CheatTab;
import common.log.Log;
import common.model.TextureAnimation;
import common.properties.Property;
import common.util.Util;
import common.world.State;
@ -661,37 +658,15 @@ public abstract class BlockRegistry {
register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));
register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0));
Map<Class, String> map = Maps.newLinkedHashMap();
for(Block block : BLOCKS) {
for(State state : block.getValidStates()) {
STATE_NAMES.put(state, state.buildSaved());
STATE_NAMES.put(state, state.getId());
}
for(int n = 0; n < 16; n++) {
State state = block.getStateFromMeta(n);
String id = STATE_NAMES.get(state);
if(!STATE_MAP.containsKey(id)) {
STATE_MAP.put(id, state);
STATE_IDS.put(state, STATES.size());
STATES.add(state);
}
for(State state : block.getSavedStates()) {
STATE_MAP.put(STATE_NAMES.get(state), state);
STATE_IDS.put(state, STATES.size());
STATES.add(state);
}
StringBuilder sb = new StringBuilder("\n\n\tpublic Property[] getUnsavedProperties() {\n\t\treturn new Property[] {");
boolean put = false;
Set<Property> props = Sets.newHashSet(block.getPropertyMap());
for(Property prop : block.getState().getSavedProperties()) {
props.remove(prop);
}
for(Property prop : props) {
if(put)
sb.append(", ");
sb.append(prop.getName().toUpperCase());
put = true;
}
if(put)
map.put(block.getClass(), sb.append("};\n\t}").toString());
}
for(Entry<Class, String> entry : map.entrySet()) {
System.out.printf("%s.java\n%s\n", entry.getKey().getSimpleName(), entry.getValue());
}
Log.SYSTEM.debug("%d Blöcke registriert", BLOCK_MAP.size());

View file

@ -4,17 +4,14 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.function.Function;
import common.block.Block;
import common.collect.ImmutableMap;
import common.collect.ImmutableSet;
import common.collect.ImmutableTable;
import common.collect.Iterables;
import common.collect.Maps;
import common.collect.Sets;
import common.collect.StandardTable;
import common.collect.Table;
import common.init.BlockRegistry;
@ -37,42 +34,6 @@ public class State {
private final Block block;
private final ImmutableMap<Property, Comparable> properties;
private ImmutableTable<Property, Comparable, State> map;
private ImmutableSet<Property> saved;
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.getName(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 State(Block block, ImmutableMap<Property, Comparable> properties) {
this.block = block;
@ -97,10 +58,6 @@ public class State {
return Collections.<Property>unmodifiableCollection(this.properties.keySet());
}
public Collection<Property> getSavedProperties() {
return this.saved;
}
public <T extends Comparable<T>> T getValue(Property<T> property) {
if(!this.properties.containsKey(property)) {
throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.block);
@ -175,10 +132,12 @@ public class State {
this.map = ImmutableTable.<Property, Comparable, State>copyOf(table);
}
public String buildSaved() {
if(this.saved != null)
throw new IllegalStateException();
this.saved = ImmutableSet.copyOf(getSavedProperties(this.block));
return filterProperties(this, this.saved);
public String getId() {
StringBuilder sb = new StringBuilder(BlockRegistry.getName(this.getBlock()));
for(Entry<Property, Comparable> entry : this.getProperties().entrySet()) {
if(this.getBlock().getSavedProperties().contains(entry.getKey()))
sb.append(',').append(entry.getKey().getName()).append('=').append(entry.getKey().getName(entry.getValue()));
}
return sb.toString();
}
}

View file

@ -1,8 +1,6 @@
package server.clipboard;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import common.block.Block;
@ -16,15 +14,14 @@ import common.color.DyeColor;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.WoodType;
import common.util.Facing;
import common.util.Vec3i;
import common.world.State;
public abstract class ReorderRegistry {
private static final Set<Block> PLACE_LAST = new HashSet<Block>();
private static final Set<Block> PLACE_FINAL = new HashSet<Block>();
private static final Map<State, Vec3i> STATE_ATTACH = new HashMap<State, Vec3i>();
private static final Map<Block, Vec3i> BLOCK_ATTACH = new HashMap<Block, Vec3i>();
// private static final Map<State, Vec3i> STATE_ATTACH = new HashMap<State, Vec3i>();
// private static final Map<Block, Vec3i> BLOCK_ATTACH = new HashMap<Block, Vec3i>();
public static boolean shouldPlaceLast(Block id) {
return PLACE_LAST.contains(id);
@ -35,11 +32,15 @@ public abstract class ReorderRegistry {
}
public static Vec3i getAttachment(State state) {
Vec3i direction = BLOCK_ATTACH.get(state.getBlock());
if (direction != null) return direction;
return STATE_ATTACH.get(state);
return null; //TODO: add attachment clean
}
// public static Vec3i getAttachment(State state) {
// Vec3i direction = BLOCK_ATTACH.get(state.getBlock());
// if (direction != null) return direction;
// return STATE_ATTACH.get(state);
// }
public static void register() {
for(WoodType wood : WoodType.values()) {
PLACE_LAST.add(BlockRegistry.byName(wood.getName() + "_sapling"));
@ -124,6 +125,7 @@ public abstract class ReorderRegistry {
PLACE_FINAL.add(Blocks.wall_banner);
}
/*
private static void addAttach(State state, Facing dir) {
STATE_ATTACH.put(state, dir.getDirectionVec());
}
@ -247,4 +249,5 @@ public abstract class ReorderRegistry {
addAttach(Blocks.blue_mushroom, Facing.DOWN);
}
*/
}

View file

@ -16,7 +16,7 @@ public abstract class RotationRegistry {
public static void register() {
List<RotationValue> values = Lists.newArrayList();
for(Block block : common.init.BlockRegistry.blocks()) {
for(Property<?> prop : block.getPropertyMap()) {
for(Property<?> prop : block.getSavedProperties()) {
for(Comparable v : prop.getStates()) {
if(!(v instanceof DirectionVec vec))
continue;

View file

@ -27,7 +27,7 @@ public class CommandBlock extends Command {
if(idx >= 0) {
Block block = BlockRegistry.byNameExact(last.substring(0, idx));
if(block != null)
return Lists.newArrayList(Iterables.transform(block.getValidStates(), state -> BlockRegistry.getName(state)));
return Lists.newArrayList(Iterables.transform(block.getSavedStates(), state -> BlockRegistry.getName(state)));
}
return BlockRegistry.getKeys();
}