Merge upstream final release

This commit is contained in:
Vincent Lee committed 2016-02-28 01:29:25 -06:00
commit 1580790398
26 files changed
+2841 -765

No files matched your search

@@ -28,6 +28,7 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.BotaniaAPI;
public final class CorporeaHelper {
@@ -126,22 +127,15 @@ public final class CorporeaHelper {
* The deeper level function that use a List< IInventory > should be
* called instead if the context for this exists to avoid having to get the value again.
*/
public static Map<IInventory, Integer> getInventoriesWithItemInNetwork(ItemStack stack, List<IInventory> inventories, boolean checkNBT) {
Map<IInventory, Integer> countMap = new HashMap<>();
for(IInventory inv : inventories) {
int count = 0;
for(int i = 0; i < inv.getSizeInventory(); i++) {
if(!isValidSlot(inv, i))
continue;
ItemStack stackAt = inv.getStackInSlot(i);
if(stacksMatch(stack, stackAt, checkNBT))
count += stackAt.stackSize;
public static Map<IInventory, Integer> getInventoriesWithItemInNetwork(ItemStack stack,List<IInventory> inventories, boolean checkNBT) {
Map<IInventory, Integer> countMap = new HashMap<IInventory, Integer>();
List<IWrappedInventory> wrappedInventories = BotaniaAPI.internalHandler.wrapInventory(inventories);
for (IWrappedInventory inv : wrappedInventories) {
CorporeaRequest request = new CorporeaRequest(stack, checkNBT, -1);
inv.countItems(request);
if (request.foundItems > 0) {
countMap.put(inv.getWrappedObject(), request.foundItems);
}
if(count > 0)
countMap.put(inv, count);
}
return countMap;
@@ -170,6 +164,9 @@ public final class CorporeaHelper {
* The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the
* two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item
* equals or matches (case a regex is passed in) the matcher string.
* <br><br>
* When requesting counting of items, individual stacks may exceed maxStackSize for
* purposes of counting huge amounts.
*/
public static List<ItemStack> requestItem(Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) {
List<ItemStack> stacks = new ArrayList<>();
@@ -178,54 +175,31 @@ public final class CorporeaHelper {
return stacks;
List<IInventory> inventories = getInventoriesOnNetwork(spark);
Map<ICorporeaInterceptor, ICorporeaSpark> interceptors = new HashMap<>();
lastRequestMatches = 0;
lastRequestExtractions = 0;
List<IWrappedInventory> inventoriesW = BotaniaAPI.internalHandler.wrapInventory(inventories);
Map<ICorporeaInterceptor, ICorporeaSpark> interceptors = new HashMap<ICorporeaInterceptor, ICorporeaSpark>();
int count = itemCount;
for(IInventory inv : inventories) {
boolean removedAny = false;
ICorporeaSpark invSpark = getSparkForInventory(inv);
CorporeaRequest request = new CorporeaRequest(matcher, checkNBT, itemCount);
for(IWrappedInventory inv : inventoriesW) {
ICorporeaSpark invSpark = inv.getSpark();
if(inv instanceof ICorporeaInterceptor) {
ICorporeaInterceptor interceptor = (ICorporeaInterceptor) inv;
Object originalInventory = inv.getWrappedObject();
if(originalInventory instanceof ICorporeaInterceptor) {
ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory;
interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit);
interceptors.put(interceptor, invSpark);
}
for(int i = inv.getSizeInventory() - 1; i >= 0; i--) {
if(!isValidSlot(inv, i))
continue;
ItemStack stackAt = inv.getStackInSlot(i);
if(matcher instanceof ItemStack ? stacksMatch((ItemStack) matcher, stackAt, checkNBT) : matcher instanceof String ? stacksMatch(stackAt, (String) matcher) : false) {
int rem = Math.min(stackAt.stackSize, count == -1 ? stackAt.stackSize : count);
if(rem > 0) {
ItemStack copy = stackAt.copy();
if(rem < copy.stackSize)
copy.stackSize = rem;
stacks.add(copy);
}
lastRequestMatches += stackAt.stackSize;
lastRequestExtractions += rem;
if(doit && rem > 0) {
inv.decrStackSize(i, rem);
removedAny = true;
if(invSpark != null)
invSpark.onItemExtracted(stackAt);
}
if(count != -1)
count -= rem;
}
if(doit) {
stacks.addAll(inv.extractItems(request));
} else {
stacks.addAll(inv.countItems(request));
}
if(removedAny)
inv.markDirty();
}
lastRequestMatches = request.foundItems;
lastRequestExtractions = request.extractedItems;
for(ICorporeaInterceptor interceptor : interceptors.keySet())
interceptor.interceptRequestLast(matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit);
@@ -0,0 +1,26 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*/
package vazkii.botania.api.corporea;
public class CorporeaRequest {
public Object matcher;
public boolean checkNBT;
public int count;
public int foundItems = 0;
public int extractedItems = 0;
public CorporeaRequest(Object matcher, boolean checkNBT, int count) {
super();
this.matcher = matcher;
this.checkNBT = checkNBT;
this.count = count;
}
}
@@ -0,0 +1,57 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*/
package vazkii.botania.api.corporea;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
/**
* This interface wraps IInventory corporea works with in order to provide
* compatibility with different storage mods.
*
*/
public interface IWrappedInventory {
/**
* Break encapsulation and exposes original inventory.
*/
IInventory getWrappedObject();
/**
* Counts items in the inventory matching the request
*
* @param request
* - specifies what should be found
* @return List of ItemStack, individual stacks may exceed maxStackSize for
* purposes of counting huge amounts. To get final count requestor
* should sum stackSize of all stacks.
*/
List<ItemStack> countItems(CorporeaRequest request);
/**
* Convenience method for accessing spark over inventory
*/
ICorporeaSpark getSpark();
/**
* Extracts items matching request from the inventory.<br/>
* {@link CorporeaRequest#count} is updated to reflect how many items are
* yet to be extracted.<br/>
* {@link CorporeaRequest#foundItems} and
* {@link CorporeaRequest#extractedItems} are updated to reflect how many
* items were found and extracted.
*
* @param request
* @return List of ItemStacks to be delivered to the destination.
*/
List<ItemStack> extractItems(CorporeaRequest request);
}
@@ -27,6 +27,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.boss.IBotaniaBoss;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.recipe.RecipeBrew;
@@ -227,4 +228,9 @@ public class DummyMethodHandler implements IInternalMethodHandler {
// NO-OP
}
@Override
public List<IWrappedInventory> wrapInventory(List<IInventory> inventories) {
return null;
}
}
@@ -26,6 +26,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.boss.IBotaniaBoss;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.recipe.RecipeBrew;
@@ -124,4 +125,9 @@ public interface IInternalMethodHandler {
public void sendBaubleUpdatePacket(EntityPlayer player, int slot);
/**
* Wrap inventories in the network into wrappers providing compatibility for storage mods.
*/
List<IWrappedInventory> wrapInventory(List<IInventory> inventories);
}
@@ -61,6 +61,7 @@ import vazkii.botania.client.gui.lexicon.button.GuiButtonNotes;
import vazkii.botania.client.gui.lexicon.button.GuiButtonOptions;
import vazkii.botania.client.gui.lexicon.button.GuiButtonUpdateWarning;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ItemLexicon;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lexicon.page.PageText;
@@ -523,7 +524,8 @@ public class GuiLexicon extends GuiScreen {
tutorial.add(LexiconData.manaIntro);
tutorial.add(LexiconData.pool);
tutorial.add(LexiconData.spreader);
tutorial.add(LexiconData.generatingIntro);
if(ConfigHandler.hardcorePassiveGeneration > 0)
tutorial.add(LexiconData.generatingIntro);
tutorial.add(LexiconData.passiveGen);
tutorial.add(LexiconData.daybloom);
tutorial.add(LexiconData.functionalIntro);
@@ -53,6 +53,7 @@ public class Botania {
public static boolean coloredLightsLoaded = false;
public static boolean etFuturumLoaded = false;
public static boolean rfApiLoaded = false;
public static boolean storageDrawersLoaded = false;
public static ILightHelper lightHelper;
@@ -73,6 +74,8 @@ public class Botania {
etFuturumLoaded = Loader.isModLoaded("etfuturum");
rfApiLoaded = ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy");
storageDrawersLoaded = Loader.isModLoaded("StorageDrawers");
lightHelper = coloredLightsLoaded ? new LightHelperColored() : new LightHelperVanilla();
proxy.preInit(event);
@@ -37,7 +37,7 @@ public final class ConfigHandler {
public static ConfigAdaptor adaptor;
public static final int hardcorePassiveGeneration = 72000;
public static int hardcorePassiveGeneration = 72000;
public static boolean useAdaptativeConfig = true;
@@ -250,6 +250,9 @@ public final class ConfigHandler {
desc = "The quantity of Botania flower patches to generate in the world, defaults to 2, the lower the number the less patches generate.";
flowerQuantity = loadPropInt("worldgen.flower.quantity", desc, flowerQuantity);
desc = "The amount of time it takes a Passive flower to decay and turn into a dead bush. Defaults to 72000, 60 minutes. Setting this to -1 disables the feature altogether.";
hardcorePassiveGeneration = loadPropInt("passiveDecay.time", desc, hardcorePassiveGeneration);
desc = "The density of each Botania flower patch generated, defaults to 2, the lower the number, the less each patch will have.";
adaptor.addMappingInt(0, "worldgen.flower.density", 16);
adaptor.addMappingInt(238, "worldgen.flower.density", 2);
@@ -10,6 +10,7 @@
*/
package vazkii.botania.common.core.handler;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
@@ -29,6 +30,9 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPIClient;
import vazkii.botania.api.boss.IBotaniaBoss;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.internal.DummyMethodHandler;
import vazkii.botania.api.internal.IManaNetwork;
import vazkii.botania.api.lexicon.LexiconPage;
@@ -46,6 +50,9 @@ import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.subtile.functional.SubTileSolegnolia;
import vazkii.botania.common.integration.corporea.WrappedDeepStorage;
import vazkii.botania.common.integration.corporea.WrappedIInventory;
import vazkii.botania.common.integration.corporea.WrappedStorageDrawers;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
import vazkii.botania.common.item.relic.ItemLokiRing;
@@ -254,4 +261,28 @@ public class InternalMethodHandler extends DummyMethodHandler {
if(player instanceof EntityPlayerMP)
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player);
}
@Override
public List<IWrappedInventory> wrapInventory(List<IInventory> inventories) {
ArrayList<IWrappedInventory> arrayList = new ArrayList<IWrappedInventory>();
for(IInventory inv : inventories) {
ICorporeaSpark spark = CorporeaHelper.getSparkForInventory(inv);
IWrappedInventory wrapped = null;
// try StorageDrawers integration
if(Botania.storageDrawersLoaded) {
wrapped = WrappedStorageDrawers.wrap(inv, spark);
}
// try DeepStorageUnit
if(wrapped == null) {
wrapped = WrappedDeepStorage.wrap(inv, spark);
}
// last chance - this will always work
if(wrapped == null) {
wrapped = WrappedIInventory.wrap(inv, spark);
}
arrayList.add(wrapped);
}
return arrayList;
}
}
@@ -0,0 +1,136 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*/
package vazkii.botania.common.integration.corporea;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import vazkii.botania.api.corporea.CorporeaRequest;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.IWrappedInventory;
/**
* Wrapper for StorageDrawers compatibility.
*
*/
public class WrappedDeepStorage extends WrappedInventoryBase {
private static boolean checkedInterface = false;
private static boolean deepStoragePresent = false;
private IDeepStorageUnit inv;
private WrappedDeepStorage(IDeepStorageUnit inv, ICorporeaSpark spark) {
this.inv = inv;
this.spark = spark;
}
@Override
public IInventory getWrappedObject() {
return (IInventory) inv;
}
@Override
public List<ItemStack> countItems(CorporeaRequest request) {
return iterateOverStacks(request, false);
}
@Override
public List<ItemStack> extractItems(CorporeaRequest request) {
return iterateOverStacks(request, true);
}
private List<ItemStack> iterateOverStacks(CorporeaRequest request, boolean doit) {
List<ItemStack> stacks = new ArrayList<ItemStack>();
boolean removedAny = false;
ItemStack prototype = inv.getStoredItemType();
if(prototype == null) {
// for the case of barrel without contents set
return stacks;
}
int storedCount = prototype.stackSize;
// WARNING: this code is very similar in all implementations of
// IWrappedInventory - keep it synch
// this code is also near duplicate to WrappedStorageDrawers - keep it
// synchronized
if(isMatchingItemStack(request.matcher, request.checkNBT, prototype)) {
int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count);
if(rem > 0) {
ItemStack copy = prototype.copy();
copy.stackSize = rem;
if(doit) {
stacks.addAll(breakDownBigStack(copy));
} else {
stacks.add(copy);
}
}
request.foundItems += storedCount;
request.extractedItems += rem;
if(doit && rem > 0) {
decreaseStoredCount(inv, rem);
removedAny = true;
if(spark != null)
spark.onItemExtracted(prototype);
}
if(request.count != -1)
request.count -= rem;
}
if(removedAny) {
// inv.markDirtyIfNeeded();
}
return stacks;
}
private void decreaseStoredCount(IDeepStorageUnit inventory, int rem) {
inventory.setStoredItemCount(inventory.getStoredItemType().stackSize - rem);
}
/**
* Creates {@link WrappedDeepStorage} if specified inv can be wrapped.
*
* @return wrapped inventory or null if it has incompatible type.
*/
public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) {
if(!isDeepStorageNeeded()) {
return null;
}
return inv instanceof IDeepStorageUnit ? new WrappedDeepStorage((IDeepStorageUnit) inv, spark) : null;
}
/**
* This method checks for presence of Deep Storage API in the pack - if some
* other mod provides IDeepStorageUnit, support for Deep Storage will be
* used. This way we don't have to ship IDeepStorageUnit in Botania jar.
*/
private static boolean isDeepStorageNeeded() {
if(!checkedInterface) {
try {
deepStoragePresent = (Class.forName("powercrystals.minefactoryreloaded.api.IDeepStorageUnit") != null);
} catch (ClassNotFoundException e) {
deepStoragePresent = false;
}
checkedInterface = true;
FMLLog.log(Level.INFO, "[Botania] Corporea support for Deep Storage: %b", deepStoragePresent);
}
return deepStoragePresent;
}
}
@@ -0,0 +1,92 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*/
package vazkii.botania.common.integration.corporea;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.CorporeaRequest;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.IWrappedInventory;
public class WrappedIInventory extends WrappedInventoryBase{
private IInventory inv;
private WrappedIInventory(IInventory inv, ICorporeaSpark spark) {
this.inv = inv;
this.spark = spark;
}
@Override
public IInventory getWrappedObject() {
return inv;
}
@Override
public List<ItemStack> countItems(CorporeaRequest request) {
return iterateOverSlots(request, false);
}
@Override
public List<ItemStack> extractItems(CorporeaRequest request) {
return iterateOverSlots(request, true);
}
private List<ItemStack> iterateOverSlots(CorporeaRequest request, boolean doit) {
List<ItemStack> stacks = new ArrayList<ItemStack>();
boolean removedAny = false;
for (int i = inv.getSizeInventory() - 1; i >= 0; i--) {
if(!CorporeaHelper.isValidSlot(inv, i))
continue;
ItemStack stackAt = inv.getStackInSlot(i);
// WARNING: this code is very similar in all implementations of
// IWrappedInventory - keep it synch
if(isMatchingItemStack(request.matcher, request.checkNBT, stackAt)) {
int rem = Math.min(stackAt.stackSize, request.count == -1 ? stackAt.stackSize : request.count);
if(rem > 0) {
ItemStack copy = stackAt.copy();
if(rem < copy.stackSize)
copy.stackSize = rem;
stacks.add(copy);
}
request.foundItems += stackAt.stackSize;
request.extractedItems += rem;
if(doit && rem > 0) {
inv.decrStackSize(i, rem);
removedAny = true;
if(spark != null)
spark.onItemExtracted(stackAt);
}
if(request.count != -1)
request.count -= rem;
}
}
if(removedAny) {
inv.markDirty();
}
return stacks;
}
public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) {
return new WrappedIInventory(inv, spark);
}
}
@@ -0,0 +1,52 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*/
package vazkii.botania.common.integration.corporea;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.IWrappedInventory;
public abstract class WrappedInventoryBase implements IWrappedInventory {
protected ICorporeaSpark spark;
@Override
public ICorporeaSpark getSpark() {
return spark;
}
protected boolean isMatchingItemStack(Object matcher, boolean checkNBT, ItemStack stackAt) {
return matcher instanceof ItemStack ? CorporeaHelper.stacksMatch((ItemStack) matcher, stackAt, checkNBT)
: matcher instanceof String ? CorporeaHelper.stacksMatch(stackAt, (String) matcher) : false;
}
protected Collection<? extends ItemStack> breakDownBigStack(ItemStack stack) {
List<ItemStack> stacks = new ArrayList<ItemStack>();
int additionalStacks = stack.stackSize / stack.getMaxStackSize();
int lastStackSize = stack.stackSize % stack.getMaxStackSize();
if(additionalStacks > 0) {
ItemStack fullStack = stack.copy();
fullStack.stackSize = stack.getMaxStackSize();
for (int i = 0; i < additionalStacks; i++) {
stacks.add(fullStack.copy());
}
}
ItemStack lastStack = stack.copy();
lastStack.stackSize = lastStackSize;
stacks.add(lastStack);
return stacks;
}
}
@@ -0,0 +1,113 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*/
package vazkii.botania.common.integration.corporea;
import java.util.ArrayList;
import java.util.List;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.corporea.CorporeaRequest;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.IWrappedInventory;
/**
* Wrapper for StorageDrawers compatibility.
*
*/
public class WrappedStorageDrawers extends WrappedInventoryBase {
private IDrawerGroup inv;
private WrappedStorageDrawers(IDrawerGroup inv, ICorporeaSpark spark) {
this.inv = inv;
this.spark = spark;
}
@Override
public IInventory getWrappedObject() {
return (IInventory) inv;
}
@Override
public List<ItemStack> countItems(CorporeaRequest request) {
return iterateOverStacks(request, false);
}
@Override
public List<ItemStack> extractItems(CorporeaRequest request) {
return iterateOverStacks(request, true);
}
private List<ItemStack> iterateOverStacks(CorporeaRequest request, boolean doit) {
List<ItemStack> stacks = new ArrayList<ItemStack>();
boolean removedAny = false;
for(int i = 0; i < inv.getDrawerCount(); i++) {
IDrawer drawer = inv.getDrawer(i);
if(drawer == null) {
continue;
}
ItemStack prototype = drawer.getStoredItemPrototype();
int storedCount = drawer.getStoredItemCount();
// WARNING: this code is very similar in all implementations of
// IWrappedInventory - keep it synch
// also this code is near duplicate to WrappedDeepStorage - keep it
// synchronized
if(isMatchingItemStack(request.matcher, request.checkNBT, prototype)) {
int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count);
if(rem > 0) {
ItemStack copy = prototype.copy();
copy.stackSize = rem;
if(doit) {
stacks.addAll(breakDownBigStack(copy));
} else {
stacks.add(copy);
}
}
request.foundItems += storedCount;
request.extractedItems += rem;
if(doit && rem > 0) {
decreaseStoredCount(drawer, rem);
removedAny = true;
if(spark != null)
spark.onItemExtracted(prototype);
}
if(request.count != -1)
request.count -= rem;
}
}
if(removedAny) {
inv.markDirtyIfNeeded();
}
return stacks;
}
private void decreaseStoredCount(IDrawer drawer, int rem) {
drawer.setStoredItemCount(drawer.getStoredItemCount() - rem);
}
/**
* Creates {@link WrappedStorageDrawers} if specified inv can be wrapped.
*
* @return wrapped inventory or null if it has incompatible type.
*/
public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) {
return inv instanceof IDrawerGroup ? new WrappedStorageDrawers((IDrawerGroup) inv, spark) : null;
}
}
File diff suppressed because it is too large. Load diff