remove block metadata TEMP

This commit is contained in:
Sen 2025-06-27 16:56:08 +02:00
parent 30a78ad279
commit 2919d99126
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
20 changed files with 111 additions and 10 deletions

View file

@ -158,7 +158,9 @@ public class Block {
}
private final ImmutableList<Property> properties;
private final ImmutableList<Property> savedProps;
private final ImmutableList<State> states;
private final ImmutableList<State> saved;
protected final Material material;
protected final boolean translucent;
@ -253,6 +255,26 @@ public class Block {
return ImmutableList.copyOf(properties);
}
private static ImmutableList<Property> getPropertyList(Property[] properties, Property[] unsaved) {
List<Property> list = unsaved.length == 0 ? Lists.newArrayList(properties) : Lists.newArrayList();
if(unsaved.length > 0) {
for(Property prop : properties) {
for(int z = 0; z < unsaved.length; z++) {
if(unsaved[z] == prop)
break;
else if(z == unsaved.length - 1)
list.add(prop);
}
}
}
Collections.sort(list, new Comparator<Property>() {
public int compare(Property p1, Property p2) {
return p1.getName().compareTo(p2.getName());
}
});
return ImmutableList.copyOf(list);
}
private static ImmutableList<State> getStateList(List<Property> properties, Block block) {
Map<Map<Property, Comparable>, State> map = Maps.<Map<Property, Comparable>, State>newLinkedHashMap();
List<State> list = Lists.<State>newArrayList();
@ -283,6 +305,8 @@ public class Block {
this.properties = getPropertyList(this.getProperties());
this.states = getStateList(this.properties, this);
this.setDefaultState(this.getBaseState());
this.savedProps = getPropertyList(this.getProperties(), this.getUnsavedProperties());
this.saved = getStateList(this.savedProps, this);
}
public Block setStepSound(SoundType sound) {
@ -397,12 +421,16 @@ public class Block {
return this.states;
}
public ImmutableList<State> getSavedStates() {
return this.saved;
}
public final State getBaseState() {
return this.states.get(0);
}
public Collection<Property> getPropertyMap() {
return this.properties;
return this.savedProps;
}
public State getStateFromMeta(int meta) {
@ -951,6 +979,10 @@ public class Block {
return new Property[0];
}
public Property[] getUnsavedProperties() {
return new Property[0];
}
protected final void setDefaultState(State state) {
this.defaultState = state;
}

View file

@ -385,4 +385,8 @@ public class BlockFence extends Block
protected Item getItemToRegister() {
return new ItemFence(this);
}
public Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, WEST, EAST};
}
}

View file

@ -409,4 +409,8 @@ public class BlockFenceGate extends Block implements Rotatable
public Property<?>[] getIgnoredProperties() {
return new Property[] {POWERED};
}
public Property[] getUnsavedProperties() {
return new Property[] {IN_WALL};
}
}

View file

@ -504,4 +504,8 @@ public class BlockPane extends Block
protected Item getItemToRegister() {
return this.canDrop ? super.getItemToRegister() : new ItemBlock(this, "glass", false);
}
public Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, WEST, EAST};
}
}

View file

@ -833,6 +833,10 @@ public class BlockStairs extends Block implements Rotatable
return true;
}
public Property[] getUnsavedProperties() {
return new Property[] {SHAPE};
}
public static enum EnumHalf implements Identifyable
{
TOP("top"),

View file

@ -299,4 +299,8 @@ public class BlockWall extends Block
protected Item getItemToRegister() {
return new ItemWall(this);
}
public Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, UP, WEST, EAST};
}
}

View file

@ -29,7 +29,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
public class BlockDoublePlant extends BlockBush implements IGrowable
{
public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> HALF = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>create("half", BlockDoublePlant.EnumBlockHalf.class);
public static final BlockDoublePlant[] PLANTS = new BlockDoublePlant[EnumPlantType.values().length];
@ -44,7 +44,7 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
{
super(Material.BUSH);
this.type = type;
this.setDefaultState(this.getBaseState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(FACING, Facing.NORTH));
this.setDefaultState(this.getBaseState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER));
this.setHardness(0.0F);
this.setStepSound(SoundType.GRASS);
this.setFlammable(60, 100);
@ -271,12 +271,12 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
*/
public int getMetaFromState(State state)
{
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((Facing)state.getValue(FACING)).getHorizontalIndex() : 0;
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 : 0;
}
protected Property[] getProperties()
{
return new Property[] {HALF, FACING};
return new Property[] {HALF};
}
public Model getModel(ModelProvider provider, String name, State state) {
@ -295,10 +295,6 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
return provider.getModel(this.type.getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
? "top" : "bottom")).cross();
}
public Property<?>[] getIgnoredProperties() {
return new Property[] {FACING};
}
protected Item getItemToRegister() {
return new ItemDoublePlant(this);

View file

@ -148,4 +148,8 @@ public class BlockGrass extends Block implements IGrowable
protected Item getItemToRegister() {
return new ItemColored(this);
}
public Property[] getUnsavedProperties() {
return new Property[] {SNOWY};
}
}

View file

@ -106,4 +106,8 @@ public class BlockMycelium extends Block
else
return provider.getModel("mycelium_side").add().nswe().d("dirt").u("mycelium_top");
}
public Property[] getUnsavedProperties() {
return new Property[] {SNOWY};
}
}

View file

@ -324,4 +324,8 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable
protected Item getItemToRegister() {
return new ItemSeeds(this, Blocks.farmland).setDisplay(this.itemName).setMaxAmount(256);
}
public Property[] getUnsavedProperties() {
return new Property[] {FACING};
}
}

View file

@ -52,4 +52,8 @@ public class BlockTianSoil extends Block
else
return provider.getModel("tian_soil_side").add().nswe().d("tian").u("tian_soil_top");
}
public Property[] getUnsavedProperties() {
return new Property[] {SNOWY};
}
}

View file

@ -597,4 +597,8 @@ public class BlockVine extends Block
protected Item getItemToRegister() {
return new ItemColored(this, "");
}
public Property[] getUnsavedProperties() {
return new Property[] {UP};
}
}

View file

@ -1156,4 +1156,8 @@ public class BlockFire extends Block
protected Item getItemToRegister() {
return null;
}
public Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, UPPER, FLIP, WEST, EAST, ALT};
}
}

View file

@ -45,4 +45,8 @@ public class BlockPodzol extends Block {
return state.getValue(SNOWY) ? provider.getModel("grass_side_snowed").add().nswe().d("dirt").u("grass_top")
: provider.getModel("dirt_podzol_side").add().nswe().d("dirt").u("dirt_podzol_top");
}
public Property[] getUnsavedProperties() {
return new Property[] {SNOWY};
}
}

View file

@ -300,6 +300,10 @@ public class BlockPistonHead extends Block implements Directional
return null;
}
public Property[] getUnsavedProperties() {
return new Property[] {SHORT};
}
public static enum EnumPistonType implements Identifyable
{
DEFAULT("normal"),

View file

@ -574,4 +574,8 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode
protected Item getItemToRegister() {
return this.isRepeaterPowered ? null : new ItemSmallBlock(this).setDisplay("Redstone-Verstärker").setTab(CheatTab.TECHNOLOGY);
}
public Property[] getUnsavedProperties() {
return new Property[] {LOCKED};
}
}

View file

@ -1033,6 +1033,10 @@ public class BlockRedstoneWire extends Block
return new ItemRedstone(Blocks.redstone).setDisplay("Redstone").setPotionEffect(PotionHelper.redstoneEffect).setMaxAmount(256);
}
public Property[] getUnsavedProperties() {
return new Property[] {EAST, NORTH, SOUTH, WEST};
}
public static enum EnumAttachPosition implements Identifyable
{
UP("up"),

View file

@ -702,4 +702,8 @@ public class BlockTripWire extends Block
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Faden").setTab(CheatTab.TECHNOLOGY).setMaxAmount(1024);
}
public Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, WEST, EAST};
}
}

View file

@ -594,4 +594,8 @@ public class BlockTripWireHook extends Block implements Rotatable
protected Item getItemToRegister() {
return new ItemBlock(this, "tripwire_hook", false);
}
public Property[] getUnsavedProperties() {
return new Property[] {SUSPENDED};
}
}

View file

@ -139,6 +139,7 @@ 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;
@ -674,9 +675,13 @@ public abstract class BlockRegistry {
STATES.add(state);
}
}
StringBuilder sb = new StringBuilder("\n\n\tpublic Property[] getSavedProperties() {\n\t\treturn new Property[] {");
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());