add item command, remove legacy ids

This commit is contained in:
Sen 2025-06-12 12:28:37 +02:00
parent 678f37e184
commit 1dea7e9645
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
38 changed files with 272 additions and 197 deletions

View file

@ -1926,7 +1926,7 @@ public class Client implements IThreadListener {
}
StringBuilder str = new StringBuilder(
"Schaue auf: " + BlockRegistry.REGISTRY.getNameForObject(block.getBlock()) + " [" + BlockRegistry.getIdFromBlock(block.getBlock()) +
"Schaue auf: " + BlockRegistry.getNameFromBlock(block.getBlock()) + " [" + BlockRegistry.getIdFromBlock(block.getBlock()) +
":" + block.getBlock().getMetaFromState(block) + "]" + "\n" +
String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ())
);
@ -1967,7 +1967,7 @@ public class Client implements IThreadListener {
: "Rüstung: n/a, Pfeile: n/a") + "\n" +
// ItemStack held = ((EntityLiving)entity).getHeldItem();
(held != null ?
"Gegens.: " + ItemRegistry.REGISTRY.getNameForObject(held.getItem()) + " x" + held.size + " (" + held.getMetadata() + ")" : "Gegens.: n/a") + "\n" +
"Gegens.: " + ItemRegistry.getNameFromItem(held.getItem()) + " x" + held.size + " (" + held.getMetadata() + ")" : "Gegens.: n/a") + "\n" +
"Eigens.: " + (entity.dead ? "D" : " ") + (entity.noClip ? "N" : " ") + (entity.onGround ? "G" : " ")
+ (entity.canBeCollidedWith() ? "C" : " ") + (entity.canBePushed() ? "P" : " ")
+ (entity.isBurning() ? "B" : " ") // + (entity.isInvisible() ? "I" : " ") // + (entity.isSilent() ? "S" : " ")

View file

@ -408,7 +408,7 @@ public class BlockRenderer
TextureMap texturemap = Client.CLIENT.getTextureMapBlocks();
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
BlockLiquid block = FluidRegistry.getStaticBlock(z);
String name = BlockRegistry.REGISTRY.getNameForObject(block).toString();
String name = BlockRegistry.getNameFromBlock(block).toString();
TextureAtlasSprite[] sprites = new TextureAtlasSprite[] {texturemap.getAtlasSprite("blocks/" + name + "_still"), texturemap.getAtlasSprite("blocks/" + name + "_flow")};
this.fluids.put(FluidRegistry.getFluidBlock(z), sprites);
this.fluids.put(block, sprites);

View file

@ -83,13 +83,13 @@ public class ItemModelMesher
// public void registerItem(Item itm, int subType, String identifier)
// {
// this.register(itm, subType, new ResourceLocation(identifier, "inventory"));
//// String id = ItemRegistry.REGISTRY.getNameForObject(itm).toString();
//// String id = ItemRegistry.getNameFromItem(itm).toString();
//// if(id.equals(identifier)) {
////// throw new IllegalArgumentException("Duplikat: " + identifier);
//// Log.DATA.info("MATCHING: " + ItemRegistry.REGISTRY.getNameForObject(itm) + ":" + subType);
//// Log.DATA.info("MATCHING: " + ItemRegistry.getNameFromItem(itm) + ":" + subType);
//// }
//// else {
//// Log.DATA.info("MISMATCH: " + ItemRegistry.REGISTRY.getNameForObject(itm) + ":" + subType + ": " + identifier);
//// Log.DATA.info("MISMATCH: " + ItemRegistry.getNameFromItem(itm) + ":" + subType + ": " + identifier);
//// }
// }
@ -124,7 +124,7 @@ public class ItemModelMesher
for(ItemStack stack : stacks) {
this.simpleShapesCache.put(this.getIndex(item, stack.getMetadata()),
this.modelManager.getModel("item/" +
ItemRegistry.REGISTRY.getNameForObject(item).toString() + "#" + stack.getMetadata() + '#' + "inventory"));
ItemRegistry.getNameFromItem(item).toString() + "#" + stack.getMetadata() + '#' + "inventory"));
}
stacks.clear();
}

View file

@ -42,7 +42,7 @@ public abstract class ModelBakery
static {
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
String name = BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)).toString();
String name = BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)).toString();
LOCATIONS_BUILTIN_TEXTURES.add("blocks/" + name + "_flow");
LOCATIONS_BUILTIN_TEXTURES.add("blocks/" + name + "_still");
}
@ -63,7 +63,7 @@ public abstract class ModelBakery
models.put(MISSING, (ModelBlock)new ModelBlock(null).add().all());
variants.add(MISSING);
for(Entry<State, String> entry : map.entrySet()) {
ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(ModelBlock.PROVIDER, BlockRegistry.REGISTRY.getNameForObject(entry.getKey().getBlock())
ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(ModelBlock.PROVIDER, BlockRegistry.getNameFromBlock(entry.getKey().getBlock())
.toString(), entry.getKey());
// ResourceLocation blk = new ResourceLocation(entry.getValue().getName());
models.put(entry.getValue(), model);
@ -144,8 +144,8 @@ public abstract class ModelBakery
// {
item.getRenderItems(item, stacks);
for(ItemStack stack : stacks) {
String resourcelocation = "item/" + ItemRegistry.REGISTRY.getNameForObject(item).toString() + "#" + stack.getMetadata() + '#' + "inventory";
models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.REGISTRY.getNameForObject(item).toString(), stack.getMetadata()));
String resourcelocation = "item/" + ItemRegistry.getNameFromItem(item).toString() + "#" + stack.getMetadata() + '#' + "inventory";
models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item).toString(), stack.getMetadata()));
itemLocations.add(resourcelocation);
}
stacks.clear();

View file

@ -33,7 +33,7 @@ public class ModelManager
for(Block block : BlockRegistry.REGISTRY) {
if(block.getRenderType() != 3) {
this.builtin.add(block);
// Log.info("Builtin: " + BlockRegistry.REGISTRY.getNameForObject(block));
// Log.info("Builtin: " + BlockRegistry.getNameFromBlock(block));
}
else {
IProperty<?>[] ignored = block.getIgnoredProperties();
@ -109,7 +109,7 @@ public class ModelManager
{
String texture = this.liquidMap.get(block);
if(texture == null)
this.liquidMap.put(block, texture = "blocks/" + BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(FluidRegistry.getFluidMeta((BlockLiquid)block))) + "_still");
this.liquidMap.put(block, texture = "blocks/" + BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(FluidRegistry.getFluidMeta((BlockLiquid)block))) + "_still");
return this.texMap.getAtlasSprite(texture);
}
}

View file

@ -30,7 +30,7 @@ public class MultiStateMap extends StateMap
if (this.name == null)
{
s = BlockRegistry.REGISTRY.getNameForObject(state.getBlock());
s = BlockRegistry.getNameFromBlock(state.getBlock());
}
else
{

View file

@ -8,6 +8,6 @@ public class SingleStateMap extends StateMap
{
protected String getResourceLocation(State state)
{
return BlockRegistry.REGISTRY.getNameForObject(state.getBlock()).toString() + '#' + this.getPropertyString(state.getProperties());
return BlockRegistry.getNameFromBlock(state.getBlock()).toString() + '#' + this.getPropertyString(state.getProperties());
}
}

View file

@ -45,9 +45,9 @@ public class TextureMap extends Texture
block.getAnimatedTextures(map);
}
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
map.put("blocks/" + BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) + "_still",
map.put("blocks/" + BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)) + "_still",
FluidRegistry.getStaticAnim(z));
map.put("blocks/" + BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) + "_flow",
map.put("blocks/" + BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)) + "_flow",
FluidRegistry.getFluidAnim(z));
}
for(Entry<String, Object> entry : map.entrySet()) {

View file

@ -28,12 +28,12 @@ public class EntityAITakePlace extends EntityAIBase
}
public StackKey(ItemStack stack) {
this.item = ItemRegistry.REGISTRY.getNameForObject(stack.getItem()).toString();
this.item = ItemRegistry.getNameFromItem(stack.getItem()).toString();
this.meta = stack.getItem().getMaxDamage() <= 0 ? stack.getMetadata() : -1;
}
// public boolean isSame(ItemStack stack) {
// return this.item.equals(ItemRegistry.REGISTRY.getNameForObject(stack.getItem()).toString()) &&
// return this.item.equals(ItemRegistry.getNameFromItem(stack.getItem()).toString()) &&
// (stack.getItem().getMaxDamage() > 0 || stack.getMetadata() == this.meta);
// }

View file

@ -815,7 +815,7 @@ public class BlockStairs extends Block
}
public Model getModel(ModelProvider provider, String name, State state) {
String primary = this.modelBlock.getModel(provider, BlockRegistry.REGISTRY.getNameForObject(this.modelBlock).toString(), this.modelState)
String primary = this.modelBlock.getModel(provider, BlockRegistry.getNameFromBlock(this.modelBlock).toString(), this.modelState)
.getPrimary();
return provider.getModel(primary)
.stairs(state.getValue(HALF) == EnumHalf.TOP, state.getValue(SHAPE) == EnumShape.INNER_RIGHT ||

View file

@ -75,7 +75,7 @@ public class BlockWorkbench extends Block
public String getGuiID()
{
return BlockRegistry.REGISTRY.getNameForObject(this.block);
return BlockRegistry.getNameFromBlock(this.block);
}
}
}

View file

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import common.biome.Biome;
import common.biome.IBiome;
import common.block.Block;
import common.block.foliage.LeavesType;
import common.collect.Lists;
import common.collect.Maps;
@ -221,6 +222,41 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
private long seed = 0L;
public static void toIdName(TagObject tag, String name, String dname, State state) {
if(state == null)
return;
tag.setString(name, BlockRegistry.getNameFromBlock(state.getBlock()));
if(state != state.getBlock().getState())
tag.setByte(dname, (byte)state.getBlock().getMetaFromState(state));
}
public static void toIdName(TagObject tag, String name, State state) {
toIdName(tag, name, name + "Data", state);
}
public static void toIdName(TagObject tag, State state) {
toIdName(tag, "Block", "Data", state);
}
public static State getFromIdName(TagObject tag, String name, String dname, State def) {
if(!tag.hasString(name))
return def;
Block block = BlockRegistry.getRegisteredBlock(tag.getString(name));
if(tag.hasByte(dname)) {
byte data = tag.getByte(dname);
return data < 0 || data >= 16 ? block.getState() : block.getStateFromMeta(data);
}
return block.getState();
}
public static State getFromIdName(TagObject tag, String name, State def) {
return getFromIdName(tag, name, name + "Data", def);
}
public static State getFromIdName(TagObject tag, State def) {
return getFromIdName(tag, "Block", "Data", def);
}
public Dimension(int id, String name) {
this.id = id;
this.name = name;
@ -865,8 +901,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.seed = tag.getLong("Seed");
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
this.seaLevel = tag.getInt("SeaLevel");
this.filler = BlockRegistry.getFromIdName(tag.getString("FillerBlock"), Blocks.stone.getState());
this.liquid = BlockRegistry.getFromIdName(tag.getString("LiquidBlock"), Blocks.water.getState());
this.filler = getFromIdName(tag, "FillerBlock", Blocks.stone.getState());
this.liquid = getFromIdName(tag, "LiquidBlock", Blocks.water.getState());
}
}
if(generator) {
@ -913,16 +949,19 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.defaultWeather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather;
this.defaultLeaves = LeavesType.getByName(tag.getString("DefaultLeaves"));
this.defaultLeaves = this.defaultLeaves == null ? LeavesType.SPRING : this.defaultLeaves;
this.top = BlockRegistry.getFromIdName(tag.getString("TopBlock"), Blocks.dirt.getState());
this.surface = BlockRegistry.getFromIdName(tag.getString("SurfaceBlock"), Blocks.grass.getState());
this.alt1 = BlockRegistry.getFromIdName(tag.getString("AltBlock1"), Blocks.gravel.getState());
this.alt2 = BlockRegistry.getFromIdName(tag.getString("AltBlock2"), Blocks.sand.getState());
this.caveFiller = BlockRegistry.getFromIdName(tag.getString("CaveFillBlock"), Blocks.lava.getState());
this.top = getFromIdName(tag, "TopBlock", Blocks.dirt.getState());
this.surface = getFromIdName(tag, "SurfaceBlock", Blocks.grass.getState());
this.alt1 = getFromIdName(tag, "AltBlock1", Blocks.gravel.getState());
this.alt2 = getFromIdName(tag, "AltBlock2", Blocks.sand.getState());
this.caveFiller = getFromIdName(tag, "CaveFillBlock", Blocks.lava.getState());
if(tag.hasStringArray("Layers")) {
String[] list = tag.getStringArray("Layers");
byte[] data = tag.hasByteArray("LayerData") ? tag.getByteArray("LayerData") : null;
data = data != null && data.length != list.length ? null : data;
this.layers = new State[list.length];
for(int z = 0; z < this.layers.length; z++) {
this.layers[z] = BlockRegistry.getFromIdName(list[z], Blocks.stone.getState());
Block block = BlockRegistry.getRegisteredBlock(list[z]);
this.layers[z] = data == null ? block.getState() : block.getStateFromMeta(data[z]);
}
}
else {
@ -1008,7 +1047,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = tag.getList("Ores");
for(int z = 0; z < list.size(); z++) {
TagObject gen = list.get(z);
this.ores.add(new Ore(BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
this.ores.add(new Ore(getFromIdName(gen, "Block", "Data", Blocks.iron_ore.getState()),
gen.getInt("Count"), gen.getInt("Add"), gen.getInt("Size"),
gen.getInt("MinC"), gen.getInt("MaxS"), gen.getBool("Distrib")));
}
@ -1019,9 +1058,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
for(int z = 0; z < list.size(); z++) {
TagObject gen = list.get(z);
this.lakes.add(new Lake(
BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
gen.hasString("Filler") ? BlockRegistry.getFromIdName(gen.getString("Filler"), null) : null,
gen.hasString("Top") ? BlockRegistry.getFromIdName(gen.getString("Top"), null) : null,
getFromIdName(gen, "Block", "Data", Blocks.iron_ore.getState()),
getFromIdName(gen, "Filler", null), getFromIdName(gen, "Top", null),
gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Ratiod")));
}
}
@ -1031,7 +1069,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
for(int z = 0; z < list.size(); z++) {
TagObject gen = list.get(z);
this.liquids.add(new Liquid(
BlockRegistry.getFromIdName(gen.getString("Block"), Blocks.iron_ore.getState()),
getFromIdName(gen, "Block", "Data", Blocks.iron_ore.getState()),
gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Lower")));
}
}
@ -1105,8 +1143,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
tag.setLong("Seed", this.seed);
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
tag.setInt("SeaLevel", this.seaLevel);
tag.setString("FillerBlock", BlockRegistry.toIdName(this.filler));
tag.setString("LiquidBlock", BlockRegistry.toIdName(this.liquid));
toIdName(tag, "FillerBlock", this.filler);
toIdName(tag, "LiquidBlock", this.liquid);
}
}
if(generator) {
@ -1153,17 +1191,24 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
tag.setBool("SemiFixed", this.semiFixed);
tag.setString("DefaultWeather", this.defaultWeather.getName());
tag.setString("DefaultLeaves", this.defaultLeaves.getName());
tag.setString("TopBlock", BlockRegistry.toIdName(this.top));
tag.setString("SurfaceBlock", BlockRegistry.toIdName(this.surface));
tag.setString("AltBlock1", BlockRegistry.toIdName(this.alt1));
tag.setString("AltBlock2", BlockRegistry.toIdName(this.alt2));
tag.setString("CaveFillBlock", BlockRegistry.toIdName(this.caveFiller));
toIdName(tag, "TopBlock", this.top);
toIdName(tag, "SurfaceBlock", this.surface);
toIdName(tag, "AltBlock1", this.alt1);
toIdName(tag, "AltBlock2", this.alt2);
toIdName(tag, "CaveFillBlock", this.caveFiller);
if(this.layers != null) {
boolean dataUsed = false;
String[] list = new String[this.layers.length];
byte[] data = new byte[this.layers.length];
for(int z = 0; z < this.layers.length; z++) {
list[z] = BlockRegistry.toIdName(this.layers[z]);
State state = this.layers[z];
list[z] = BlockRegistry.getNameFromBlock(state.getBlock());
data[z] = (byte)state.getBlock().getMetaFromState(state);
dataUsed |= state.getBlock().getState() != state;
}
tag.setStringArray("Layers", list);
if(dataUsed)
tag.setByteArray("LayerData", data);
}
if(this.addBiomes != null) {
String[] list = new String[this.addBiomes.length];
@ -1204,7 +1249,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = Lists.newArrayList();
for(Ore gen : this.ores) {
TagObject ore = new TagObject();
ore.setString("Block", BlockRegistry.toIdName(gen.state()));
toIdName(ore, "Block", "Data", gen.state());
ore.setBool("Distrib", gen.dist());
ore.setInt("Size", gen.size());
ore.setInt("Count", gen.count());
@ -1219,11 +1264,9 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = Lists.newArrayList();
for(Lake gen : this.lakes) {
TagObject lake = new TagObject();
lake.setString("Block", BlockRegistry.toIdName(gen.state()));
if(gen.filler() != null)
lake.setString("Filler", BlockRegistry.toIdName(gen.filler()));
if(gen.top() != null)
lake.setString("Top", BlockRegistry.toIdName(gen.top()));
toIdName(lake, "Block", "Data", gen.state());
toIdName(lake, "Filler", gen.filler());
toIdName(lake, "Top", gen.top());
lake.setBool("Ratiod", gen.ratiod());
lake.setInt("Chance", gen.chance());
lake.setInt("Min", gen.minHeight());
@ -1236,7 +1279,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = Lists.newArrayList();
for(Liquid gen : this.liquids) {
TagObject liquid = new TagObject();
liquid.setString("Block", BlockRegistry.toIdName(gen.state()));
toIdName(liquid, "Block", "Data", gen.state());
liquid.setBool("Lower", gen.lower());
liquid.setInt("Chance", gen.chance());
liquid.setInt("Min", gen.minHeight());

View file

@ -761,29 +761,13 @@ public abstract class EntityCart extends Entity implements IWorldNameable
if (tagCompund.hasString("DisplayTile"))
{
Block block = BlockRegistry.getByIdFallback(tagCompund.getString("DisplayTile"));
Block block = BlockRegistry.getRegisteredBlock(tagCompund.getString("DisplayTile"));
if (block == null)
{
this.func_174899_a(Blocks.air.getState());
}
else
{
this.func_174899_a(block.getStateFromMeta(i));
}
this.func_174899_a(block.getStateFromMeta(i));
}
else
{
Block block1 = BlockRegistry.getBlockById(tagCompund.getInt("DisplayTile"));
if (block1 == null)
{
this.func_174899_a(Blocks.air.getState());
}
else
{
this.func_174899_a(block1.getStateFromMeta(i));
}
this.func_174899_a(Blocks.air.getState());
}
this.setDisplayTileOffset(tagCompund.getInt("DisplayOffset"));
@ -804,8 +788,8 @@ public abstract class EntityCart extends Entity implements IWorldNameable
{
tagCompound.setBool("CustomDisplayTile", true);
State iblockstate = this.getDisplayTile();
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(iblockstate.getBlock());
tagCompound.setString("DisplayTile", resourcelocation == null ? "" : resourcelocation.toString());
String resourcelocation = BlockRegistry.getNameFromBlock(iblockstate.getBlock());
tagCompound.setString("DisplayTile", resourcelocation == null ? "" : resourcelocation);
tagCompound.setInt("DisplayData", iblockstate.getBlock().getMetaFromState(iblockstate));
tagCompound.setInt("DisplayOffset", this.getDisplayTileOffset());
}

View file

@ -203,7 +203,7 @@ public class EntityFalling extends Entity implements IObjectData
protected void writeEntity(TagObject tagCompound)
{
Block block = this.fallTile != null ? this.fallTile.getBlock() : Blocks.air;
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(block);
String resourcelocation = BlockRegistry.getNameFromBlock(block);
tagCompound.setString("Block", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("Data", (byte)block.getMetaFromState(this.fallTile));
tagCompound.setByte("Time", (byte)this.fallTime);
@ -222,7 +222,7 @@ public class EntityFalling extends Entity implements IObjectData
if (tagCompund.hasString("Block"))
{
this.fallTile = BlockRegistry.getByIdFallback(tagCompund.getString("Block")).getStateFromMeta(i);
this.fallTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("Block")).getStateFromMeta(i);
}
else
{

View file

@ -465,7 +465,7 @@ public class EntityItem extends Entity
return this.getCustomNameTag();
String comp = super.getTypeName();
comp += " (" + this.getEntityItem().size + " * " +
ItemRegistry.REGISTRY.getNameForObject(this.getEntityItem().getItem()) + ":" + this.getEntityItem().getMetadata() + ")";
ItemRegistry.getNameFromItem(this.getEntityItem().getItem()) + ":" + this.getEntityItem().getMetadata() + ")";
return comp;
}

View file

@ -478,7 +478,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
tagCompound.setShort("zTile", (short)this.zTile);
tagCompound.setShort("life", (short)this.ticksInGround);
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
String id = BlockRegistry.getNameFromBlock(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setByte("inData", (byte)this.inData);
@ -500,7 +500,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile"));
}
else
{

View file

@ -523,7 +523,7 @@ public class EntityHook extends Entity implements IObjectData
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
String id = BlockRegistry.getNameFromBlock(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setByte("shake", (byte)this.shake);
@ -541,7 +541,7 @@ public class EntityHook extends Entity implements IObjectData
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile"));
}
else
{

View file

@ -259,7 +259,7 @@ public abstract class EntityProjectile extends Entity
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
String id = BlockRegistry.getNameFromBlock(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setBool("inGround", this.inGround);
@ -280,7 +280,7 @@ public abstract class EntityProjectile extends Entity
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile"));
}
else
{

View file

@ -309,7 +309,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
if(this.inTile != null) {
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
String id = BlockRegistry.getNameFromBlock(this.inTile);
tagCompound.setString("inTile", id == null ? "" : id.toString());
}
tagCompound.setByte("shake", (byte)this.throwableShake);
@ -334,7 +334,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile
if (tagCompund.hasString("inTile"))
{
this.inTile = BlockRegistry.getByIdFallback(tagCompund.getString("inTile"));
this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile"));
}
else
{

View file

@ -141,13 +141,17 @@ public abstract class BlockRegistry {
return REGISTRY.getIDForObject(block);
}
public static String getNameFromBlock(Block block) {
return REGISTRY.getNameForObject(block);
}
public static int getStateId(State state) {
Block block = state.getBlock();
return getIdFromBlock(block) + (block.getMetaFromState(state) << 12);
}
public static Block getBlockById(int id) {
return (Block)REGISTRY.getObjectById(id);
return REGISTRY.getObjectById(id);
}
public static State getStateById(int id) {
@ -156,65 +160,21 @@ public abstract class BlockRegistry {
return getBlockById(i).getStateFromMeta(j);
}
public static Block getByNameOrId(String name) {
Block block = REGISTRY.getObjectExact(name);
if(block == null) {
try {
return REGISTRY.getObjectExact(Integer.parseInt(name));
}
catch(NumberFormatException e) {
}
}
return block;
}
public static Block getByIdFallback(String name) {
// String loc = StringUtils.trimColon(name);
if(REGISTRY.containsKey(name)) {
return REGISTRY.getObject(name);
}
else {
try {
return REGISTRY.getObjectById(Integer.parseInt(name));
}
catch(NumberFormatException e) {
return null;
}
}
}
public static String toIdName(State block) {
int meta = block.getBlock().getMetaFromState(block);
return REGISTRY.getNameForObject(block.getBlock()).toString() +
((meta == block.getBlock().getMetaFromState(block.getBlock().getState())) ? "" : (":" + meta));
}
public static State getFromIdName(String name, State def) {
if(name == null) {
if(name == null)
return def;
}
String[] tok = name.split(":");
if(tok.length < 1 || tok.length > 2) {
if(tok.length < 1 || tok.length > 2)
return def;
}
Block block = getByNameOrId(tok[0]);
// if(block == null) {
// try {
// block = getBlockById(Integer.parseUnsignedInt(tok[0]));
// }
// catch(NumberFormatException e) {
// }
// }
if(block == null) {
Block block = REGISTRY.getObjectExact(tok[0]);
if(block == null)
return def;
}
byte data;
if(tok.length == 2) {
try {
int i = (byte)Integer.parseUnsignedInt(tok[1]);
if(i >= 16) {
int i = Integer.parseUnsignedInt(tok[1]);
if(i >= 16)
return def;
}
data = (byte)i;
}
catch(NumberFormatException e) {

View file

@ -430,10 +430,10 @@ public abstract class Blocks {
}
if(!blocks.isEmpty()) {
List<Block> list = Lists.newArrayList(blocks);
Collections.sort(list, Comparator.comparing(block -> BlockRegistry.REGISTRY.getNameForObject(block)));
Collections.sort(list, Comparator.comparing(block -> BlockRegistry.getNameFromBlock(block)));
System.err.printf("\n*** -------------------------------------------------------------- ***\n\n");
for(Block block : list) {
String name = BlockRegistry.REGISTRY.getNameForObject(block);
String name = BlockRegistry.getNameFromBlock(block);
System.err.printf("\tpublic static final %s %s = get(\"%s\");\n", block.getClass().getSimpleName(), name, name);
}
System.err.printf("\n^^^ " + Blocks.class.getCanonicalName() + ": Blockliste ist unvollständig, Bitte neuen Quellcode einfügen ^^^\n");

View file

@ -256,7 +256,7 @@ public abstract class DispenserRegistry {
// REGISTRY.putObject(Items.water_bucket, ibehaviordispenseitem);
// REGISTRY.putObject(Items.fluid_bucket, ibehaviordispenseitem);
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
REGISTRY.putObject(ItemRegistry.getRegisteredItem(BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) +
REGISTRY.putObject(ItemRegistry.getRegisteredItem(BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)) +
"_bucket"), ibehaviordispenseitem);
}
REGISTRY.putObject(Items.bucket, new BehaviorDefaultDispenseItem()
@ -283,7 +283,7 @@ public abstract class DispenserRegistry {
// else
if (material.isLiquid() && block instanceof BlockLiquid && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
{
item = ItemRegistry.getRegisteredItem(BlockRegistry.REGISTRY.getNameForObject(block instanceof BlockDynamicLiquid
item = ItemRegistry.getRegisteredItem(BlockRegistry.getNameFromBlock(block instanceof BlockDynamicLiquid
? FluidRegistry.getStaticBlock((BlockDynamicLiquid)block) : block) +
"_bucket"); // Items.fluid_bucket;
// meta = FluidRegistry.getFluidMeta((BlockLiquid)iblockstate.getBlock());

View file

@ -136,6 +136,10 @@ public abstract class ItemRegistry {
return item == null ? 0 : REGISTRY.getIDForObject(item);
}
public static String getNameFromItem(Item item) {
return REGISTRY.getNameForObject(item);
}
public static Item getItemById(int id) {
return REGISTRY.getObjectById(id);
}
@ -148,6 +152,30 @@ public abstract class ItemRegistry {
return REGISTRY.getObject(name);
}
public static ItemStack getFromIdName(String name, ItemStack def) {
if(name == null)
return def;
String[] tok = name.split(":");
if(tok.length < 1 || tok.length > 2)
return def;
Item item = REGISTRY.getObject(tok[0]);
if(item == null)
return def;
short data = 0;
if(tok.length == 2) {
try {
int i = Integer.parseUnsignedInt(tok[1]);
if(i >= 32768)
return def;
data = (short)i;
}
catch(NumberFormatException e) {
return def;
}
}
return new ItemStack(item, 1, data);
}
private static ItemBlock registerFlat(Block block) {
ItemBlock item = new ItemBlock(block, "");
registerBlock(block, item);
@ -161,13 +189,13 @@ public abstract class ItemRegistry {
}
private static void registerBlock(Block block, ItemBlock item) {
REGISTRY.register(BlockRegistry.getIdFromBlock(block), BlockRegistry.REGISTRY.getNameForObject(block), item);
REGISTRY.register(BlockRegistry.getIdFromBlock(block), BlockRegistry.getNameFromBlock(block), item);
BLOCKMAP.put(block, item);
}
private static void registerSpecial(Block block) {
if(BLOCKMAP.containsKey(block) || SPECIALIZED.contains(block))
throw new IllegalArgumentException("Block " + BlockRegistry.REGISTRY.getNameForObject(block) + " ist bereits registriert");
throw new IllegalArgumentException("Block " + BlockRegistry.getNameFromBlock(block) + " ist bereits registriert");
SPECIALIZED.add(block);
}
@ -181,7 +209,7 @@ public abstract class ItemRegistry {
if(item.getBlock() == null)
throw new IllegalArgumentException("Unbenanntes Item benötigt einen Block");
registerSpecial(item.getBlock());
REGISTRY.register(BlockRegistry.getIdFromBlock(item.getBlock()), BlockRegistry.REGISTRY.getNameForObject(item.getBlock()), item);
REGISTRY.register(BlockRegistry.getIdFromBlock(item.getBlock()), BlockRegistry.getNameFromBlock(item.getBlock()), item);
}
private static void registerTools(ToolMaterial material, String name, String prefix) {
@ -332,7 +360,7 @@ public abstract class ItemRegistry {
})).setDisplay("Felsen"));
for(BlockLeaves leaves : BlockLeaves.LEAVES) {
registerBlock(leaves, new ItemLeaves(leaves)); // .setDisplay(BlockRegistry.REGISTRY.getNameForObject(leaves)));
registerBlock(leaves, new ItemLeaves(leaves)); // .setDisplay(BlockRegistry.getNameFromBlock(leaves)));
}
for(BlockSlab slab : BlockSlab.SLABS) {
registerBlock(slab, new ItemSlab(slab));
@ -351,13 +379,13 @@ public abstract class ItemRegistry {
Item bucket = (new ItemBucket(null, false)).setDisplay("Eimer");
registerItem("bucket", bucket);
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
registerItem(BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) +
registerItem(BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)) +
"_bucket", new ItemBucket(FluidRegistry.getFluidBlock(z), false).setDisplay("Eimer")
.setContainerItem(bucket));
}
registerItem("recursive_bucket", (new ItemBucket(null, true)).setDisplay("Unendlicher Eimer"));
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
registerItem("recursive_" + BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(z)) +
registerItem("recursive_" + BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)) +
"_bucket", new ItemBucket(FluidRegistry.getFluidBlock(z), true).setDisplay("Flutender Eimer"));
}
registerItem("milk_bucket", (new ItemBucketMilk()).setDisplay("Milch").setContainerItem(bucket));
@ -645,7 +673,7 @@ public abstract class ItemRegistry {
for(Block block : BlockRegistry.REGISTRY) {
if(!BLOCKMAP.containsKey(block) && !SPECIALIZED.contains(block))
registerBlock(block, new ItemBlock(block));
// Log.info("Block " + BlockRegistry.REGISTRY.getNameForObject(block) + " hat kein Item");
// Log.info("Block " + BlockRegistry.getNameFromBlock(block) + " hat kein Item");
}
}
}

View file

@ -666,10 +666,10 @@ public abstract class Items {
}
if(!items.isEmpty()) {
List<Item> list = Lists.newArrayList(items);
Collections.sort(list, Comparator.comparing(item -> ItemRegistry.REGISTRY.getNameForObject(item)));
Collections.sort(list, Comparator.comparing(item -> ItemRegistry.getNameFromItem(item)));
System.err.printf("\n*** -------------------------------------------------------------- ***\n\n");
for(Item item : list) {
String name = ItemRegistry.REGISTRY.getNameForObject(item);
String name = ItemRegistry.getNameFromItem(item);
System.err.printf("\tpublic static final %s %s = get(\"%s\");\n", item.getClass().getSimpleName(), name, name);
}
System.err.printf("\n^^^ " + Items.class.getCanonicalName() + ": Gegenstandsliste ist unvollständig, Bitte neuen Quellcode einfügen ^^^\n");

View file

@ -742,13 +742,13 @@ public abstract class UniverseRegistry {
dtag.setBool("SemiFixed", false);
// dtag.setString("DefaultWeather", Weather.CLEAR.getName());
dtag.setString("DefaultLeaves", LeavesType.SPRING.getName());
dtag.setString("FillerBlock", BlockRegistry.toIdName(Blocks.air.getState()));
dtag.setString("TopBlock", BlockRegistry.toIdName(Blocks.air.getState()));
dtag.setString("SurfaceBlock", BlockRegistry.toIdName(Blocks.air.getState()));
dtag.setString("AltBlock1", BlockRegistry.toIdName(Blocks.air.getState()));
dtag.setString("AltBlock2", BlockRegistry.toIdName(Blocks.air.getState()));
dtag.setString("LiquidBlock", BlockRegistry.toIdName(Blocks.air.getState()));
dtag.setString("CaveFillBlock", BlockRegistry.toIdName(Blocks.air.getState()));
Dimension.toIdName(dtag, "FillerBlock", Blocks.air.getState());
Dimension.toIdName(dtag, "TopBlock", Blocks.air.getState());
Dimension.toIdName(dtag, "SurfaceBlock", Blocks.air.getState());
Dimension.toIdName(dtag, "AltBlock1", Blocks.air.getState());
Dimension.toIdName(dtag, "AltBlock2", Blocks.air.getState());
Dimension.toIdName(dtag, "LiquidBlock", Blocks.air.getState());
Dimension.toIdName(dtag, "CaveFillBlock", Blocks.air.getState());
}
dtag.merge(ptag);
dim.fromTags(dtag);

View file

@ -218,8 +218,8 @@ public class ItemBlock extends Item
public Model getModel(ModelProvider provider, String name, int meta) {
return this.flatTexture != null ? provider.getModel(this.getTransform(), !this.flatTexture.isEmpty() ? this.flatTexture :
this.block.getModel(provider,
BlockRegistry.REGISTRY.getNameForObject(this.block).toString(), this.block.getStateFromMeta(this.getMetadata(meta))).getPrimary() /* "blocks/" + name */) :
BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.getMetadata(meta))).getPrimary() /* "blocks/" + name */) :
provider.getModel(this.block.getModel(provider,
BlockRegistry.REGISTRY.getNameForObject(this.block).toString(), this.block.getStateFromMeta(this.getMetadata(meta))), this.getTransform());
BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.getMetadata(meta))), this.getTransform());
}
}

View file

@ -176,7 +176,7 @@ public class ItemBucket extends Item
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
Block block = iblockstate.getBlock();
return this.fillBucket(itemStackIn, playerIn, new ItemStack(
ItemRegistry.getRegisteredItem(BlockRegistry.REGISTRY.getNameForObject(block instanceof BlockDynamicLiquid
ItemRegistry.getRegisteredItem(BlockRegistry.getNameFromBlock(block instanceof BlockDynamicLiquid
? FluidRegistry.getStaticBlock((BlockDynamicLiquid)block) : block) +
"_bucket"), 1, 0));
}
@ -342,6 +342,6 @@ public class ItemBucket extends Item
// return super.getModel(name, meta);
// else
// return provider.getModel(this.getTransform(), meta < 0 || meta >= FluidRegistry.getNumFluids() ? "bucket" :
// (BlockRegistry.REGISTRY.getNameForObject(FluidRegistry.getStaticBlock(meta)) + "_bucket"));
// (BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(meta)) + "_bucket"));
// }
}

View file

@ -103,8 +103,8 @@ public class ItemDye extends Item
}
State iblockstate = worldIn.getState(pos);
if(iblockstate.getBlock() instanceof BlockBed) {
Block bedBlock = BlockRegistry.getByNameOrId(enumdyecolor.getName() + "_bed");
if(bedBlock != null) {
Block bedBlock = BlockRegistry.getRegisteredBlock(enumdyecolor.getName() + "_bed");
if(bedBlock != Blocks.air) {
if (iblockstate.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT)
{
pos = pos.offset(iblockstate.getValue(BlockBed.FACING));

View file

@ -177,7 +177,7 @@ public final class ItemStack
*/
public TagObject writeTags(TagObject tag)
{
String resourcelocation = ItemRegistry.REGISTRY.getNameForObject(this.item);
String resourcelocation = ItemRegistry.getNameFromItem(this.item);
tag.setString("id", resourcelocation == null ? "air" : resourcelocation.toString());
tag.setInt("Count", this.size);
tag.setShort("Damage", (short)this.meta);
@ -973,7 +973,7 @@ public final class ItemStack
this.isItemDamaged() ? (this.getMaxDamage() - this.getItemDamage()) : this.getMaxDamage(), this.getMaxDamage()));
}
list.add(TextColor.GRAY + ItemRegistry.REGISTRY.getNameForObject(this.item));
list.add(TextColor.GRAY + ItemRegistry.getNameFromItem(this.item));
if (this.hasTagCompound())
{

View file

@ -201,7 +201,7 @@ public class TileEntityPiston extends TileEntity implements ITickable
public void readTags(TagObject compound)
{
super.readTags(compound);
this.pistonState = BlockRegistry.getBlockById(compound.getInt("blockId")).getStateFromMeta(compound.getInt("blockData"));
this.pistonState = BlockRegistry.getRegisteredBlock(compound.getString("blockId")).getStateFromMeta(compound.getInt("blockData"));
this.pistonFacing = Facing.getFront(compound.getInt("facing"));
this.lastProgress = this.progress = compound.getFloat("progress");
this.extending = compound.getBool("extending");
@ -210,7 +210,7 @@ public class TileEntityPiston extends TileEntity implements ITickable
public void writeTags(TagObject compound)
{
super.writeTags(compound);
compound.setInt("blockId", BlockRegistry.getIdFromBlock(this.pistonState.getBlock()));
compound.setString("blockId", BlockRegistry.getNameFromBlock(this.pistonState.getBlock()));
compound.setInt("blockData", this.pistonState.getBlock().getMetaFromState(this.pistonState));
compound.setInt("facing", this.pistonFacing.getIndex());
compound.setFloat("progress", this.lastProgress);

View file

@ -74,7 +74,7 @@ public class State {
}
else if(!property.getAllowedValues().contains(value)) {
throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block "
+ BlockRegistry.REGISTRY.getNameForObject(this.block) + ", it is not an allowed value");
+ BlockRegistry.getNameFromBlock(this.block) + ", it is not an allowed value");
}
else {
return (State)(this.properties.get(property) == value ? this : (State)this.map.get(property, value));
@ -99,7 +99,7 @@ public class State {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(BlockRegistry.REGISTRY.getNameForObject(this.getBlock()));
sb.append(BlockRegistry.getNameFromBlock(this.getBlock()));
if(!this.getProperties().isEmpty()) {
sb.append("[");
Iterable<String> iter = Iterables.transform(this.getProperties().entrySet(), MAP_ENTRY_TO_STRING);

View file

@ -110,9 +110,8 @@ public abstract class RotationRegistry {
}
}
if(!values.isEmpty()) {
int legacyId = common.init.BlockRegistry.getIdFromBlock(block);
Rotation state = new Rotation(values.toArray(new RotationValue[values.size()]), predicate);
// Log.CONFIG.debug("Block " + game.init.BlockRegistry.REGISTRY.getNameForObject(block) + "/" + legacyId + " mask = " + String.format("0x%x", mask));
// Log.CONFIG.debug("Block " + game.init.BlockRegistry.getNameFromBlock(block) + "/" + legacyId + " mask = " + String.format("0x%x", mask));
// for(RotationValue value : values) {
// Log.CONFIG.debug(" meta " + value.data + " -> " + value.direction.toString());
// }

View file

@ -192,6 +192,14 @@ public abstract class Command implements Executable {
return this.addParameter(new PlayerEntityParser(name, defaulted, policy));
}
protected Command addPlayerEntityList(String name, boolean defaulted, UserPolicy policy) {
return this.addParameter(new PlayerEntityListParser(name, defaulted, policy));
}
protected Command addPlayerEntityList(String name, char shortName, boolean defaulted, UserPolicy policy) {
return this.addParameter(shortName, new PlayerEntityListParser(name, defaulted, policy));
}
protected Command addEntity(String name, boolean defaulted, UserPolicy policy) {
return this.addParameter(new EntityParser(name, defaulted, false, policy));
}

View file

@ -266,6 +266,7 @@ public class CommandEnvironment {
this.registerExecutable(new CommandSv());
this.registerExecutable(new CommandClear());
this.registerExecutable(new CommandEntity());
this.registerExecutable(new CommandItem());
this.registerExecutable(new CommandHelp(this));
}

View file

@ -0,0 +1,63 @@
package server.command.commands;
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;
import server.command.CommandEnvironment;
import server.command.Executor;
import server.command.RunException;
import server.command.StringCompleter;
import server.command.UserPolicy;
public class CommandItem extends Command {
public CommandItem() {
super("item");
this.addString("item", false, new StringCompleter() {
public Collection<String> complete(CommandEnvironment env) {
return ItemRegistry.REGISTRY.getKeys();
}
});
this.setParamsOptional();
this.addInt("amount", 1, ItemStack.MAX_SIZE, 1);
this.addTag("tag", 't');
this.setParamsRequired();
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);
}
public Object exec(CommandEnvironment env, Executor exec, String item, int amount, TagObject tag, List<EntityNPC> players) {
ItemStack stack = ItemRegistry.getFromIdName(item, null);
if(stack == null)
throw new RunException("Gegenstand '%s' existiert nicht", item);
stack.setTagCompound(tag);
int done = 0;
int given = 0;
for(EntityNPC player : players) {
int total = amount;
while(total > 0) {
int added = Math.min(total, stack.getMaxStackSize());
ItemStack st = stack.copy();
st.size = added;
player.inventory.addItemStackToInventory(st);
added -= st.size;
if(added <= 0)
break;
total -= added;
}
total = amount - total;
if(total <= 0)
continue;
exec.logConsole("%d * %s zum Inventar von %s hinzugefügt", total, stack.getDisplayName(), player.getCommandName());
done++;
given += total;
}
if(done > 1)
exec.logConsole("%d * %s an %d Spieler verteilt", given, stack.getDisplayName(), done);
return given;
}
}

View file

@ -1,7 +1,6 @@
package server.world;
import common.block.Block;
import common.init.BlockRegistry;
import common.util.BlockPos;
public class NextTickListEntry implements Comparable<NextTickListEntry>
@ -62,11 +61,6 @@ public class NextTickListEntry implements Comparable<NextTickListEntry>
return this.scheduledTime < p_compareTo_1_.scheduledTime ? -1 : (this.scheduledTime > p_compareTo_1_.scheduledTime ? 1 : (this.priority != p_compareTo_1_.priority ? this.priority - p_compareTo_1_.priority : (this.tickEntryID < p_compareTo_1_.tickEntryID ? -1 : (this.tickEntryID > p_compareTo_1_.tickEntryID ? 1 : 0))));
}
public String toString()
{
return BlockRegistry.getIdFromBlock(this.block) + ": " + this.position + ", " + this.scheduledTime + ", " + this.priority + ", " + this.tickEntryID;
}
public Block getBlock()
{
return this.block;

View file

@ -23,6 +23,7 @@ import common.collect.Lists;
import common.collect.Maps;
import common.entity.Entity;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.EntityRegistry;
import common.log.Log;
import common.tags.TagObject;
@ -455,22 +456,14 @@ public class Region {
int invalid = 0;
for(int n = 0; n < ticks.size(); ++n) {
TagObject tick = ticks.get(n);
Block block;
Block block = BlockRegistry.getRegisteredBlock(tick.getString("i"));
if(tick.hasString("i")) {
block = BlockRegistry.getByIdFallback(tick.getString("i"));
}
else {
block = BlockRegistry.getBlockById(tick.getInt("i"));
}
if(block != null) { // FIX
if(block != Blocks.air) { // FIX
world.scheduleBlockUpdate(new BlockPos(tick.getInt("x"), tick.getInt("y"), tick.getInt("z")), block,
tick.getInt("t"), tick.getInt("p"));
}
else if(invalid++ < 10) {
Log.IO.warn("Unbekannter Block-Tick in Chunk " + x + "," + z + ": " +
(tick.hasString("i") ? ("'" + tick.getString("i") + "'") : ("#" + tick.getInt("i"))));
Log.IO.warn("Unbekannter Block-Tick in Chunk " + x + "," + z + ": '" + tick.getString("i") + "'");
}
}
if(invalid > 10) {
@ -573,9 +566,11 @@ public class Region {
List<TagObject> ticks = Lists.newArrayList();
for(NextTickListEntry tic : tics) {
if(tic.getBlock() == Blocks.air)
continue;
TagObject tick = new TagObject();
String res = BlockRegistry.REGISTRY.getNameForObject(tic.getBlock());
tick.setString("i", res == null ? "" : res.toString());
String res = BlockRegistry.getNameFromBlock(tic.getBlock());
tick.setString("i", res == null ? "" : res);
tick.setInt("x", tic.position.getX());
tick.setInt("y", tic.position.getY());
tick.setInt("z", tic.position.getZ());

View file

@ -406,19 +406,19 @@ public class StructureVillage
protected void writeTags(TagObject tagCompound)
{
super.writeTags(tagCompound);
tagCompound.setInt("CA", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeA));
tagCompound.setInt("CB", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeB));
tagCompound.setInt("CC", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeC));
tagCompound.setInt("CD", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeD));
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));
}
protected void readTags(TagObject tagCompound)
{
super.readTags(tagCompound);
this.cropTypeA = BlockRegistry.getBlockById(tagCompound.getInt("CA"));
this.cropTypeB = BlockRegistry.getBlockById(tagCompound.getInt("CB"));
this.cropTypeC = BlockRegistry.getBlockById(tagCompound.getInt("CC"));
this.cropTypeD = BlockRegistry.getBlockById(tagCompound.getInt("CD"));
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"));
}
private Block func_151559_a(Random rand)
@ -515,15 +515,15 @@ public class StructureVillage
protected void writeTags(TagObject tagCompound)
{
super.writeTags(tagCompound);
tagCompound.setInt("CA", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeA));
tagCompound.setInt("CB", BlockRegistry.REGISTRY.getIDForObject(this.cropTypeB));
tagCompound.setString("CA", BlockRegistry.getNameFromBlock(this.cropTypeA));
tagCompound.setString("CB", BlockRegistry.getNameFromBlock(this.cropTypeB));
}
protected void readTags(TagObject tagCompound)
{
super.readTags(tagCompound);
this.cropTypeA = BlockRegistry.getBlockById(tagCompound.getInt("CA"));
this.cropTypeB = BlockRegistry.getBlockById(tagCompound.getInt("CB"));
this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA"));
this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB"));
}
private Block func_151560_a(Random rand)