remove block metadata TEMP
This commit is contained in:
parent
1e104d5db8
commit
30a78ad279
83 changed files with 1088 additions and 1177 deletions
|
@ -42,11 +42,11 @@ public abstract class ReorderRegistry {
|
|||
|
||||
public static void register() {
|
||||
for(WoodType wood : WoodType.values()) {
|
||||
PLACE_LAST.add(BlockRegistry.getRegisteredBlock(wood.getName() + "_sapling"));
|
||||
PLACE_LAST.add(BlockRegistry.byName(wood.getName() + "_sapling"));
|
||||
}
|
||||
// PLACE_LAST.add(Blocks.bed);
|
||||
for(DyeColor color : BlockBed.COLORS) {
|
||||
PLACE_LAST.add(BlockRegistry.getRegisteredBlock(color.getName() + "_bed"));
|
||||
PLACE_LAST.add(BlockRegistry.byName(color.getName() + "_bed"));
|
||||
}
|
||||
PLACE_LAST.add(Blocks.golden_rail);
|
||||
PLACE_LAST.add(Blocks.detector_rail);
|
||||
|
@ -141,7 +141,7 @@ public abstract class ReorderRegistry {
|
|||
|
||||
static {
|
||||
for(WoodType wood : WoodType.values()) {
|
||||
addAttach(BlockRegistry.getRegisteredBlock(wood.getName() + "_sapling"), Facing.DOWN);
|
||||
addAttach(BlockRegistry.byName(wood.getName() + "_sapling"), Facing.DOWN);
|
||||
}
|
||||
addAttach(Blocks.tallgrass, Facing.DOWN);
|
||||
addAttach(Blocks.deadbush, Facing.DOWN);
|
||||
|
|
|
@ -15,7 +15,7 @@ public abstract class RotationRegistry {
|
|||
|
||||
public static void register() {
|
||||
List<RotationValue> values = Lists.newArrayList();
|
||||
for(Block block : common.init.BlockRegistry.REGISTRY) {
|
||||
for(Block block : common.init.BlockRegistry.blocks()) {
|
||||
for(Property<?> prop : block.getPropertyMap()) {
|
||||
for(Comparable v : prop.getStates()) {
|
||||
if(!(v instanceof DirectionVec vec))
|
||||
|
|
|
@ -25,11 +25,11 @@ public class CommandBlock extends Command {
|
|||
public Collection<String> complete(CommandEnvironment env, String last) {
|
||||
int idx = last.indexOf(',');
|
||||
if(idx >= 0) {
|
||||
Block block = BlockRegistry.REGISTRY.byNameExact(last.substring(0, idx));
|
||||
Block block = BlockRegistry.byNameExact(last.substring(0, idx));
|
||||
if(block != null)
|
||||
return Lists.newArrayList(Iterables.transform(block.getValidStates(), state -> state.getId()));
|
||||
return Lists.newArrayList(Iterables.transform(block.getValidStates(), state -> BlockRegistry.getName(state)));
|
||||
}
|
||||
return BlockRegistry.REGISTRY.getKeys();
|
||||
return BlockRegistry.getKeys();
|
||||
}
|
||||
});
|
||||
this.addBlockPos("position", true);
|
||||
|
@ -40,7 +40,7 @@ public class CommandBlock extends Command {
|
|||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String block, BlockPos position, WorldServer world, TagObject tag) {
|
||||
State state = State.getState(block, null);
|
||||
State state = BlockRegistry.byName(block, null);
|
||||
if(state == null)
|
||||
throw new RunException("Block '%s' existiert nicht", block);
|
||||
boolean success = world.setState(position, state);
|
||||
|
|
|
@ -20,7 +20,7 @@ public class CommandItem extends Command {
|
|||
|
||||
this.addString("item", false, new StringCompleter() {
|
||||
public Collection<String> complete(CommandEnvironment env, String last) {
|
||||
return ItemRegistry.REGISTRY.getKeys();
|
||||
return ItemRegistry.getKeys();
|
||||
}
|
||||
});
|
||||
this.setParamsOptional();
|
||||
|
|
|
@ -1207,7 +1207,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
State iblockstate = this.entity.worldObj.getState(pos);
|
||||
TileEntity tileentity = this.entity.worldObj.getTileEntity(pos);
|
||||
|
||||
this.entity.worldObj.playAuxSFX(this.entity, 2001, pos, BlockRegistry.getStateId(iblockstate));
|
||||
this.entity.worldObj.playAuxSFX(this.entity, 2001, pos, BlockRegistry.getId(iblockstate));
|
||||
boolean flag1 = this.removeBlock(pos);
|
||||
|
||||
// if (this.creative)
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Set;
|
|||
import common.biome.Biome;
|
||||
import common.block.Block;
|
||||
import common.entity.Entity;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.log.Log;
|
||||
import common.rng.Random;
|
||||
|
@ -24,13 +25,13 @@ public class ChunkServer extends Chunk {
|
|||
super(world, x, z);
|
||||
}
|
||||
|
||||
public ChunkServer(World world, short[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) {
|
||||
public ChunkServer(World world, char[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) {
|
||||
this(world, x, z);
|
||||
boolean sky = !world.dimension.hasNoLight();
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
for(int by = 0; by < height; ++by) {
|
||||
State state = State.ID_MAP.getByValue(data[bx << 4 | bz | by << 8]);
|
||||
State state = BlockRegistry.byId(data[bx << 4 | bz | by << 8]);
|
||||
if(state != null && state.getBlock() != Blocks.air) {
|
||||
int y = by >> 4;
|
||||
BlockArray arr = this.getArray(y);
|
||||
|
|
|
@ -109,6 +109,7 @@ import common.entity.animal.EntitySquid;
|
|||
import common.entity.animal.EntityWolf;
|
||||
import common.entity.item.EntityBoat;
|
||||
import common.entity.item.EntityMinecart;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.init.EntityRegistry;
|
||||
import common.init.TileRegistry;
|
||||
|
@ -327,7 +328,7 @@ public abstract class Converter {
|
|||
}
|
||||
|
||||
private static void mapBlock(State state, int id, int data) {
|
||||
BLOCK_MAP[(id << 4) | data] = (char)State.ID_MAP.get(state);
|
||||
BLOCK_MAP[(id << 4) | data] = (char)BlockRegistry.getId(state);
|
||||
}
|
||||
|
||||
private static void mapBlock(State state, int id, int ... values) {
|
||||
|
|
|
@ -44,39 +44,25 @@ public class Region {
|
|||
removed.add(id);
|
||||
}
|
||||
Map<String, Character> mapping = Maps.newHashMap();
|
||||
Map<String, List<Character>> current = Maps.newHashMap();
|
||||
Set<Character> taken = Sets.newHashSet();
|
||||
List<String> missing = Lists.newArrayList();
|
||||
for(int z = 0; z < 4096; z++) {
|
||||
Block block = BlockRegistry.getBlockById(z);
|
||||
if(block != Blocks.air) {
|
||||
for(int n = 0; n < 16; n++) {
|
||||
State state = block.getStateFromMeta(n);
|
||||
String id = state.getId();
|
||||
List<Character> ids = current.get(id);
|
||||
char mid = (char)State.ID_MAP.get(state);
|
||||
if(ids == null) {
|
||||
current.put(id, Lists.newArrayList(mid));
|
||||
}
|
||||
else {
|
||||
ids.add(mid);
|
||||
continue;
|
||||
}
|
||||
if(tag.hasChar(id)) {
|
||||
char bid = tag.getChar(id);
|
||||
if(bid == 0) {
|
||||
missing.add(id);
|
||||
continue;
|
||||
}
|
||||
mapping.put(id, bid);
|
||||
taken.add(bid);
|
||||
removed.remove(id);
|
||||
Log.IO.debug("Bestehende Block-ID %d = %s", (int)bid, id);
|
||||
}
|
||||
else {
|
||||
missing.add(id);
|
||||
}
|
||||
for(State state : BlockRegistry.states()) {
|
||||
if(state.getBlock() == Blocks.air)
|
||||
continue;
|
||||
String id = BlockRegistry.getName(state);
|
||||
if(tag.hasChar(id)) {
|
||||
char bid = tag.getChar(id);
|
||||
if(bid == 0) {
|
||||
missing.add(id);
|
||||
continue;
|
||||
}
|
||||
mapping.put(id, bid);
|
||||
taken.add(bid);
|
||||
removed.remove(id);
|
||||
Log.IO.debug("Bestehende Block-ID %d = %s", (int)bid, id);
|
||||
}
|
||||
else {
|
||||
missing.add(id);
|
||||
}
|
||||
}
|
||||
char bid = 1;
|
||||
|
@ -91,11 +77,9 @@ public class Region {
|
|||
}
|
||||
for(Entry<String, Character> entry : mapping.entrySet()) {
|
||||
bid = entry.getValue();
|
||||
List<Character> ids = current.get(entry.getKey());
|
||||
DECODE_MAP[bid] = ids.get(0);
|
||||
for(char id : ids) {
|
||||
ENCODE_MAP[id] = bid;
|
||||
}
|
||||
char ids = (char)BlockRegistry.getId(BlockRegistry.byName(entry.getKey(), null));
|
||||
DECODE_MAP[bid] = ids;
|
||||
ENCODE_MAP[ids] = bid;
|
||||
}
|
||||
for(String id : removed) {
|
||||
tag.remove(id);
|
||||
|
@ -559,7 +543,7 @@ public class Region {
|
|||
int invalid = 0;
|
||||
for(int n = 0; n < ticks.size(); ++n) {
|
||||
TagObject tick = ticks.get(n);
|
||||
Block block = BlockRegistry.getRegisteredBlock(tick.getString("i"));
|
||||
Block block = BlockRegistry.byName(tick.getString("i"));
|
||||
|
||||
if(block != Blocks.air) { // FIX
|
||||
world.scheduleBlockUpdate(new BlockPos(tick.getInt("x"), tick.getInt("y"), tick.getInt("z")), block,
|
||||
|
@ -671,7 +655,7 @@ public class Region {
|
|||
if(tic.getBlock() == Blocks.air)
|
||||
continue;
|
||||
TagObject tick = new TagObject();
|
||||
String res = BlockRegistry.getNameFromBlock(tic.getBlock());
|
||||
String res = BlockRegistry.getName(tic.getBlock());
|
||||
tick.setString("i", res == null ? "" : res);
|
||||
tick.setInt("x", tic.position.getX());
|
||||
tick.setInt("y", tic.position.getY());
|
||||
|
|
|
@ -1,27 +1,28 @@
|
|||
package server.worldgen;
|
||||
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.world.State;
|
||||
|
||||
public class ChunkPrimer {
|
||||
public final int height;
|
||||
private final short[] data;
|
||||
private final char[] data;
|
||||
|
||||
public ChunkPrimer(int height) {
|
||||
this.data = new short[Math.max(height, 256) * 256];
|
||||
this.data = new char[Math.max(height, 256) * 256];
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public short[] getData() {
|
||||
public char[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public State get(int x, int y, int z) {
|
||||
State state = State.ID_MAP.getByValue(this.data[x << 4 | z | y << 8]);
|
||||
State state = BlockRegistry.byId(this.data[x << 4 | z | y << 8]);
|
||||
return state != null ? state : Blocks.air.getState();
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z, State state) {
|
||||
this.data[x << 4 | z | y << 8] = (short)State.ID_MAP.get(state);
|
||||
this.data[x << 4 | z | y << 8] = (char)BlockRegistry.getId(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,19 +404,19 @@ public class StructureVillage
|
|||
protected void writeTags(TagObject tagCompound)
|
||||
{
|
||||
super.writeTags(tagCompound);
|
||||
tagCompound.setString("CA", BlockRegistry.getNameFromBlock(this.cropTypeA));
|
||||
tagCompound.setString("CB", BlockRegistry.getNameFromBlock(this.cropTypeB));
|
||||
tagCompound.setString("CC", BlockRegistry.getNameFromBlock(this.cropTypeC));
|
||||
tagCompound.setString("CD", BlockRegistry.getNameFromBlock(this.cropTypeD));
|
||||
tagCompound.setString("CA", BlockRegistry.getName(this.cropTypeA));
|
||||
tagCompound.setString("CB", BlockRegistry.getName(this.cropTypeB));
|
||||
tagCompound.setString("CC", BlockRegistry.getName(this.cropTypeC));
|
||||
tagCompound.setString("CD", BlockRegistry.getName(this.cropTypeD));
|
||||
}
|
||||
|
||||
protected void readTags(TagObject tagCompound)
|
||||
{
|
||||
super.readTags(tagCompound);
|
||||
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeC = BlockRegistry.getRegisteredBlock(tagCompound.getString("CC")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeD = BlockRegistry.getRegisteredBlock(tagCompound.getString("CD")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeA = BlockRegistry.byName(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeB = BlockRegistry.byName(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeC = BlockRegistry.byName(tagCompound.getString("CC")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeD = BlockRegistry.byName(tagCompound.getString("CD")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
}
|
||||
|
||||
private BlockCrops func_151559_a(Random rand)
|
||||
|
@ -513,15 +513,15 @@ public class StructureVillage
|
|||
protected void writeTags(TagObject tagCompound)
|
||||
{
|
||||
super.writeTags(tagCompound);
|
||||
tagCompound.setString("CA", BlockRegistry.getNameFromBlock(this.cropTypeA));
|
||||
tagCompound.setString("CB", BlockRegistry.getNameFromBlock(this.cropTypeB));
|
||||
tagCompound.setString("CA", BlockRegistry.getName(this.cropTypeA));
|
||||
tagCompound.setString("CB", BlockRegistry.getName(this.cropTypeB));
|
||||
}
|
||||
|
||||
protected void readTags(TagObject tagCompound)
|
||||
{
|
||||
super.readTags(tagCompound);
|
||||
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeA = BlockRegistry.byName(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
this.cropTypeB = BlockRegistry.byName(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat;
|
||||
}
|
||||
|
||||
private BlockCrops func_151560_a(Random rand)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue