Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-1.12' into master-1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Sep 9, 2020
2 parents 29039fe + 545ac9c commit 71e5e2b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
9 changes: 9 additions & 0 deletions resources/changelog/1.12.2-2.4.7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.6.0 or higher.

Fixes:
* Fix crafting table handler not accepting some recipes smaller than 3x3
Closes CyclopsMC/IntegratedCrafting#46
* Fix oredict-based ingredients being compared too strictly
Closes CyclopsMC/IntegratedCrafting#45

8 changes: 8 additions & 0 deletions resources/changelog/1.12.2-2.4.8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.6.0 or higher.

Changes:
* Reduce unneeded slot range check to improve performance
This was not needed because the wrapped item inventory
already takes care of this.
Closes CyclopsMC/IntegratedDynamics#904
Original file line number Diff line number Diff line change
Expand Up @@ -361,37 +361,26 @@ public int getSlots() {
return storage.getSlots();
}

protected void validateSlotIndex(int slot) throws IndexOutOfBoundsException {
int slots = getSlots();
if (slot < 0 || slot >= slots) {
throw new IndexOutOfBoundsException("Slot " + slot + " not in valid range - [0," + slots + ")");
}
}

@Nonnull
@Override
public ItemStack getStackInSlot(int slot) {
validateSlotIndex(slot);
return storage.getSlotContents(slot);
}

@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
validateSlotIndex(slot);
return storage.insert(slot, stack, simulate);
}

@Nonnull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
validateSlotIndex(slot);
return storage.extract(slot, amount, simulate);
}

@Override
public int getSlotLimit(int slot) {
validateSlotIndex(slot);
return Helpers.castSafe(storage.getMaxQuantity(slot));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,7 @@ public IMixedIngredients simulate(IMixedIngredients input) {
return null;
}

int rows = 2;
int columns = 2;
if (recipeIngredients.size() > 4) {
rows = 3;
columns = 3;
}
CraftingInventory inventoryCrafting = new CraftingInventory(DUMMY_CONTAINTER, rows, columns);
CraftingInventory inventoryCrafting = new CraftingInventory(DUMMY_CONTAINTER, 3, 3);
for (int i = 0; i < recipeIngredients.size(); i++) {
inventoryCrafting.setInventorySlotContents(i, recipeIngredients.get(i));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public void testGetStackInSlot() {
assertThat(eq(wrapper.getStackInSlot(8), APPLE_10), is(true));
}

@Test(expected = IndexOutOfBoundsException.class)
@Test(expected = RuntimeException.class)
public void testGetStackInSlotTooSmall() {
wrapper.getStackInSlot(-1);
}

@Test(expected = IndexOutOfBoundsException.class)
@Test(expected = RuntimeException.class)
public void testGetStackInSlotTooBig() {
wrapper.getStackInSlot(10);
}
Expand Down

0 comments on commit 71e5e2b

Please sign in to comment.