Clean up and reformat
This commit is contained in:
parent
747bbd4c3f
commit
e09dc2c489
25 changed files with 489 additions and 482 deletions
|
@ -57,26 +57,26 @@ public class ClientProxy extends CommonProxy
|
|||
{
|
||||
return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPaused()
|
||||
{
|
||||
if(FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
|
||||
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
|
||||
{
|
||||
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
|
||||
|
||||
if(screen != null)
|
||||
|
||||
if (screen != null)
|
||||
{
|
||||
if(screen.doesGuiPauseGame())
|
||||
if (screen.doesGuiPauseGame())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class CommonProxy implements IGuiHandler
|
|||
{
|
||||
return new ContainerBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import resonantinduction.battery.BatteryManager;
|
||||
import resonantinduction.battery.BlockBattery;
|
||||
import resonantinduction.battery.ItemCapacitor;
|
||||
import resonantinduction.battery.TileEntityBattery;
|
||||
|
@ -37,8 +36,6 @@ import cpw.mods.fml.common.network.NetworkMod;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
|
@ -170,7 +167,7 @@ public class ResonantInduction
|
|||
|
||||
ResonantInduction.proxy.registerRenderers();
|
||||
|
||||
TabRI.ITEMSTACK = new ItemStack(blockTesla);
|
||||
TabRI.ITEMSTACK = new ItemStack(blockBattery);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -16,7 +16,7 @@ public interface IBattery
|
|||
public float getEnergyStored(ItemStack itemStack);
|
||||
|
||||
public float getMaxEnergyStored(ItemStack itemStack);
|
||||
|
||||
|
||||
public float getTransfer(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package resonantinduction.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public final class InventoryUtil
|
||||
public final class InventoryUtil
|
||||
{
|
||||
public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side)
|
||||
{
|
||||
|
@ -55,15 +52,15 @@ public final class InventoryUtil
|
|||
{
|
||||
ISidedInventory sidedInventory = (ISidedInventory) inventory;
|
||||
int[] slots = sidedInventory.getAccessibleSlotsFromSide(side);
|
||||
|
||||
|
||||
for (int get = 0; get <= slots.length - 1; get++)
|
||||
{
|
||||
int slotID = slots[get];
|
||||
|
||||
|
||||
if (sidedInventory.isItemValidForSlot(slotID, itemStack) && sidedInventory.canInsertItem(slotID, itemStack, side))
|
||||
{
|
||||
ItemStack inSlot = inventory.getStackInSlot(slotID);
|
||||
|
||||
|
||||
if (inSlot == null)
|
||||
{
|
||||
inventory.setInventorySlotContents(slotID, itemStack);
|
||||
|
@ -75,20 +72,20 @@ public final class InventoryUtil
|
|||
{
|
||||
ItemStack toSet = itemStack.copy();
|
||||
toSet.stackSize += inSlot.stackSize;
|
||||
|
||||
|
||||
inventory.setInventorySlotContents(slotID, toSet);
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize();
|
||||
|
||||
|
||||
ItemStack toSet = itemStack.copy();
|
||||
toSet.stackSize = inSlot.getMaxStackSize();
|
||||
|
||||
|
||||
ItemStack remains = itemStack.copy();
|
||||
remains.stackSize = rejects;
|
||||
|
||||
|
||||
inventory.setInventorySlotContents(slotID, toSet);
|
||||
return remains;
|
||||
}
|
||||
|
@ -96,10 +93,10 @@ public final class InventoryUtil
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack takeTopItemFromInventory(IInventory inventory, int side)
|
||||
{
|
||||
if (!(inventory instanceof ISidedInventory))
|
||||
|
@ -143,7 +140,7 @@ public final class InventoryUtil
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,163 +5,165 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ListUtil
|
||||
public class ListUtil
|
||||
{
|
||||
public static <V> List<V> inverse(List<V> list)
|
||||
{
|
||||
List<V> toReturn = new ArrayList<V>();
|
||||
|
||||
for(int i = list.size()-1; i >= 0; i--)
|
||||
|
||||
for (int i = list.size() - 1; i >= 0; i--)
|
||||
{
|
||||
toReturn.add((V)list.get(i));
|
||||
toReturn.add(list.get(i));
|
||||
}
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static <V> List<V> cap(List<V> list, int cap)
|
||||
{
|
||||
List<V> toReturn = new ArrayList<V>();
|
||||
|
||||
if(list.size() <= cap)
|
||||
|
||||
if (list.size() <= cap)
|
||||
{
|
||||
toReturn = copy(list);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for(V obj : list)
|
||||
|
||||
for (V obj : list)
|
||||
{
|
||||
count++;
|
||||
|
||||
|
||||
toReturn.add(obj);
|
||||
|
||||
if(count == cap)
|
||||
|
||||
if (count == cap)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static <V> List<V> copy(List<V> list)
|
||||
{
|
||||
List<V> toReturn = new ArrayList<V>();
|
||||
|
||||
for(V obj : list)
|
||||
|
||||
for (V obj : list)
|
||||
{
|
||||
toReturn.add(obj);
|
||||
}
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static <V> List<V> merge(List<V> listOne, List<V> listTwo)
|
||||
{
|
||||
List<V> newList = new ArrayList<V>();
|
||||
|
||||
for(V obj : listOne)
|
||||
|
||||
for (V obj : listOne)
|
||||
{
|
||||
newList.add(obj);
|
||||
}
|
||||
|
||||
for(V obj : listTwo)
|
||||
|
||||
for (V obj : listTwo)
|
||||
{
|
||||
newList.add(obj);
|
||||
}
|
||||
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
public static <V> List<V> capRemains(List<V> list, int cap)
|
||||
{
|
||||
List<V> toReturn = new ArrayList<V>();
|
||||
|
||||
if(list.size() <= cap)
|
||||
|
||||
if (list.size() <= cap)
|
||||
{
|
||||
return toReturn;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
List<V> inverse = inverse(list);
|
||||
|
||||
int iterNeeded = list.size()-cap;
|
||||
|
||||
int iterNeeded = list.size() - cap;
|
||||
int count = 0;
|
||||
|
||||
for(V obj : list)
|
||||
|
||||
for (V obj : list)
|
||||
{
|
||||
count++;
|
||||
|
||||
|
||||
toReturn.add(obj);
|
||||
|
||||
if(count == iterNeeded)
|
||||
|
||||
if (count == iterNeeded)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
public static <V> ArrayList<List<V>> split(List<V> list, int divide)
|
||||
{
|
||||
int remain = list.size()%divide;
|
||||
int size = (list.size()-remain)/divide;
|
||||
|
||||
int remain = list.size() % divide;
|
||||
int size = (list.size() - remain) / divide;
|
||||
|
||||
ArrayList<List<V>> toReturn = new ArrayList<List<V>>();
|
||||
|
||||
for(int i = 0; i < divide; i++)
|
||||
|
||||
for (int i = 0; i < divide; i++)
|
||||
{
|
||||
toReturn.add(i, new ArrayList<V>());
|
||||
}
|
||||
|
||||
for(List<V> iterSet : toReturn)
|
||||
|
||||
for (List<V> iterSet : toReturn)
|
||||
{
|
||||
List<V> removed = new ArrayList<V>();
|
||||
|
||||
|
||||
int toAdd = size;
|
||||
|
||||
if(remain > 0)
|
||||
|
||||
if (remain > 0)
|
||||
{
|
||||
remain--;
|
||||
toAdd++;
|
||||
}
|
||||
|
||||
for(V obj : list)
|
||||
|
||||
for (V obj : list)
|
||||
{
|
||||
if(toAdd == 0)
|
||||
if (toAdd == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
iterSet.add(obj);
|
||||
removed.add(obj);
|
||||
toAdd--;
|
||||
}
|
||||
|
||||
for(V obj : removed)
|
||||
|
||||
for (V obj : removed)
|
||||
{
|
||||
list.remove(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static <V> V getTop(List<V> list)
|
||||
{
|
||||
for(V obj : list)
|
||||
for (V obj : list)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static <V> List<V> asList(Set<V> set)
|
||||
{
|
||||
return (List<V>)Arrays.asList(set.toArray());
|
||||
return (List<V>) Arrays.asList(set.toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TileEntityBase extends TileEntity
|
|||
this.initiate();
|
||||
}
|
||||
|
||||
if(doPacket && !worldObj.isRemote)
|
||||
if (doPacket && !worldObj.isRemote)
|
||||
{
|
||||
for (EntityPlayer player : this.playersUsing)
|
||||
{
|
||||
|
|
|
@ -8,28 +8,28 @@ import resonantinduction.api.IBattery;
|
|||
public class BatteryManager
|
||||
{
|
||||
public static final int CELLS_PER_BATTERY = 16;
|
||||
|
||||
|
||||
public static class SlotOut extends Slot
|
||||
{
|
||||
public SlotOut(IInventory inventory, int index, int x, int y)
|
||||
{
|
||||
super(inventory, index, x, y);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SlotBattery extends Slot
|
||||
{
|
||||
public SlotBattery(IInventory inventory, int index, int x, int y)
|
||||
{
|
||||
super(inventory, index, x, y);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack)
|
||||
{
|
||||
|
|
|
@ -17,13 +17,13 @@ public class BatteryUpdateProtocol
|
|||
{
|
||||
/** The battery nodes that have already been iterated over. */
|
||||
public Set<TileEntityBattery> iteratedNodes = new HashSet<TileEntityBattery>();
|
||||
|
||||
|
||||
/** The structures found, all connected by some nodes to the pointer. */
|
||||
public SynchronizedBatteryData structureFound = null;
|
||||
|
||||
|
||||
/** The original block the calculation is getting run from. */
|
||||
public TileEntity pointer;
|
||||
|
||||
|
||||
public BatteryUpdateProtocol(TileEntity tileEntity)
|
||||
{
|
||||
pointer = tileEntity;
|
||||
|
@ -31,205 +31,207 @@ public class BatteryUpdateProtocol
|
|||
|
||||
private void loopThrough(TileEntity tile)
|
||||
{
|
||||
if(structureFound == null)
|
||||
if (structureFound == null)
|
||||
{
|
||||
World worldObj = tile.worldObj;
|
||||
|
||||
World worldObj = tile.worldObj;
|
||||
|
||||
int origX = tile.xCoord, origY = tile.yCoord, origZ = tile.zCoord;
|
||||
|
||||
|
||||
boolean isCorner = true;
|
||||
boolean rightBlocks = true;
|
||||
|
||||
|
||||
Set<Vector3> locations = new HashSet<Vector3>();
|
||||
|
||||
|
||||
int xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
|
||||
|
||||
|
||||
int x = 0, y = 0, z = 0;
|
||||
|
||||
if((isBattery(origX + 1, origY, origZ) && isBattery(origX - 1, origY, origZ)) ||
|
||||
(isBattery(origX, origY + 1, origZ) && isBattery(origX, origY - 1, origZ)) ||
|
||||
(isBattery(origX, origY, origZ + 1) && isBattery(origX, origY, origZ - 1)))
|
||||
|
||||
if ((isBattery(origX + 1, origY, origZ) && isBattery(origX - 1, origY, origZ)) || (isBattery(origX, origY + 1, origZ) && isBattery(origX, origY - 1, origZ)) || (isBattery(origX, origY, origZ + 1) && isBattery(origX, origY, origZ - 1)))
|
||||
{
|
||||
isCorner = false;
|
||||
isCorner = false;
|
||||
}
|
||||
|
||||
if(isCorner)
|
||||
|
||||
if (isCorner)
|
||||
{
|
||||
if(isBattery(origX+1, origY, origZ))
|
||||
{
|
||||
xmin = 0;
|
||||
|
||||
while(isBattery(origX+x+1, origY, origZ))
|
||||
{
|
||||
x++;
|
||||
}
|
||||
|
||||
xmax = x;
|
||||
}
|
||||
else {
|
||||
xmax = 0;
|
||||
|
||||
while(isBattery(origX+x-1, origY, origZ))
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
xmin = x;
|
||||
}
|
||||
|
||||
if(isBattery(origX, origY+1, origZ))
|
||||
{
|
||||
ymin = 0;
|
||||
|
||||
while(isBattery(origX, origY+y+1, origZ))
|
||||
{
|
||||
y++;
|
||||
}
|
||||
|
||||
ymax = y;
|
||||
}
|
||||
else {
|
||||
ymax = 0;
|
||||
|
||||
while(isBattery(origX, origY+y-1 ,origZ))
|
||||
{
|
||||
y--;
|
||||
}
|
||||
|
||||
ymin = y;
|
||||
}
|
||||
|
||||
if(isBattery(origX, origY, origZ+1))
|
||||
{
|
||||
zmin = 0;
|
||||
|
||||
while(isBattery(origX, origY, origZ+z+1))
|
||||
{
|
||||
z++;
|
||||
}
|
||||
|
||||
zmax = z;
|
||||
}
|
||||
else {
|
||||
zmax = 0;
|
||||
|
||||
while(isBattery(origX, origY, origZ+z-1))
|
||||
{
|
||||
z--;
|
||||
}
|
||||
|
||||
zmin = z;
|
||||
}
|
||||
|
||||
for(x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for(y = ymin; y <= ymax; y++)
|
||||
{
|
||||
for(z = zmin; z <= zmax; z++)
|
||||
{
|
||||
if(!isBattery(origX+x, origY+y, origZ+z))
|
||||
{
|
||||
rightBlocks = false;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
locations.add(new Vector3(tile).translate(new Vector3(x, y, z)));
|
||||
}
|
||||
}
|
||||
|
||||
if(!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(locations.size() >= 1 && locations.size() < 512)
|
||||
if (isBattery(origX + 1, origY, origZ))
|
||||
{
|
||||
xmin = 0;
|
||||
|
||||
while (isBattery(origX + x + 1, origY, origZ))
|
||||
{
|
||||
x++;
|
||||
}
|
||||
|
||||
xmax = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmax = 0;
|
||||
|
||||
while (isBattery(origX + x - 1, origY, origZ))
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
xmin = x;
|
||||
}
|
||||
|
||||
if (isBattery(origX, origY + 1, origZ))
|
||||
{
|
||||
ymin = 0;
|
||||
|
||||
while (isBattery(origX, origY + y + 1, origZ))
|
||||
{
|
||||
y++;
|
||||
}
|
||||
|
||||
ymax = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ymax = 0;
|
||||
|
||||
while (isBattery(origX, origY + y - 1, origZ))
|
||||
{
|
||||
y--;
|
||||
}
|
||||
|
||||
ymin = y;
|
||||
}
|
||||
|
||||
if (isBattery(origX, origY, origZ + 1))
|
||||
{
|
||||
zmin = 0;
|
||||
|
||||
while (isBattery(origX, origY, origZ + z + 1))
|
||||
{
|
||||
z++;
|
||||
}
|
||||
|
||||
zmax = z;
|
||||
}
|
||||
else
|
||||
{
|
||||
zmax = 0;
|
||||
|
||||
while (isBattery(origX, origY, origZ + z - 1))
|
||||
{
|
||||
z--;
|
||||
}
|
||||
|
||||
zmin = z;
|
||||
}
|
||||
|
||||
for (x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for (y = ymin; y <= ymax; y++)
|
||||
{
|
||||
for (z = zmin; z <= zmax; z++)
|
||||
{
|
||||
if (!isBattery(origX + x, origY + y, origZ + z))
|
||||
{
|
||||
rightBlocks = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
locations.add(new Vector3(tile).translate(new Vector3(x, y, z)));
|
||||
}
|
||||
}
|
||||
|
||||
if (!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (locations.size() >= 1 && locations.size() < 512)
|
||||
{
|
||||
if(rightBlocks && isCorner)
|
||||
if (rightBlocks && isCorner)
|
||||
{
|
||||
SynchronizedBatteryData structure = new SynchronizedBatteryData();
|
||||
structure.locations = locations;
|
||||
structure.length = Math.abs(xmax-xmin)+1;
|
||||
structure.height = Math.abs(ymax-ymin)+1;
|
||||
structure.width = Math.abs(zmax-zmin)+1;
|
||||
|
||||
if(structure.getVolume() > 1)
|
||||
structure.length = Math.abs(xmax - xmin) + 1;
|
||||
structure.height = Math.abs(ymax - ymin) + 1;
|
||||
structure.width = Math.abs(zmax - zmin) + 1;
|
||||
|
||||
if (structure.getVolume() > 1)
|
||||
{
|
||||
structure.isMultiblock = true;
|
||||
}
|
||||
|
||||
if(structure.locations.contains(new Vector3(pointer)))
|
||||
|
||||
if (structure.locations.contains(new Vector3(pointer)))
|
||||
{
|
||||
structureFound = structure;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iteratedNodes.add((TileEntityBattery)tile);
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
|
||||
iteratedNodes.add((TileEntityBattery) tile);
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(tile).getFromSide(side).getTileEntity(tile.worldObj);
|
||||
|
||||
if(tileEntity instanceof TileEntityBattery)
|
||||
|
||||
if (tileEntity instanceof TileEntityBattery)
|
||||
{
|
||||
if(!iteratedNodes.contains(tileEntity))
|
||||
if (!iteratedNodes.contains(tileEntity))
|
||||
{
|
||||
loopThrough(tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isBattery(int x, int y, int z)
|
||||
{
|
||||
if(pointer.worldObj.getBlockTileEntity(x, y, z) instanceof TileEntityBattery)
|
||||
if (pointer.worldObj.getBlockTileEntity(x, y, z) instanceof TileEntityBattery)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void disperseCells()
|
||||
{
|
||||
SynchronizedBatteryData oldStructure = null;
|
||||
|
||||
for(TileEntityBattery tile : iteratedNodes)
|
||||
|
||||
for (TileEntityBattery tile : iteratedNodes)
|
||||
{
|
||||
if(tile.structure.isMultiblock)
|
||||
if (tile.structure.isMultiblock)
|
||||
{
|
||||
oldStructure = tile.structure;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(oldStructure != null)
|
||||
|
||||
if (oldStructure != null)
|
||||
{
|
||||
int maxCells = iteratedNodes.size()*BatteryManager.CELLS_PER_BATTERY;
|
||||
|
||||
int maxCells = iteratedNodes.size() * BatteryManager.CELLS_PER_BATTERY;
|
||||
|
||||
List<ItemStack> rejected = ListUtil.capRemains(oldStructure.inventory, maxCells);
|
||||
ejectItems(rejected, new Vector3(pointer));
|
||||
|
||||
|
||||
ArrayList<List<ItemStack>> inventories = ListUtil.split(ListUtil.cap(oldStructure.inventory, maxCells), iteratedNodes.size());
|
||||
List<TileEntityBattery> iterList = ListUtil.asList(iteratedNodes);
|
||||
|
||||
|
||||
boolean didVisibleInventory = false;
|
||||
|
||||
for(int i = 0; i < iterList.size(); i++)
|
||||
|
||||
for (int i = 0; i < iterList.size(); i++)
|
||||
{
|
||||
TileEntityBattery tile = iterList.get(i);
|
||||
tile.structure = SynchronizedBatteryData.getBase(tile, inventories.get(i));
|
||||
|
||||
if(!didVisibleInventory)
|
||||
|
||||
if (!didVisibleInventory)
|
||||
{
|
||||
tile.structure.visibleInventory = oldStructure.visibleInventory;
|
||||
didVisibleInventory = true;
|
||||
|
@ -237,58 +239,59 @@ public class BatteryUpdateProtocol
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ejectItems(List<ItemStack> items, Vector3 vec)
|
||||
{
|
||||
for(ItemStack itemStack : items)
|
||||
{
|
||||
float motion = 0.7F;
|
||||
double motionX = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionY = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionZ = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
||||
EntityItem entityItem = new EntityItem(pointer.worldObj, vec.x + motionX, vec.y + motionY, vec.z + motionZ, itemStack);
|
||||
|
||||
pointer.worldObj.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
for (ItemStack itemStack : items)
|
||||
{
|
||||
float motion = 0.7F;
|
||||
double motionX = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionY = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionZ = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
||||
EntityItem entityItem = new EntityItem(pointer.worldObj, vec.x + motionX, vec.y + motionY, vec.z + motionZ, itemStack);
|
||||
|
||||
pointer.worldObj.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBatteries()
|
||||
{
|
||||
loopThrough(pointer);
|
||||
|
||||
if(structureFound != null)
|
||||
|
||||
if (structureFound != null)
|
||||
{
|
||||
for(TileEntityBattery tileEntity : iteratedNodes)
|
||||
for (TileEntityBattery tileEntity : iteratedNodes)
|
||||
{
|
||||
if(!structureFound.locations.contains(new Vector3(tileEntity)))
|
||||
if (!structureFound.locations.contains(new Vector3(tileEntity)))
|
||||
{
|
||||
disperseCells();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(Vector3 obj : structureFound.locations)
|
||||
|
||||
for (Vector3 obj : structureFound.locations)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery)obj.getTileEntity(pointer.worldObj);
|
||||
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) obj.getTileEntity(pointer.worldObj);
|
||||
|
||||
structureFound.inventory = ListUtil.merge(structureFound.inventory, tileEntity.structure.inventory);
|
||||
|
||||
if(tileEntity.structure.hasVisibleInventory())
|
||||
|
||||
if (tileEntity.structure.hasVisibleInventory())
|
||||
{
|
||||
structureFound.visibleInventory = tileEntity.structure.visibleInventory;
|
||||
}
|
||||
|
||||
|
||||
tileEntity.structure = structureFound;
|
||||
}
|
||||
|
||||
|
||||
List<ItemStack> rejected = ListUtil.capRemains(structureFound.inventory, structureFound.getMaxCells());
|
||||
ejectItems(rejected, new Vector3(pointer));
|
||||
|
||||
|
||||
structureFound.inventory = ListUtil.cap(structureFound.inventory, structureFound.getMaxCells());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
disperseCells();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,14 +36,18 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer)
|
||||
{
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = ListUtil.getTop(tileEntity.structure.inventory);
|
||||
|
||||
if (tileEntity.structure.inventory.remove(itemStack))
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityPlayer.dropPlayerItem(itemStack);
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = ListUtil.getTop(tileEntity.structure.inventory);
|
||||
|
||||
if (tileEntity.structure.inventory.remove(itemStack))
|
||||
{
|
||||
entityPlayer.dropPlayerItem(itemStack);
|
||||
tileEntity.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +73,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
tileEntity.structure.inventory.add(entityPlayer.getCurrentEquippedItem());
|
||||
tileEntity.structure.sortInventory();
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
tileEntity.updateInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ import resonantinduction.battery.BatteryManager.SlotOut;
|
|||
public class ContainerBattery extends Container
|
||||
{
|
||||
private TileEntityBattery tileEntity;
|
||||
|
||||
|
||||
public ContainerBattery(InventoryPlayer inventory, TileEntityBattery unit)
|
||||
{
|
||||
tileEntity = unit;
|
||||
|
@ -21,131 +21,134 @@ public class ContainerBattery extends Container
|
|||
addSlotToContainer(new SlotOut(unit, 1, 8, 58));
|
||||
addSlotToContainer(new SlotBattery(unit, 2, 31, 22));
|
||||
addSlotToContainer(new SlotBattery(unit, 3, 31, 58));
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++slotX)
|
||||
{
|
||||
for(int slotY = 0; slotY < 9; ++slotY)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 125 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 183));
|
||||
}
|
||||
|
||||
tileEntity.openChest();
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
}
|
||||
|
||||
int slotX;
|
||||
|
||||
for (slotX = 0; slotX < 3; ++slotX)
|
||||
{
|
||||
for (int slotY = 0; slotY < 9; ++slotY)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 125 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 183));
|
||||
}
|
||||
|
||||
tileEntity.openChest();
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotID, int par2, int par3, EntityPlayer par4EntityPlayer)
|
||||
{
|
||||
{
|
||||
ItemStack stack = super.slotClick(slotID, par2, par3, par4EntityPlayer);
|
||||
|
||||
if(slotID == 1)
|
||||
|
||||
if (slotID == 1)
|
||||
{
|
||||
ItemStack itemstack = ((Slot)inventorySlots.get(slotID)).getStack();
|
||||
ItemStack itemstack = ((Slot) inventorySlots.get(slotID)).getStack();
|
||||
ItemStack itemstack1 = itemstack == null ? null : itemstack.copy();
|
||||
inventoryItemStacks.set(slotID, itemstack1);
|
||||
|
||||
for (int j = 0; j < crafters.size(); ++j)
|
||||
{
|
||||
((ICrafting)crafters.get(j)).sendSlotContents(this, slotID, itemstack1);
|
||||
((ICrafting) crafters.get(j)).sendSlotContents(this, slotID, itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
tileEntity.playersUsing.remove(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(slotID == 0 || slotID == 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 2 || slotID == 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof IBattery)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 4 && slotID <= 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot) inventorySlots.get(slotID);
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
if (currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
return stack;
|
||||
}
|
||||
if (slotID == 0 || slotID == 1)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotID == 2 || slotID == 3)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotStack.getItem() instanceof IBattery)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slotID >= 4 && slotID <= 30)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotID > 30)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 4, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,40 +13,40 @@ public class GuiBattery extends GuiContainer
|
|||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "batterybox_gui.png");
|
||||
public TileEntityBattery tileEntity;
|
||||
|
||||
|
||||
public GuiBattery(InventoryPlayer inventory, TileEntityBattery tentity)
|
||||
{
|
||||
super(new ContainerBattery(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
ySize+=41;
|
||||
ySize += 41;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
|
||||
fontRenderer.drawString("Battery", 43, 6, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
fontRenderer.drawString("Cells: " + tileEntity.clientCells + " / " + tileEntity.structure.getMaxCells(), 62, 23, 0x404040);
|
||||
fontRenderer.drawString("Energy: " + (int)tileEntity.getEnergyStored() + " / " + (int)tileEntity.getMaxEnergyStored(), 62, 32, 0x404040);
|
||||
fontRenderer.drawString("Energy: " + (int) tileEntity.getEnergyStored() + " / " + (int) tileEntity.getMaxEnergyStored(), 62, 32, 0x404040);
|
||||
fontRenderer.drawString("Volume: " + tileEntity.structure.getVolume(), 62, 41, 0x404040);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
|
||||
{
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
|
||||
{
|
||||
mc.renderEngine.func_110577_a(TEXTURE);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
int scale = (int)((tileEntity.getEnergyStored() / tileEntity.getMaxEnergyStored()) * 105);
|
||||
drawTexturedModalRect(guiWidth + 61, guiHeight + 102, 0, 207, scale, 12);
|
||||
}
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
int scale = (int) ((tileEntity.getEnergyStored() / tileEntity.getMaxEnergyStored()) * 105);
|
||||
drawTexturedModalRect(guiWidth + 61, guiHeight + 102, 0, 207, scale, 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,11 +66,11 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getTransfer(ItemStack itemStack)
|
||||
{
|
||||
return getMaxEnergyStored(itemStack)*0.05F;
|
||||
return getMaxEnergyStored(itemStack) * 0.05F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,102 +10,100 @@ import resonantinduction.api.IBattery;
|
|||
import resonantinduction.base.ListUtil;
|
||||
import resonantinduction.base.Vector3;
|
||||
|
||||
public class SynchronizedBatteryData
|
||||
public class SynchronizedBatteryData
|
||||
{
|
||||
public Set<Vector3> locations = new HashSet<Vector3>();
|
||||
|
||||
|
||||
public List<ItemStack> inventory = new ArrayList<ItemStack>();
|
||||
|
||||
|
||||
/**
|
||||
* Slot 0: Cell input slot
|
||||
* Slot 1: Battery charge slot
|
||||
* Slot 2: Battery discharge slot
|
||||
* Slot 0: Cell input slot Slot 1: Battery charge slot Slot 2: Battery discharge slot
|
||||
*/
|
||||
public ItemStack[] visibleInventory = new ItemStack[3];
|
||||
|
||||
|
||||
public int length;
|
||||
|
||||
|
||||
public int width;
|
||||
|
||||
|
||||
public int height;
|
||||
|
||||
|
||||
public ItemStack tempStack;
|
||||
|
||||
|
||||
public boolean isMultiblock;
|
||||
|
||||
|
||||
public boolean didTick;
|
||||
|
||||
|
||||
public boolean wroteInventory;
|
||||
|
||||
|
||||
public int getVolume()
|
||||
{
|
||||
return length*width*height;
|
||||
return length * width * height;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxCells()
|
||||
{
|
||||
return getVolume()*BatteryManager.CELLS_PER_BATTERY;
|
||||
return getVolume() * BatteryManager.CELLS_PER_BATTERY;
|
||||
}
|
||||
|
||||
|
||||
public void sortInventory()
|
||||
{
|
||||
Object[] array = ListUtil.copy(inventory).toArray();
|
||||
|
||||
|
||||
ItemStack[] toSort = new ItemStack[array.length];
|
||||
|
||||
for(int i = 0; i < array.length; i++)
|
||||
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
toSort[i] = (ItemStack)array[i];
|
||||
toSort[i] = (ItemStack) array[i];
|
||||
}
|
||||
|
||||
|
||||
boolean cont = true;
|
||||
ItemStack temp;
|
||||
|
||||
while(cont)
|
||||
|
||||
while (cont)
|
||||
{
|
||||
cont = false;
|
||||
|
||||
for(int i = 0; i < toSort.length-1; i++)
|
||||
|
||||
for (int i = 0; i < toSort.length - 1; i++)
|
||||
{
|
||||
if(((IBattery)toSort[i].getItem()).getEnergyStored(toSort[i]) < ((IBattery)toSort[i+1].getItem()).getEnergyStored(toSort[i+1]))
|
||||
{
|
||||
if (((IBattery) toSort[i].getItem()).getEnergyStored(toSort[i]) < ((IBattery) toSort[i + 1].getItem()).getEnergyStored(toSort[i + 1]))
|
||||
{
|
||||
temp = toSort[i];
|
||||
toSort[i] = toSort[i+1];
|
||||
toSort[i+1] = temp;
|
||||
toSort[i] = toSort[i + 1];
|
||||
toSort[i + 1] = temp;
|
||||
cont = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inventory = new ArrayList<ItemStack>();
|
||||
|
||||
for(ItemStack itemStack : toSort)
|
||||
|
||||
for (ItemStack itemStack : toSort)
|
||||
{
|
||||
inventory.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasVisibleInventory()
|
||||
{
|
||||
for(ItemStack itemStack : visibleInventory)
|
||||
for (ItemStack itemStack : visibleInventory)
|
||||
{
|
||||
if(itemStack != null)
|
||||
if (itemStack != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static SynchronizedBatteryData getBase(TileEntityBattery tileEntity, List<ItemStack> inventory)
|
||||
{
|
||||
SynchronizedBatteryData structure = getBase(tileEntity);
|
||||
structure.inventory = inventory;
|
||||
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
public static SynchronizedBatteryData getBase(TileEntityBattery tileEntity)
|
||||
{
|
||||
SynchronizedBatteryData structure = new SynchronizedBatteryData();
|
||||
|
@ -113,10 +111,10 @@ public class SynchronizedBatteryData
|
|||
structure.width = 1;
|
||||
structure.height = 1;
|
||||
structure.locations.add(new Vector3(tileEntity));
|
||||
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
@ -127,27 +125,27 @@ public class SynchronizedBatteryData
|
|||
code = 31 * height;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(!(obj instanceof SynchronizedBatteryData))
|
||||
if (!(obj instanceof SynchronizedBatteryData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SynchronizedBatteryData data = (SynchronizedBatteryData)obj;
|
||||
|
||||
if(!data.locations.equals(locations))
|
||||
|
||||
SynchronizedBatteryData data = (SynchronizedBatteryData) obj;
|
||||
|
||||
if (!data.locations.equals(locations))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(data.length != length || data.width != width || data.height != height)
|
||||
|
||||
if (data.length != length || data.width != width || data.height != height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
if (playersUsing.size() > 0)
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
||||
this.updateInventory();
|
||||
}
|
||||
|
||||
if (ticks == 5 && !structure.isMultiblock)
|
||||
|
@ -110,6 +110,11 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
}
|
||||
|
||||
public void updateInventory()
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package resonantinduction.contractor;
|
||||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -15,7 +16,6 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.PacketHandler;
|
||||
import resonantinduction.ResonantInduction;
|
||||
import resonantinduction.api.ITesla;
|
||||
import resonantinduction.base.IPacketReceiver;
|
||||
import resonantinduction.base.InventoryUtil;
|
||||
import resonantinduction.base.TileEntityBase;
|
||||
|
@ -123,7 +123,7 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
|||
{
|
||||
Vector3 result = this.pathfinder.results.get(i);
|
||||
|
||||
if (this.canBePath(this.worldObj, result))
|
||||
if (TileEntityEMContractor.canBePath(this.worldObj, result))
|
||||
{
|
||||
if (i - 1 >= 0)
|
||||
{
|
||||
|
@ -172,7 +172,8 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
|||
|
||||
public static boolean canBePath(World world, Vector3 position)
|
||||
{
|
||||
return position.getBlockID(world) == 0 || position.getTileEntity(world) instanceof TileEntityEMContractor;
|
||||
Block block = Block.blocksList[position.getBlockID(world)];
|
||||
return block == null || position.getTileEntity(world) instanceof TileEntityEMContractor || (block != null && !block.isBlockNormalCube(world, (int) position.x, (int) position.y, (int) position.z));
|
||||
}
|
||||
|
||||
private void moveEntity(EntityItem entityItem, ForgeDirection direction, Vector3 lockVector)
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package resonantinduction.entangler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.base.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -90,10 +90,10 @@ public class FXElectricBolt extends EntityFX
|
|||
this.segments.add(new BoltSegment(this.start, this.end));
|
||||
this.recalculate();
|
||||
double offsetRatio = this.boltLength * this.complexity;
|
||||
this.split(2, offsetRatio / 10, 0.7f, 0.1f, 20/2);
|
||||
this.split(2, offsetRatio / 15, 0.5f, 0.1f, 25/2);
|
||||
this.split(2, offsetRatio / 25, 0.5f, 0.1f, 28/2);
|
||||
this.split(2, offsetRatio / 38, 0.5f, 0.1f, 30/2);
|
||||
this.split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2);
|
||||
this.split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2);
|
||||
this.split(2, offsetRatio / 25, 0.5f, 0.1f, 28 / 2);
|
||||
this.split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2);
|
||||
this.split(2, offsetRatio / 55, 0, 0, 0);
|
||||
this.split(2, offsetRatio / 70, 0, 0, 0);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.client.model.ModelRenderer;
|
|||
public class ModelEMContractor extends ModelBase
|
||||
{
|
||||
public boolean doSpin;
|
||||
|
||||
|
||||
ModelRenderer frame1;
|
||||
ModelRenderer frame2;
|
||||
ModelRenderer frame3;
|
||||
|
@ -41,7 +41,7 @@ public class ModelEMContractor extends ModelBase
|
|||
public ModelEMContractor(boolean spin)
|
||||
{
|
||||
doSpin = spin;
|
||||
|
||||
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
|||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
|
||||
* hi@OverridetZ, block metadata
|
||||
*/
|
||||
@Override
|
||||
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
return ForgeDirection.getOrientation(side).getOpposite().ordinal();
|
||||
|
|
|
@ -5,7 +5,6 @@ package resonantinduction.multimeter;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import resonantinduction.base.Vector3;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -48,7 +47,7 @@ public class ItemBlockMultimeter extends ItemBlock
|
|||
{
|
||||
if (!par2EntityPlayer.isSneaking())
|
||||
{
|
||||
//if (!world.isRemote)
|
||||
// if (!world.isRemote)
|
||||
{
|
||||
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
|||
{
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery.png");
|
||||
public static final ResourceLocation TEXTURE_MULTI = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery_multi.png");
|
||||
|
||||
|
||||
public static final ModelBattery MODEL = new ModelBattery();
|
||||
private EntityItem fakeBattery;
|
||||
private Random random = new Random();
|
||||
|
@ -59,25 +59,26 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
|||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
if(((TileEntityBattery)t).structure.isMultiblock)
|
||||
|
||||
if (((TileEntityBattery) t).structure.isMultiblock)
|
||||
{
|
||||
this.func_110628_a(TEXTURE_MULTI);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
this.func_110628_a(TEXTURE);
|
||||
}
|
||||
|
||||
|
||||
MODEL.render(0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
int renderAmount = Math.min(((TileEntityBattery)t).clientCells, 16);
|
||||
|
||||
if(renderAmount == 0)
|
||||
int renderAmount = Math.min(((TileEntityBattery) t).clientCells, 16);
|
||||
|
||||
if (renderAmount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
|
@ -158,10 +159,10 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
|||
icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno");
|
||||
}
|
||||
|
||||
float f4 = ((Icon) icon).getMinU();
|
||||
float f5 = ((Icon) icon).getMaxU();
|
||||
float f6 = ((Icon) icon).getMinV();
|
||||
float f7 = ((Icon) icon).getMaxV();
|
||||
float f4 = icon.getMinU();
|
||||
float f5 = icon.getMaxU();
|
||||
float f6 = icon.getMinV();
|
||||
float f7 = icon.getMaxV();
|
||||
float f8 = 1.0F;
|
||||
float f9 = 0.5F;
|
||||
float f10 = 0.25F;
|
||||
|
@ -175,7 +176,7 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
|||
int j = itemstack.stackSize;
|
||||
byte b0 = getMiniItemCount(itemstack);
|
||||
|
||||
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));
|
||||
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * b0 / 2.0F));
|
||||
|
||||
for (int kj = 0; kj < b0; ++kj)
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) icon).getOriginX(), ((Icon) icon).getOriginY(), f12);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, icon.getOriginX(), icon.getOriginY(), f12);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
|
|
@ -59,12 +59,13 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
|
|||
{
|
||||
this.func_110628_a(TEXTURE_PUSH);
|
||||
}
|
||||
|
||||
if(((TileEntityEMContractor)t).canFunction() && !ResonantInduction.proxy.isPaused())
|
||||
|
||||
if (((TileEntityEMContractor) t).canFunction() && !ResonantInduction.proxy.isPaused())
|
||||
{
|
||||
MODEL_SPIN.render(0.0625f);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
MODEL.render(0.0625f);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.ResonantInduction;
|
||||
import resonantinduction.contractor.TileEntityEMContractor;
|
||||
import resonantinduction.model.ModelMultimeter;
|
||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
|
Loading…
Add table
Reference in a new issue