add item command, remove legacy ids
This commit is contained in:
parent
678f37e184
commit
1dea7e9645
38 changed files with 272 additions and 197 deletions
|
@ -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);
|
||||
// }
|
||||
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class BlockWorkbench extends Block
|
|||
|
||||
public String getGuiID()
|
||||
{
|
||||
return BlockRegistry.REGISTRY.getNameForObject(this.block);
|
||||
return BlockRegistry.getNameFromBlock(this.block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue