Skip to content

Commit

Permalink
Fix some NBT errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander committed Feb 17, 2014
1 parent fa49ead commit 69c8fd8
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 60 deletions.
6 changes: 2 additions & 4 deletions src/main/java/tconstruct/blocks/LiquidMetalFinite.java
Expand Up @@ -9,10 +9,9 @@
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;
import tconstruct.common.TContent;
import tconstruct.common.TRepo;
import tconstruct.library.TConstructRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class LiquidMetalFinite extends BlockFluidFinite
{
Expand Down Expand Up @@ -41,7 +40,6 @@ public void registerBlockIcons (IIconRegister iconRegister)
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
if (side == 0 || side == 1)
Expand All @@ -63,4 +61,4 @@ public void onEntityCollidedWithBlock (World par1World, int x, int y, int z, Ent
entity.setFire(15);
}
}
}
}
Expand Up @@ -129,7 +129,7 @@ public void readNetworkNBT (NBTTagCompound tags)
{
super.readNetworkNBT(tags);

NBTTagList tanks = tags.getTagList("Tanks", 9);
NBTTagList tanks = tags.getTagList("Tanks", 10);
if (tanks != null)
{
lavaTanks.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/blocks/logic/SmelteryLogic.java
Expand Up @@ -1104,7 +1104,7 @@ public void readFromNBT (NBTTagCompound tags)
meltingTemps = tags.getIntArray("MeltingTemps");
activeTemps = tags.getIntArray("ActiveTemps");

NBTTagList liquidTag = tags.getTagList("Liquids", 9);
NBTTagList liquidTag = tags.getTagList("Liquids", 10);
moltenMetal.clear();

for (int iter = 0; iter < liquidTag.tagCount(); iter++)
Expand Down
Expand Up @@ -71,7 +71,7 @@ public void writeToNBT (NBTTagCompound par1NBTTagCompound)
public void readFromNBT (NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", 9);
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", 10);
this.inventory = new ItemStack[this.getSizeInventory()];

for (int i = 0; i < nbttaglist.tagCount(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/entity/CartEntity.java
Expand Up @@ -698,7 +698,7 @@ protected void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)

if (getSizeInventory() > 0)
{
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 9);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10);
this.cargoItems = new ItemStack[this.getSizeInventory()];

for (int var3 = 0; var3 < var2.tagCount(); ++var3)
Expand Down
Expand Up @@ -3,7 +3,7 @@
public class FluidRenderProperties
{

// Constant defaults
//Constant defaults
public static final FluidRenderProperties DEFAULT_TABLE = new FluidRenderProperties(Applications.TABLE);
public static final FluidRenderProperties DEFAULT_BASIN = new FluidRenderProperties(Applications.BASIN);

Expand Down
Expand Up @@ -180,7 +180,7 @@ public FluidTankInfo[] getMultiTankInfo ()
@Override
public void readNetworkNBT (NBTTagCompound tags)
{
NBTTagList liquidTag = tags.getTagList("Liquids", 9);
NBTTagList liquidTag = tags.getTagList("Liquids", 10);
fluidlist.clear();

for (int iter = 0; iter < liquidTag.tagCount(); iter++)
Expand Down
68 changes: 24 additions & 44 deletions src/main/java/tconstruct/library/component/TankLayerScan.java
@@ -1,21 +1,14 @@
package tconstruct.library.component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;

import mantle.blocks.iface.IFacingLogic;
import mantle.blocks.iface.IMasterLogic;
import mantle.blocks.iface.IServantLogic;
import mantle.world.CoordTuple;
import mantle.world.CoordTupleSort;
import java.util.*;

import mantle.blocks.iface.*;
import mantle.world.*;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.*;
import net.minecraft.tileentity.TileEntity;
import tconstruct.TConstruct;
import tconstruct.library.util.*;

public class TankLayerScan extends LogicComponent
{
Expand All @@ -38,14 +31,7 @@ public class TankLayerScan extends LogicComponent
protected CoordTuple returnStone;

private static boolean debug = System.getenv("DBG_MANTLE_TankLayerScan") != null;
private static int MAX_LAYER_RECURSION_DEPTH = System.getProperty("os.arch").equals("amd64") ? 4000 : 2000; // Recursion
// causes
// overflows
// on
// 32-bit,
// so reduce
// if not
// 64-bit
private static int MAX_LAYER_RECURSION_DEPTH = System.getProperty("os.arch").equals("amd64") ? 4000 : 2000; // Recursion causes overflows on 32-bit, so reduce if not 64-bit

public TankLayerScan(TileEntity te, Block... ids)
{
Expand All @@ -72,7 +58,7 @@ public void checkValidStructure ()
blockCoords.clear();
airCoords.clear();
boolean validAir = false;
// Check for air space in front of and behind the structure
//Check for air space in front of and behind the structure
byte dir = getDirection();
switch (getDirection())
{
Expand All @@ -88,7 +74,7 @@ public void checkValidStructure ()
break;
}

// Recurse the structure
//Recurse the structure
boolean validBlocks = false;

int xPos = 0, zPos = 0;
Expand Down Expand Up @@ -126,7 +112,7 @@ public void checkValidStructure ()
blockCoords.clear();
bricks = 0;

// Does the actual adding of blocks in the ring
//Does the actual adding of blocks in the ring
boolean sealed = floodTest(master.xCoord + xPos, master.yCoord, master.zCoord + zPos);
if (!world.isRemote && debug)
{
Expand All @@ -136,7 +122,7 @@ public void checkValidStructure ()

if (sealed)
{
blockCoords.add(new CoordTuple(master.xCoord, master.yCoord, master.zCoord)); // Don't forget me!
blockCoords.add(new CoordTuple(master.xCoord, master.yCoord, master.zCoord)); //Don't forget me!
layerAirCoords = new HashSet<CoordTuple>(airCoords);
layerBlockCoords = new HashSet<CoordTuple>(blockCoords);

Expand All @@ -157,7 +143,7 @@ public void checkValidStructure ()
}
}

// @SuppressWarnings({ "unchecked" })
//@SuppressWarnings({ "unchecked" })
protected void finalizeStructure ()
{
Collections.sort(blockCoords, new CoordTupleSort());
Expand Down Expand Up @@ -204,8 +190,7 @@ private byte getDirection ()
protected boolean checkAir (int x, int y, int z)
{
Block block = world.getBlock(x, y, z);
if (block == null || world.isAirBlock(x, y, z))// || block ==
// TContent.tankAir)
if (block == null || world.isAirBlock(x, y, z))// || block == TContent.tankAir)
return true;

return false;
Expand Down Expand Up @@ -304,9 +289,9 @@ public int recurseStructureDown (int y)
if (checkAir(coord.x, y, coord.z))
{
boolean valid = true;
addAirBlock(coord.x, y, coord.z); // Don't skip first one
addAirBlock(coord.x, y, coord.z); //Don't skip first one

// Air blocks
//Air blocks
while (i.hasNext())
{
coord = (CoordTuple) i.next();
Expand All @@ -321,7 +306,7 @@ public int recurseStructureDown (int y)
}
}

// Bricks
//Bricks
i = layerBlockCoords.iterator();
while (i.hasNext())
{
Expand All @@ -341,7 +326,7 @@ public int recurseStructureDown (int y)
}
else if (checkServant(coord.x, y, coord.z))
{
// Bottom floor. All blocks, please vacate the elevator
//Bottom floor. All blocks, please vacate the elevator
boolean valid = true;
while (i.hasNext())
{
Expand Down Expand Up @@ -374,7 +359,7 @@ public int recurseStructureUp (int y)
{
boolean valid = true;

// Bricks
//Bricks
while (i.hasNext())
{
coord = (CoordTuple) i.next();
Expand All @@ -388,7 +373,7 @@ public int recurseStructureUp (int y)
}
}

// Air blocks
//Air blocks
if (valid)
{
i = layerAirCoords.iterator();
Expand Down Expand Up @@ -453,7 +438,7 @@ public void recheckStructure ()
}
else
{
if (structureTop == 0) // Workaround for missing data
if (structureTop == 0) //Workaround for missing data
{
for (CoordTuple coord : blockCoords)
structureTop = coord.y;
Expand Down Expand Up @@ -488,10 +473,7 @@ protected void invalidateBlocksAbove (int height)
}
}

/**
* Do any necessary cleanup here. Remove air blocks, invalidate servants,
* etc
*/
/** Do any necessary cleanup here. Remove air blocks, invalidate servants, etc */
public void cleanup ()
{
Iterator i = blockCoords.iterator();
Expand All @@ -511,7 +493,7 @@ public void cleanup ()
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
NBTTagList layerAir = tags.getTagList("AirLayer", 9);
NBTTagList layerAir = tags.getTagList("AirLayer", 10);
if (layerAir != null)
{
layerAirCoords.clear();
Expand All @@ -523,7 +505,7 @@ public void readFromNBT (NBTTagCompound tags)
}
}

NBTTagList blocks = tags.getTagList("Blocks", 9);
NBTTagList blocks = tags.getTagList("Blocks", 10);
if (blocks != null)
{
blockCoords.clear();
Expand All @@ -535,7 +517,7 @@ public void readFromNBT (NBTTagCompound tags)
}
}

NBTTagList air = tags.getTagList("Air", 9);
NBTTagList air = tags.getTagList("Air", 10);
if (air != null)
{
airCoords.clear();
Expand All @@ -549,7 +531,6 @@ public void readFromNBT (NBTTagCompound tags)
structureTop = tags.getInteger("structureTop");
}

@Override
public void readNetworkNBT (NBTTagCompound tags)
{
completeStructure = tags.getBoolean("Complete");
Expand Down Expand Up @@ -582,7 +563,6 @@ public void writeToNBT (NBTTagCompound tags)
tags.setInteger("structureTop", structureTop);
}

@Override
public void writeNetworkNBT (NBTTagCompound tags)
{
tags.setBoolean("Complete", completeStructure);
Expand Down
Expand Up @@ -53,7 +53,7 @@ public void modify (ItemStack[] input, ItemStack armor)
NBTTagList attributes;
if (baseTag.hasKey("AttributeModifiers"))
{
attributes = baseTag.getTagList("AttributeModifiers", 9);
attributes = baseTag.getTagList("AttributeModifiers", 10);
for (int iter = 0; iter < attributes.tagCount(); iter++)
{
NBTTagCompound tag = (NBTTagCompound) attributes.getCompoundTagAt(iter);
Expand Down
Expand Up @@ -50,7 +50,7 @@ public void modify (ItemStack[] input, ItemStack armor)
NBTTagList attributes;
if (baseTag.hasKey("AttributeModifiers"))
{
attributes = baseTag.getTagList("AttributeModifiers", 9);
attributes = baseTag.getTagList("AttributeModifiers", 10);
for (int iter = 0; iter < attributes.tagCount(); iter++)
{
NBTTagCompound tag = (NBTTagCompound) attributes.getCompoundTagAt(iter);
Expand Down
Expand Up @@ -50,7 +50,7 @@ public void modify (ItemStack[] input, ItemStack armor)
NBTTagList attributes;
if (baseTag.hasKey("AttributeModifiers"))
{
attributes = baseTag.getTagList("AttributeModifiers", 9);
attributes = baseTag.getTagList("AttributeModifiers", 10);
for (int iter = 0; iter < attributes.tagCount(); iter++)
{
NBTTagCompound tag = (NBTTagCompound) attributes.getCompoundTagAt(iter);
Expand Down
Expand Up @@ -48,7 +48,7 @@ public void modify (ItemStack[] input, ItemStack armor)
NBTTagList attributes;
if (baseTag.hasKey("AttributeModifiers"))
{
attributes = baseTag.getTagList("AttributeModifiers", 9);
attributes = baseTag.getTagList("AttributeModifiers", 10);
for (int iter = 0; iter < attributes.tagCount(); iter++)
{
NBTTagCompound tag = (NBTTagCompound) attributes.getCompoundTagAt(iter);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/util/player/ArmorExtended.java
Expand Up @@ -243,7 +243,7 @@ public void saveToNBT (EntityPlayer entityplayer)
public void readFromNBT (EntityPlayer entityplayer)
{
NBTTagCompound tags = entityplayer.getEntityData();
NBTTagList tagList = tags.getTagList("TConstruct.Inventory", 9);
NBTTagList tagList = tags.getTagList("TConstruct.Inventory", 10);
for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
Expand Down
Expand Up @@ -144,7 +144,7 @@ public void saveToNBT (EntityPlayer entityplayer)
public void readFromNBT (EntityPlayer entityplayer)
{
NBTTagCompound tags = entityplayer.getEntityData();
NBTTagList tagList = tags.getTagList("TConstruct.Knapsack", 9);
NBTTagList tagList = tags.getTagList("TConstruct.Knapsack", 10);
for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
Expand Down

0 comments on commit 69c8fd8

Please sign in to comment.