More battery work, algorithm semi-working

This commit is contained in:
Aidan Brady 2013-08-04 02:48:17 -04:00
parent bea61449b4
commit 64706f7a37
3 changed files with 65 additions and 8 deletions

View file

@ -53,7 +53,7 @@ public class BatteryManager implements ITickHandler
* @param inventory - inventory of the battery
* @param tileEntity - battery TileEntity
*/
public static void updateCache(int inventoryID, HashSet<ItemStack> inventory, TileEntityBattery tileEntity)
public static void updateCache(int inventoryID, Set<ItemStack> inventory, TileEntityBattery tileEntity)
{
if(!dynamicInventories.containsKey(inventoryID))
{

View file

@ -156,8 +156,14 @@ public class BatteryUpdateProtocol
structure.height = Math.abs(ymax-ymin)+1;
structure.width = Math.abs(zmax-zmin)+1;
if(structure.locations.contains(new Vector3(pointer)))
if(structure.locations.contains(new Vector3(pointer)) && structure.height > 1 && structure.length > 1 && structure.width > 1)
{
System.out.println("Bingo");
System.out.println("Height: " + structure.height);
System.out.println("Length: " + structure.length);
System.out.println("Width: " + structure.width);
System.out.println("Volume: " + structure.locations.size());
structureFound = structure;
return;
}

View file

@ -6,6 +6,7 @@ package resonantinduction.battery;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@ -25,17 +26,67 @@ public class TileEntityBattery extends TileEntityBase
public SynchronizedBatteryData structure;
public int inventoryID;
public boolean prevStructure;
public TileEntityBattery()
{
doPacket = false;
}
public boolean clientHasStructure;
public int inventoryID;
@Override
public void updateEntity()
{
super.updateEntity();
ticks++;
//DO NOT SUPER
if(worldObj.isRemote)
{
if(structure == null)
{
structure = new SynchronizedBatteryData();
}
prevStructure = clientHasStructure;
}
if(playersUsing.size() > 0 && ((worldObj.isRemote && !clientHasStructure) || (!worldObj.isRemote && structure == null)))
{
for(EntityPlayer player : playersUsing)
{
player.closeScreen();
}
}
if(!worldObj.isRemote)
{
if(inventoryID != -1 && structure == null)
{
BatteryManager.updateCache(inventoryID, inventory, this);
}
if(structure == null && ticks == 5)
{
update();
}
if(prevStructure != (structure != null))
{
//packet
}
prevStructure = structure != null;
if(structure != null)
{
structure.didTick = false;
if(inventoryID != -1)
{
BatteryManager.updateCache(inventoryID, structure.inventory, this);
inventory = structure.inventory;
}
}
}
}
@Override