more block data fixes
This commit is contained in:
parent
eb815a8e21
commit
ea76cecba3
24 changed files with 115 additions and 242 deletions
|
@ -1,7 +1,6 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.Collection;
|
||||
import common.init.BlockRegistry;
|
||||
import common.tags.TagObject;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
|
@ -19,7 +18,7 @@ public class CommandBlock extends Command {
|
|||
|
||||
this.addString("block", false, new StringCompleter() {
|
||||
public Collection<String> complete(CommandEnvironment env) {
|
||||
return BlockRegistry.REGISTRY.getKeys();
|
||||
return State.getKeys();
|
||||
}
|
||||
});
|
||||
this.addBlockPos("position", true);
|
||||
|
@ -30,7 +29,7 @@ public class CommandBlock extends Command {
|
|||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String block, BlockPos position, WorldServer world, TagObject tag) {
|
||||
State state = BlockRegistry.getFromIdName(block, null);
|
||||
State state = State.getState(block, null);
|
||||
if(state == null)
|
||||
throw new RunException("Block '%s' existiert nicht", block);
|
||||
boolean success = world.setState(position, state);
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.ItemRegistry;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import server.command.Command;
|
||||
|
@ -20,7 +19,7 @@ public class CommandItem extends Command {
|
|||
|
||||
this.addString("item", false, new StringCompleter() {
|
||||
public Collection<String> complete(CommandEnvironment env) {
|
||||
return ItemRegistry.REGISTRY.getKeys();
|
||||
return ItemStack.getKeys();
|
||||
}
|
||||
});
|
||||
this.setParamsOptional();
|
||||
|
@ -31,7 +30,7 @@ public class CommandItem extends Command {
|
|||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String item, int amount, TagObject tag, List<EntityNPC> players) {
|
||||
ItemStack stack = ItemRegistry.getFromIdName(item, null);
|
||||
ItemStack stack = ItemStack.getStack(item, null);
|
||||
if(stack == null)
|
||||
throw new RunException("Gegenstand '%s' existiert nicht", item);
|
||||
stack.setTagCompound(tag);
|
||||
|
|
|
@ -5,7 +5,6 @@ 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;
|
||||
|
@ -31,7 +30,7 @@ public class ChunkServer extends Chunk {
|
|||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
for(int by = 0; by < height; ++by) {
|
||||
State state = BlockRegistry.STATEMAP.getByValue(data[bx << 4 | bz | by << 8]);
|
||||
State state = State.ID_MAP.getByValue(data[bx << 4 | bz | by << 8]);
|
||||
if(state != null && state.getBlock() != Blocks.air) {
|
||||
int y = by >> 4;
|
||||
BlockArray arr = this.getArray(y);
|
||||
|
|
|
@ -51,7 +51,6 @@ 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;
|
||||
|
@ -272,7 +271,7 @@ public abstract class Converter {
|
|||
}
|
||||
|
||||
private static void mapBlock(State state, int id, int data) {
|
||||
BLOCK_MAP[(id << 4) | data] = (char)BlockRegistry.STATEMAP.get(state);
|
||||
BLOCK_MAP[(id << 4) | data] = (char)State.ID_MAP.get(state);
|
||||
}
|
||||
|
||||
private static void mapBlock(State state, int id) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class Region {
|
|||
State state = block.getStateFromMeta(n);
|
||||
String id = state.getId();
|
||||
List<Character> ids = current.get(id);
|
||||
char mid = (char)BlockRegistry.STATEMAP.get(state);
|
||||
char mid = (char)State.ID_MAP.get(state);
|
||||
if(ids == null) {
|
||||
current.put(id, Lists.newArrayList(mid));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package server.worldgen;
|
||||
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.world.State;
|
||||
|
||||
|
@ -18,11 +17,11 @@ public class ChunkPrimer {
|
|||
}
|
||||
|
||||
public State get(int x, int y, int z) {
|
||||
State state = BlockRegistry.STATEMAP.getByValue(this.data[x << 4 | z | y << 8]);
|
||||
State state = State.ID_MAP.getByValue(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)BlockRegistry.STATEMAP.get(state);
|
||||
this.data[x << 4 | z | y << 8] = (short)State.ID_MAP.get(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import common.biome.Biome;
|
||||
import common.block.Block;
|
||||
import common.block.artificial.BlockSlab;
|
||||
import common.block.artificial.BlockStairs;
|
||||
import common.block.foliage.BlockCrops;
|
||||
import common.block.foliage.BlockLog;
|
||||
import common.block.tech.BlockTorch;
|
||||
import common.collect.Lists;
|
||||
|
@ -381,10 +381,10 @@ public class StructureVillage
|
|||
|
||||
public static class Field1 extends StructureVillage.Village
|
||||
{
|
||||
private Block cropTypeA;
|
||||
private Block cropTypeB;
|
||||
private Block cropTypeC;
|
||||
private Block cropTypeD;
|
||||
private BlockCrops cropTypeA;
|
||||
private BlockCrops cropTypeB;
|
||||
private BlockCrops cropTypeC;
|
||||
private BlockCrops cropTypeD;
|
||||
|
||||
public Field1()
|
||||
{
|
||||
|
@ -413,13 +413,13 @@ public class StructureVillage
|
|||
protected void readTags(TagObject tagCompound)
|
||||
{
|
||||
super.readTags(tagCompound);
|
||||
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA"));
|
||||
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB"));
|
||||
this.cropTypeC = BlockRegistry.getRegisteredBlock(tagCompound.getString("CC"));
|
||||
this.cropTypeD = BlockRegistry.getRegisteredBlock(tagCompound.getString("CD"));
|
||||
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;
|
||||
}
|
||||
|
||||
private Block func_151559_a(Random rand)
|
||||
private BlockCrops func_151559_a(Random rand)
|
||||
{
|
||||
switch (rand.zrange(5))
|
||||
{
|
||||
|
@ -469,14 +469,14 @@ public class StructureVillage
|
|||
|
||||
for (int i = 1; i <= 7; ++i)
|
||||
{
|
||||
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeC.getStateFromMeta(randomIn.range(2, 7)), 7, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeC.getStateFromMeta(randomIn.range(2, 7)), 8, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeD.getStateFromMeta(randomIn.range(2, 7)), 10, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeD.getStateFromMeta(randomIn.range(2, 7)), 11, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeC.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 7, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeC.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 8, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeD.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 10, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeD.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 11, 1, i, structureBoundingBoxIn);
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
|
@ -494,8 +494,8 @@ public class StructureVillage
|
|||
|
||||
public static class Field2 extends StructureVillage.Village
|
||||
{
|
||||
private Block cropTypeA;
|
||||
private Block cropTypeB;
|
||||
private BlockCrops cropTypeA;
|
||||
private BlockCrops cropTypeB;
|
||||
|
||||
public Field2()
|
||||
{
|
||||
|
@ -520,11 +520,11 @@ public class StructureVillage
|
|||
protected void readTags(TagObject tagCompound)
|
||||
{
|
||||
super.readTags(tagCompound);
|
||||
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA"));
|
||||
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB"));
|
||||
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;
|
||||
}
|
||||
|
||||
private Block func_151560_a(Random rand)
|
||||
private BlockCrops func_151560_a(Random rand)
|
||||
{
|
||||
switch (rand.zrange(5))
|
||||
{
|
||||
|
@ -570,10 +570,10 @@ public class StructureVillage
|
|||
|
||||
for (int i = 1; i <= 7; ++i)
|
||||
{
|
||||
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 1, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeA.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 2, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 4, 1, i, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, this.cropTypeB.getState().withProperty(BlockCrops.AGE, randomIn.range(2, 7)), 5, 1, i, structureBoundingBoxIn);
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue