registry cleanup
This commit is contained in:
parent
de8d2477a3
commit
34a3f52b50
7 changed files with 35 additions and 34 deletions
|
@ -159,9 +159,9 @@ public class Block {
|
||||||
private final ImmutableList<Property> properties;
|
private final ImmutableList<Property> properties;
|
||||||
private final ImmutableList<State> states;
|
private final ImmutableList<State> states;
|
||||||
protected final Material material;
|
protected final Material material;
|
||||||
|
protected final boolean translucent;
|
||||||
|
|
||||||
protected boolean fullBlock;
|
protected boolean fullBlock;
|
||||||
protected boolean translucent;
|
|
||||||
protected boolean sumBrightness;
|
protected boolean sumBrightness;
|
||||||
protected boolean axeHarvest;
|
protected boolean axeHarvest;
|
||||||
protected boolean shovelHarvest;
|
protected boolean shovelHarvest;
|
||||||
|
@ -276,6 +276,7 @@ public class Block {
|
||||||
this.fullBlock = this.isOpaqueCube();
|
this.fullBlock = this.isOpaqueCube();
|
||||||
this.lightOpacity = this.isOpaqueCube() ? 255 : 0;
|
this.lightOpacity = this.isOpaqueCube() ? 255 : 0;
|
||||||
this.translucent = !material.blocksLight();
|
this.translucent = !material.blocksLight();
|
||||||
|
this.sumBrightness = this.translucent || this.lightOpacity == 0;
|
||||||
this.properties = getPropertyList(this.getProperties());
|
this.properties = getPropertyList(this.getProperties());
|
||||||
this.states = getStateList(this.properties, this);
|
this.states = getStateList(this.properties, this);
|
||||||
this.setDefaultState(this.getBaseState());
|
this.setDefaultState(this.getBaseState());
|
||||||
|
@ -288,6 +289,7 @@ public class Block {
|
||||||
|
|
||||||
public Block setLightOpacity(int opacity) {
|
public Block setLightOpacity(int opacity) {
|
||||||
this.lightOpacity = opacity;
|
this.lightOpacity = opacity;
|
||||||
|
this.sumBrightness = this.translucent || this.lightOpacity == 0;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,11 +328,6 @@ public class Block {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block setSumBrightness() {
|
|
||||||
this.sumBrightness = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block setMiningLevel(int level) {
|
public Block setMiningLevel(int level) {
|
||||||
this.miningLevel = level;
|
this.miningLevel = level;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -32,4 +32,8 @@ public final class BlockAir extends Block {
|
||||||
public boolean isReplaceable(World world, BlockPos pos) {
|
public boolean isReplaceable(World world, BlockPos pos) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSumBrightness() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,10 @@ public class BlockSlab extends Block implements Directional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSumBrightness() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public Model getModel(String name, IBlockState state) {
|
public Model getModel(String name, IBlockState state) {
|
||||||
if(state.getValue(VARIANT) == EnumType.STONE)
|
if(state.getValue(VARIANT) == EnumType.STONE)
|
||||||
|
|
|
@ -829,6 +829,10 @@ public class BlockStairs extends Block implements Rotatable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSumBrightness() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static enum EnumHalf implements Identifyable
|
public static enum EnumHalf implements Identifyable
|
||||||
{
|
{
|
||||||
TOP("top"),
|
TOP("top"),
|
||||||
|
|
|
@ -180,4 +180,8 @@ public class BlockFarmland extends Block
|
||||||
public Model getModel(ModelProvider provider, String name, State state) {
|
public Model getModel(ModelProvider provider, String name, State state) {
|
||||||
return provider.getModel("dirt").add(0, 0, 0, 16, 15, 16).dnswe().u("farmland_" + state.getValue(MOISTURE)).noCull();
|
return provider.getModel("dirt").add(0, 0, 0, 16, 15, 16).dnswe().u("farmland_" + state.getValue(MOISTURE)).noCull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSumBrightness() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,11 +137,10 @@ import common.util.Util;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
|
||||||
public abstract class BlockRegistry {
|
public abstract class BlockRegistry {
|
||||||
private static final String AIR_ID = "air";
|
public static final Mapping<Block> REGISTRY = new Mapping("air");
|
||||||
public static final Mapping<Block> REGISTRY = new Mapping(AIR_ID);
|
|
||||||
public static final IdMap<State> STATEMAP = new IdMap();
|
public static final IdMap<State> STATEMAP = new IdMap();
|
||||||
|
|
||||||
private static int nextBlockId = 1;
|
private static int nextBlockId = 0;
|
||||||
|
|
||||||
public static int getIdFromBlock(Block block) {
|
public static int getIdFromBlock(Block block) {
|
||||||
return REGISTRY.getId(block);
|
return REGISTRY.getId(block);
|
||||||
|
@ -201,30 +200,8 @@ public abstract class BlockRegistry {
|
||||||
return REGISTRY.byName(name);
|
return REGISTRY.byName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register() {
|
|
||||||
REGISTRY.register(0, BlockRegistry.AIR_ID, (new BlockAir()).setDisplay("Luft"));
|
|
||||||
registerBlocks();
|
|
||||||
REGISTRY.finish();
|
|
||||||
|
|
||||||
for(Block block : REGISTRY) {
|
|
||||||
if(block != Blocks.air
|
|
||||||
&& ((block instanceof BlockStairs) || /* (block instanceof BlockSlab) || */ (block instanceof BlockSlab)
|
|
||||||
|| (block instanceof BlockFarmland) || block.isTranslucent() || block.getLightOpacity() == 0)) {
|
|
||||||
block.setSumBrightness();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Block block : REGISTRY) {
|
|
||||||
for(State state : block.getValidStates()) {
|
|
||||||
STATEMAP.put(state, REGISTRY.getId(block) << 4 | block.getMetaFromState(state));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.SYSTEM.debug("%d Blöcke registriert", nextBlockId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void registerBlock(String name, Block block) {
|
private static void registerBlock(String name, Block block) {
|
||||||
BlockRegistry.REGISTRY.register(nextBlockId++, name, block);
|
REGISTRY.register(nextBlockId++, name, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerFluid(String name, String display, boolean infinite, LiquidType type, boolean opaque, int light, int rate,
|
private static void registerFluid(String name, String display, boolean infinite, LiquidType type, boolean opaque, int light, int rate,
|
||||||
|
@ -239,7 +216,8 @@ public abstract class BlockRegistry {
|
||||||
registerBlock(name, st);
|
registerBlock(name, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerBlocks() {
|
static void register() {
|
||||||
|
registerBlock("air", (new BlockAir()).setDisplay("Luft"));
|
||||||
Block stone = (new BlockStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Stein");
|
Block stone = (new BlockStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Stein");
|
||||||
registerBlock("stone", stone);
|
registerBlock("stone", stone);
|
||||||
registerBlock("bedrock", (new BlockBedrock()).setHardness(1000.0F).setResistance(100000.0F).setStepSound(SoundType.STONE)
|
registerBlock("bedrock", (new BlockBedrock()).setHardness(1000.0F).setResistance(100000.0F).setStepSound(SoundType.STONE)
|
||||||
|
@ -673,5 +651,15 @@ public abstract class BlockRegistry {
|
||||||
registerBlock("daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor"));
|
registerBlock("daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor"));
|
||||||
registerBlock("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));
|
registerBlock("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));
|
||||||
registerBlock("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0));
|
registerBlock("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0));
|
||||||
|
|
||||||
|
REGISTRY.finish();
|
||||||
|
|
||||||
|
for(Block block : REGISTRY) {
|
||||||
|
for(State state : block.getValidStates()) {
|
||||||
|
STATEMAP.put(state, REGISTRY.getId(block) << 4 | block.getMetaFromState(state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.SYSTEM.debug("%d Blöcke registriert", nextBlockId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,6 +553,6 @@ public abstract class ItemRegistry {
|
||||||
|
|
||||||
REGISTRY.finish();
|
REGISTRY.finish();
|
||||||
|
|
||||||
Log.SYSTEM.debug("%d Gegenstände registriert", nextItemId);
|
Log.SYSTEM.debug("%d Gegenstände registriert", nextItemId - 4096);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue