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<State> states;
|
||||
protected final Material material;
|
||||
protected final boolean translucent;
|
||||
|
||||
protected boolean fullBlock;
|
||||
protected boolean translucent;
|
||||
protected boolean sumBrightness;
|
||||
protected boolean axeHarvest;
|
||||
protected boolean shovelHarvest;
|
||||
|
@ -276,6 +276,7 @@ public class Block {
|
|||
this.fullBlock = this.isOpaqueCube();
|
||||
this.lightOpacity = this.isOpaqueCube() ? 255 : 0;
|
||||
this.translucent = !material.blocksLight();
|
||||
this.sumBrightness = this.translucent || this.lightOpacity == 0;
|
||||
this.properties = getPropertyList(this.getProperties());
|
||||
this.states = getStateList(this.properties, this);
|
||||
this.setDefaultState(this.getBaseState());
|
||||
|
@ -288,6 +289,7 @@ public class Block {
|
|||
|
||||
public Block setLightOpacity(int opacity) {
|
||||
this.lightOpacity = opacity;
|
||||
this.sumBrightness = this.translucent || this.lightOpacity == 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -326,11 +328,6 @@ public class Block {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Block setSumBrightness() {
|
||||
this.sumBrightness = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Block setMiningLevel(int level) {
|
||||
this.miningLevel = level;
|
||||
return this;
|
||||
|
|
|
@ -32,4 +32,8 @@ public final class BlockAir extends Block {
|
|||
public boolean isReplaceable(World world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getSumBrightness() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,6 +264,10 @@ public class BlockSlab extends Block implements Directional
|
|||
this.textureTop);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSumBrightness() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
public Model getModel(String name, IBlockState state) {
|
||||
|
|
|
@ -829,6 +829,10 @@ public class BlockStairs extends Block implements Rotatable
|
|||
);
|
||||
}
|
||||
|
||||
public boolean getSumBrightness() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static enum EnumHalf implements Identifyable
|
||||
{
|
||||
TOP("top"),
|
||||
|
|
|
@ -180,4 +180,8 @@ public class BlockFarmland extends Block
|
|||
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();
|
||||
}
|
||||
|
||||
public boolean getSumBrightness() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,11 +137,10 @@ import common.util.Util;
|
|||
import common.world.State;
|
||||
|
||||
public abstract class BlockRegistry {
|
||||
private static final String AIR_ID = "air";
|
||||
public static final Mapping<Block> REGISTRY = new Mapping(AIR_ID);
|
||||
public static final Mapping<Block> REGISTRY = new Mapping("air");
|
||||
public static final IdMap<State> STATEMAP = new IdMap();
|
||||
|
||||
private static int nextBlockId = 1;
|
||||
private static int nextBlockId = 0;
|
||||
|
||||
public static int getIdFromBlock(Block block) {
|
||||
return REGISTRY.getId(block);
|
||||
|
@ -201,30 +200,8 @@ public abstract class BlockRegistry {
|
|||
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) {
|
||||
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,
|
||||
|
@ -239,7 +216,8 @@ public abstract class BlockRegistry {
|
|||
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");
|
||||
registerBlock("stone", 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("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken"));
|
||||
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();
|
||||
|
||||
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