cleanup, add warning checks for invalid item/block names in MappingRegistry
This commit is contained in:
parent
5c767249a6
commit
445957588f
3 changed files with 40 additions and 21 deletions
|
@ -243,8 +243,12 @@ public class MappingRegistry {
|
||||||
|
|
||||||
for (Block b : idToBlock) {
|
for (Block b : idToBlock) {
|
||||||
NBTTagCompound sub = new NBTTagCompound();
|
NBTTagCompound sub = new NBTTagCompound();
|
||||||
sub.setString("name",
|
String name = Block.blockRegistry.getNameForObject(b);
|
||||||
Block.blockRegistry.getNameForObject(b));
|
if (name == null || name.length() == 0) {
|
||||||
|
BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() + ") has an empty registry name! This is a bug!");
|
||||||
|
} else {
|
||||||
|
sub.setString("name", name);
|
||||||
|
}
|
||||||
blocksMapping.appendTag(sub);
|
blocksMapping.appendTag(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,8 +258,12 @@ public class MappingRegistry {
|
||||||
|
|
||||||
for (Item i : idToItem) {
|
for (Item i : idToItem) {
|
||||||
NBTTagCompound sub = new NBTTagCompound();
|
NBTTagCompound sub = new NBTTagCompound();
|
||||||
sub.setString("name",
|
String name = Item.itemRegistry.getNameForObject(i);
|
||||||
Item.itemRegistry.getNameForObject(i));
|
if (name == null || name.length() == 0) {
|
||||||
|
BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() + ") has an empty registry name! This is a bug!");
|
||||||
|
} else {
|
||||||
|
sub.setString("name", name);
|
||||||
|
}
|
||||||
itemsMapping.appendTag(sub);
|
itemsMapping.appendTag(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,6 +286,12 @@ public class MappingRegistry {
|
||||||
|
|
||||||
for (int i = 0; i < blocksMapping.tagCount(); ++i) {
|
for (int i = 0; i < blocksMapping.tagCount(); ++i) {
|
||||||
NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
|
NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
|
||||||
|
if (!sub.hasKey("name")) {
|
||||||
|
// Keeping the order correct
|
||||||
|
idToBlock.add(null);
|
||||||
|
BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String name = sub.getString("name");
|
String name = sub.getString("name");
|
||||||
Block b = null;
|
Block b = null;
|
||||||
|
|
||||||
|
@ -299,6 +313,12 @@ public class MappingRegistry {
|
||||||
|
|
||||||
for (int i = 0; i < itemsMapping.tagCount(); ++i) {
|
for (int i = 0; i < itemsMapping.tagCount(); ++i) {
|
||||||
NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
|
NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
|
||||||
|
if (!sub.hasKey("name")) {
|
||||||
|
// Keeping the order correct
|
||||||
|
idToItem.add(null);
|
||||||
|
BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String name = sub.getString("name");
|
String name = sub.getString("name");
|
||||||
Item item = null;
|
Item item = null;
|
||||||
|
|
||||||
|
|
|
@ -86,14 +86,18 @@ public class PacketFluidUpdate extends PacketCoordinates {
|
||||||
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) {
|
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) {
|
||||||
int id = data.readShort();
|
int id = data.readShort();
|
||||||
int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0;
|
int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0;
|
||||||
int color = data.readInt();
|
int color = id != 0 ? data.readInt() : 0xFFFFFF;
|
||||||
|
|
||||||
renderCache[dir.ordinal()] = new FluidRenderData(id, amt, color);
|
renderCache[dir.ordinal()] = new FluidRenderData(id, amt, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) {
|
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) {
|
||||||
|
int amt = Math.min(transLiq.getCapacity(), data.readUnsignedShort());
|
||||||
|
|
||||||
if (renderCache[dir.ordinal()] != null) {
|
if (renderCache[dir.ordinal()] != null) {
|
||||||
renderCache[dir.ordinal()].amount = Math.min(transLiq.getCapacity(), data.readUnsignedShort());
|
renderCache[dir.ordinal()].amount = amt;
|
||||||
|
} else {
|
||||||
|
renderCache[dir.ordinal()] = new FluidRenderData(0, amt, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,12 +115,11 @@ public class PacketFluidUpdate extends PacketCoordinates {
|
||||||
FluidRenderData liquid = renderCache[dir.ordinal()];
|
FluidRenderData liquid = renderCache[dir.ordinal()];
|
||||||
|
|
||||||
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) {
|
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) {
|
||||||
if (liquid != null) {
|
if (liquid != null && liquid.fluidID != 0) {
|
||||||
data.writeShort(liquid.fluidID);
|
data.writeShort(liquid.fluidID);
|
||||||
data.writeInt(liquid.color);
|
data.writeInt(liquid.color);
|
||||||
} else {
|
} else {
|
||||||
data.writeShort(0);
|
data.writeShort(0);
|
||||||
data.writeInt(0xFFFFFF);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) {
|
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) {
|
||||||
|
|
|
@ -108,17 +108,23 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
||||||
return displayFluidLists.get(liquidId);
|
return displayFluidLists.get(liquidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fluid fluid = FluidRegistry.getFluid(liquidId);
|
||||||
|
|
||||||
|
if (fluid == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
DisplayFluidList d = new DisplayFluidList();
|
DisplayFluidList d = new DisplayFluidList();
|
||||||
displayFluidLists.put(liquidId, d);
|
displayFluidLists.put(liquidId, d);
|
||||||
|
|
||||||
RenderInfo block = new RenderInfo();
|
RenderInfo block = new RenderInfo();
|
||||||
|
|
||||||
Fluid fluid = FluidRegistry.getFluid(liquidId);
|
|
||||||
if (fluid.getBlock() != null) {
|
if (fluid.getBlock() != null) {
|
||||||
block.baseBlock = fluid.getBlock();
|
block.baseBlock = fluid.getBlock();
|
||||||
} else {
|
} else {
|
||||||
block.baseBlock = Blocks.water;
|
block.baseBlock = Blocks.water;
|
||||||
}
|
}
|
||||||
|
|
||||||
block.texture = fluid.getStillIcon();
|
block.texture = fluid.getStillIcon();
|
||||||
|
|
||||||
float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
|
float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
|
||||||
|
@ -706,7 +712,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayFluidList d = getListFromBuffer(fluidRenderData, pipe.container.getWorldObj());
|
DisplayFluidList d = getDisplayFluidLists(fluidRenderData.fluidID, pipe.container.getWorldObj());
|
||||||
|
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -749,7 +755,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
||||||
FluidRenderData fluidRenderData = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];
|
FluidRenderData fluidRenderData = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];
|
||||||
|
|
||||||
if (fluidRenderData != null && fluidRenderData.amount > 0) {
|
if (fluidRenderData != null && fluidRenderData.amount > 0) {
|
||||||
DisplayFluidList d = getListFromBuffer(fluidRenderData, pipe.container.getWorldObj());
|
DisplayFluidList d = getDisplayFluidLists(fluidRenderData.fluidID, pipe.container.getWorldObj());
|
||||||
|
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
int stage = (int) ((float) fluidRenderData.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
|
int stage = (int) ((float) fluidRenderData.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
|
||||||
|
@ -772,16 +778,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DisplayFluidList getListFromBuffer(FluidRenderData stack, World world) {
|
|
||||||
int liquidId = stack.fluidID;
|
|
||||||
|
|
||||||
if (liquidId == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDisplayFluidLists(liquidId, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderSolids(Pipe<PipeTransportItems> pipe, double x, double y, double z) {
|
private void renderSolids(Pipe<PipeTransportItems> pipe, double x, double y, double z) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue