mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2126 from MellowArpeggiation/master
NBT Structure fixes
This commit is contained in:
commit
0ab4f215b1
@ -108,6 +108,7 @@ public class BlockDecoModel extends BlockEnumMulti implements INBTTransformable
|
||||
|
||||
@Override
|
||||
public int transformMeta(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
//N: 0b00, S: 0b01, W: 0b10, E: 0b11
|
||||
int rot = meta >> 2;
|
||||
int type = meta & 3;
|
||||
|
||||
@ -260,6 +260,16 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
||||
|
||||
if(te == null || te instanceof TileEntityWandLoot) {
|
||||
// Some generator has broken the TE->block relationship, which, honestly, rude.
|
||||
// so we're just gonna hop in and force update the TE
|
||||
|
||||
MainRegistry.logger.warn("TE set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!");
|
||||
|
||||
te = replaceBlock.createTileEntity(worldObj, replaceMeta);
|
||||
worldObj.setTileEntity(xCoord, yCoord, zCoord, te);
|
||||
}
|
||||
|
||||
if(te instanceof IInventory) {
|
||||
int count = minItems;
|
||||
if(maxItems - minItems > 0) count += worldObj.rand.nextInt(maxItems - minItems);
|
||||
@ -271,15 +281,20 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
|
||||
// Shouldn't happen but let's guard anyway, if it fails we just don't rotate the chest block correctly
|
||||
if(!(worldObj instanceof WorldServer)) return;
|
||||
|
||||
if(fakePlayer == null || fakePlayer.worldObj != worldObj) {
|
||||
fakePlayer = FakePlayerFactory.get((WorldServer)worldObj, FAKE_PROFILE);
|
||||
try {
|
||||
if(fakePlayer == null || fakePlayer.worldObj != worldObj) {
|
||||
fakePlayer = FakePlayerFactory.get((WorldServer)worldObj, FAKE_PROFILE);
|
||||
}
|
||||
|
||||
fakePlayer.rotationYaw = fakePlayer.rotationYawHead = placedRotation;
|
||||
|
||||
ItemStack fakeStack = new ItemStack(replaceBlock, 1, replaceMeta);
|
||||
|
||||
replaceBlock.onBlockPlacedBy(worldObj, xCoord, yCoord, zCoord, fakePlayer, fakeStack);
|
||||
} catch(Exception ex) {
|
||||
MainRegistry.logger.warn("Failed to correctly rotate loot block at: " + xCoord + ", " + yCoord + ", " + zCoord);
|
||||
MainRegistry.logger.catching(ex);
|
||||
}
|
||||
|
||||
fakePlayer.rotationYaw = fakePlayer.rotationYawHead = placedRotation;
|
||||
|
||||
ItemStack fakeStack = new ItemStack(replaceBlock, 1, replaceMeta);
|
||||
|
||||
replaceBlock.onBlockPlacedBy(worldObj, xCoord, yCoord, zCoord, fakePlayer, fakeStack);
|
||||
}
|
||||
|
||||
private List<String> getPoolNames(boolean loot) {
|
||||
@ -306,6 +321,8 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
|
||||
nbt.setInteger("max", maxItems);
|
||||
nbt.setString("pool", poolName);
|
||||
nbt.setFloat("rot", placedRotation);
|
||||
|
||||
nbt.setBoolean("trigger", triggerReplace);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -319,6 +336,8 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
|
||||
placedRotation = nbt.getFloat("rot");
|
||||
|
||||
if(replaceBlock == null) replaceBlock = ModBlocks.deco_loot;
|
||||
|
||||
triggerReplace = nbt.getBoolean("trigger");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -23,51 +23,51 @@ public class RenderRBMKLid extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float i) {
|
||||
|
||||
|
||||
TileEntityRBMKBase control = (TileEntityRBMKBase)te;
|
||||
boolean hasRod = false;
|
||||
boolean cherenkov = false;
|
||||
|
||||
|
||||
if(te instanceof TileEntityRBMKRod) {
|
||||
|
||||
|
||||
TileEntityRBMKRod rod = (TileEntityRBMKRod) te;
|
||||
|
||||
|
||||
if(rod.hasRod)
|
||||
hasRod = true;
|
||||
|
||||
if(rod.lastFluxQuantity > 5)
|
||||
|
||||
if(rod.fluxQuantity > 5)
|
||||
cherenkov = true;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
|
||||
|
||||
int offset = 1;
|
||||
|
||||
|
||||
for(int o = 1; o < 16; o++) {
|
||||
|
||||
|
||||
if(te.getWorldObj().getBlock(te.xCoord, te.yCoord + o, te.zCoord) == te.getBlockType()) {
|
||||
offset = o;
|
||||
|
||||
|
||||
int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord + o, te.zCoord);
|
||||
|
||||
|
||||
if(meta > 5 && meta < 12)
|
||||
break;
|
||||
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
|
||||
|
||||
if(control.hasLid()) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, offset, 0);
|
||||
|
||||
|
||||
int meta = control.getBlockMetadata() - RBMKBase.offset;
|
||||
|
||||
|
||||
if(meta == RBMKBase.DIR_GLASS_LID.ordinal()) {
|
||||
bindTexture(texture_glass);
|
||||
} else {
|
||||
@ -79,7 +79,7 @@ public class RenderRBMKLid extends TileEntitySpecialRenderer {
|
||||
|
||||
cherenkov = false;
|
||||
}
|
||||
|
||||
|
||||
if((control instanceof TileEntityRBMKBoiler || control instanceof TileEntityRBMKHeater) && meta != RBMKBase.DIR_GLASS_LID.ordinal()) {
|
||||
ResourceManager.rbmk_rods_vbo.renderPart("Lid");
|
||||
} else {
|
||||
@ -88,11 +88,11 @@ public class RenderRBMKLid extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
if(hasRod) {
|
||||
GL11.glPushMatrix();
|
||||
bindTexture(texture_rods);
|
||||
|
||||
|
||||
for(int j = 0; j <= offset; j++) {
|
||||
ResourceManager.rbmk_element_vbo.renderPart("Rods");
|
||||
GL11.glTranslated(0, 1, 0);
|
||||
@ -100,7 +100,7 @@ public class RenderRBMKLid extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
if(cherenkov) {
|
||||
GL11.glTranslated(0, 0.75, 0);
|
||||
|
||||
@ -110,11 +110,11 @@ public class RenderRBMKLid extends TileEntitySpecialRenderer {
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(0.4F, 0.9F, 1.0F, 0.1F);
|
||||
|
||||
|
||||
for(double j = 0; j <= offset; j += 0.25) {
|
||||
tess.addVertex(-0.5, j, -0.5);
|
||||
tess.addVertex(-0.5, j, 0.5);
|
||||
|
||||
@ -23,6 +23,7 @@ public interface INBTTransformable {
|
||||
*/
|
||||
|
||||
public static int transformMetaDeco(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
switch(coordBaseMode) {
|
||||
case 1: //West
|
||||
switch(meta) {
|
||||
@ -50,6 +51,7 @@ public interface INBTTransformable {
|
||||
}
|
||||
|
||||
public static int transformMetaDecoModel(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
int rot = (meta + coordBaseMode) % 4;
|
||||
int type = (meta / 4) * 4;
|
||||
|
||||
@ -57,6 +59,7 @@ public interface INBTTransformable {
|
||||
}
|
||||
|
||||
public static int transformMetaStairs(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
switch(coordBaseMode) {
|
||||
case 1: //West
|
||||
if((meta & 3) < 2) //Flip second bit for E/W
|
||||
@ -74,15 +77,13 @@ public interface INBTTransformable {
|
||||
meta = meta ^ 2;
|
||||
break;
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
public static int transformMetaPillar(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 2) return meta; // 180° rotation: X and Z flip, result same
|
||||
|
||||
int type = meta & 3; // lower 2 bits
|
||||
int rot = meta & 12; // upper 2 bits (4 or 8)
|
||||
if(coordBaseMode == 0 || coordBaseMode == 2) return meta;
|
||||
int type = meta & 3;
|
||||
int rot = meta & 12;
|
||||
|
||||
if(rot == 4) return type | 8;
|
||||
if(rot == 8) return type | 4;
|
||||
@ -91,6 +92,7 @@ public interface INBTTransformable {
|
||||
}
|
||||
|
||||
public static int transformMetaDirectional(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
int rot = meta & 3;
|
||||
int other = meta & 12;
|
||||
|
||||
@ -109,6 +111,7 @@ public interface INBTTransformable {
|
||||
}
|
||||
|
||||
public static int transformMetaTorch(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
switch(coordBaseMode) {
|
||||
case 1: //West
|
||||
switch(meta) {
|
||||
@ -136,12 +139,14 @@ public interface INBTTransformable {
|
||||
}
|
||||
|
||||
public static int transformMetaDoor(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
if(meta == 8 || meta == 9) return meta; // ignore top parts
|
||||
|
||||
return transformMetaDirectional(meta, coordBaseMode);
|
||||
}
|
||||
|
||||
public static int transformMetaLever(int meta, int coordBaseMode) {
|
||||
if(coordBaseMode == 0) return meta;
|
||||
if(meta <= 0 || meta >= 7) { //levers suck ass
|
||||
switch(coordBaseMode) {
|
||||
case 1: case 3: //west / east
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user