mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 12:59:41 +00:00
Started on a new, more modular approach to controller-less multiblocks, allowing for the creation of the EIM
This commit is contained in:
1 parent
1cfe6fc352
commit
fc7dd3e65a
8 files changed
+293
-144
No files matched your search
@@ -887,77 +887,6 @@ public final class MekanismUtils
|
||||
player.openContainer.addCraftingToCrafters(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs an inventory from the world's caches, and removes all the world's references to it.
|
||||
* @param world - world the cache is stored in
|
||||
* @param id - inventory ID to pull
|
||||
* @return correct Dynamic Tank inventory cache
|
||||
*/
|
||||
public static DynamicTankCache pullInventory(World world, int id)
|
||||
{
|
||||
DynamicTankCache toReturn = Mekanism.dynamicInventories.get(id);
|
||||
|
||||
for(Coord4D obj : Mekanism.dynamicInventories.get(id).locations)
|
||||
{
|
||||
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(world);
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
tileEntity.cachedData = new DynamicTankCache();
|
||||
tileEntity.inventory = new ItemStack[2];
|
||||
tileEntity.inventoryID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Mekanism.dynamicInventories.remove(id);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a dynamic tank cache with the defined inventory ID with the parameterized values.
|
||||
* @param inventoryID - inventory ID of the dynamic tank
|
||||
* @param cache - cache of the dynamic tank
|
||||
* @param tileEntity - dynamic tank TileEntity
|
||||
*/
|
||||
public static void updateCache(int inventoryID, DynamicTankCache cache, TileEntityDynamicTank tileEntity)
|
||||
{
|
||||
if(!Mekanism.dynamicInventories.containsKey(inventoryID))
|
||||
{
|
||||
cache.locations.add(Coord4D.get(tileEntity));
|
||||
|
||||
Mekanism.dynamicInventories.put(inventoryID, cache);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Mekanism.dynamicInventories.put(inventoryID, cache);
|
||||
Mekanism.dynamicInventories.get(inventoryID).locations.add(Coord4D.get(tileEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs a unique inventory ID for a dynamic tank.
|
||||
* @return unique inventory ID
|
||||
*/
|
||||
public static int getUniqueInventoryID()
|
||||
{
|
||||
int id = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
for(Integer i : Mekanism.dynamicInventories.keySet())
|
||||
{
|
||||
if(id == i)
|
||||
{
|
||||
id++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a private value from a defined class and field.
|
||||
* @param obj - the Object to retrieve the value from, null if static
|
||||
|
||||
Reference in new issue
Block a user