Reinstated Compression sigil. (#1374)

*  Reinstated Compression sigil.
- does not compress wooden planks into crafting tables
- searches for reversible 3x3/2x2 recipes with a single material type
- probably has a lot of redundant stuff and looks silly
- uses try/catch (might want to find a different approach, some people scoff at this)
- should probably have spent the night sleeping, I'm taking exams tomorrow and will probably sleep the whole day through.

* Learned how to properly handle the "NullPointerException"-situation.

* Update BaseCompressionHandler.java

* Update CompressionRegistry.java

* Removed (almost) all code comments (only a one-liner remains that serves as pointer to a completly commented-out class (StorageBlockCraftingRecipeAssimilator)).
Made methods and variables for long function calls to be more efficient.
Fixed an oversight that resulted in a NullPointerException after removing redundant checks that were made to prevent exactly that.

Rearranged and reformatted code.

* corrected something that could be considered a typo but was an oversight

* This should be it. An Array should be more efficient but you can correct me if I'm wrong. In either case it does what it is supposed to do.

* Fixed. Needed a seperate inventory for the reversible check (or clear the previously used one, but then I'd had to repopulate again and that would just have been messy)

* Forgot one of my lines.

* Fix and cleanup.
Could definitely clean more but that should suffice for now.
This commit is contained in:
AEon - Tobias 2018-08-26 22:05:30 +02:00 committed by Nick Ignoffo
parent 9440d3c0b9
commit 1f392721fa
7 changed files with 153 additions and 180 deletions

View file

@ -38,7 +38,7 @@ public class CompressionRegistry {
public static ItemStack compressInventory(ItemStack[] inv, World world) {
for (CompressionHandler handler : compressionRegistry) {
ItemStack stack = handler.compressInventory(inv, world);
if (stack != null) {
if (!stack.isEmpty()) {
return stack;
}
}
@ -78,16 +78,10 @@ public class CompressionRegistry {
}
public static int getItemThreshold(ItemStack stack) {
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet()) {
if (areItemStacksEqual(entry.getKey(), stack)) {
return entry.getValue();
}
}
return 0;
return stack.getItem().getItemStackLimit(stack); //this should work according to the guide, leaving behind a full stack of the source item (unless otherwise specified with a BaseCompressionHandler recipe)
}
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) {
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? !compressedStack.hasTagCompound() : stack.getTagCompound().equals(compressedStack.getTagCompound()));
}
}
}