diff options
| author | shedaniel <daniel@shedaniel.me> | 2019-12-08 12:38:50 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2019-12-08 12:38:50 +0800 |
| commit | 237fb0b83944fc2fd4960bdc8a8b518a8ca9aaaf (patch) | |
| tree | 4851fe9d8166b7b5b7b24363f72468eb87924029 /src/main/java/me/shedaniel/rei/server | |
| parent | 89843ec1ae0cc0f7c3dc9c6c9050ae84ff1018ce (diff) | |
| download | RoughlyEnoughItems-237fb0b83944fc2fd4960bdc8a8b518a8ca9aaaf.tar.gz RoughlyEnoughItems-237fb0b83944fc2fd4960bdc8a8b518a8ca9aaaf.tar.bz2 RoughlyEnoughItems-237fb0b83944fc2fd4960bdc8a8b518a8ca9aaaf.zip | |
Warn on no container info
Diffstat (limited to 'src/main/java/me/shedaniel/rei/server')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java | 10 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java | 17 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java b/src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java index 51f98cb2e..3ea2dc4f4 100644 --- a/src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java +++ b/src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java @@ -12,19 +12,19 @@ import net.minecraft.util.Identifier; import java.util.Map; public class ContainerInfoHandler { - private static final Map<Identifier, Map<Class<? extends Container>, ContainerInfo>> containerInfoMap = Maps.newHashMap(); + private static final Map<String, Map<Class<? extends Container>, ContainerInfo>> containerInfoMap = Maps.newHashMap(); public static void registerContainerInfo(Identifier category, ContainerInfo containerInfo) { if (!containerInfoMap.containsKey(category)) - containerInfoMap.put(category, Maps.newHashMap()); - containerInfoMap.get(category).put(containerInfo.getContainerClass(), containerInfo); + containerInfoMap.put(category.toString(), Maps.newHashMap()); + containerInfoMap.get(category.toString()).put(containerInfo.getContainerClass(), containerInfo); } public static boolean isCategoryHandled(Identifier category) { - return containerInfoMap.containsKey(category) && !containerInfoMap.get(category).isEmpty(); + return containerInfoMap.containsKey(category.toString()) && !containerInfoMap.get(category.toString()).isEmpty(); } public static ContainerInfo getContainerInfo(Identifier category, Class<?> containerClass) { - return containerInfoMap.get(category).get(containerClass); + return isCategoryHandled(category) ? containerInfoMap.get(category.toString()).get(containerClass) : null; } } diff --git a/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java b/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java index 03abd2170..57f0b8897 100644 --- a/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java +++ b/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java @@ -20,10 +20,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.DefaultedList; import net.minecraft.util.Identifier; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner<Integer> { @@ -38,7 +35,7 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner< } public static <C extends Inventory> void start(Identifier category, Container craftingContainer_1, ServerPlayerEntity player, Map<Integer, List<ItemStack>> map, boolean hasShift) { - ContainerInfo containerInfo = ContainerInfoHandler.getContainerInfo(category, craftingContainer_1.getClass()); + ContainerInfo containerInfo = Objects.requireNonNull(ContainerInfoHandler.getContainerInfo(category, craftingContainer_1.getClass()), "Container Info does not exist on the server!"); new InputSlotCrafter<C>(craftingContainer_1, containerInfo).fillInputSlots(player, map, hasShift); } @@ -107,7 +104,7 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner< protected void fillInputSlots(RecipeFinder recipeFinder, DefaultedList<Ingredient> ingredients, boolean hasShift) { // boolean boolean_2 = this.craftingContainer.matches(recipe_1); boolean boolean_2 = false; - int int_1 = recipeFinder.countRecipeCrafts(ingredients, (IntList) null); + int int_1 = recipeFinder.countRecipeCrafts(ingredients, null); int int_2; if (boolean_2) { for (int_2 = 0; int_2 < this.containerInfo.getCraftingHeight(craftingContainer) * this.containerInfo.getCraftingWidth(craftingContainer) + 1; ++int_2) { @@ -201,10 +198,10 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner< if (!itemStack_1.isEmpty()) { int int_3 = this.inventory.getOccupiedSlotWithRoomForStack(itemStack_1); if (int_3 == -1 && list_1.size() <= int_1) { - Iterator var6 = list_1.iterator(); + Iterator<ItemStack> var6 = list_1.iterator(); while (var6.hasNext()) { - ItemStack itemStack_2 = (ItemStack) var6.next(); + ItemStack itemStack_2 = var6.next(); if (itemStack_2.isItemEqualIgnoreDamage(itemStack_1) && itemStack_2.getCount() != itemStack_2.getMaxCount() && itemStack_2.getCount() + itemStack_1.getCount() <= itemStack_2.getMaxCount()) { itemStack_2.increment(itemStack_1.getCount()); itemStack_1.setCount(0); @@ -231,9 +228,9 @@ public class InputSlotCrafter<C extends Inventory> implements RecipeGridAligner< private int getFreeInventorySlots() { int int_1 = 0; - Iterator var2 = this.inventory.main.iterator(); + Iterator<ItemStack> var2 = this.inventory.main.iterator(); while (var2.hasNext()) { - ItemStack itemStack_1 = (ItemStack) var2.next(); + ItemStack itemStack_1 = var2.next(); if (itemStack_1.isEmpty()) { ++int_1; } |
