Skip to content

Commit

Permalink
Fix upgrade tool incorrectly counting required items
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 9, 2019
1 parent 55e91b7 commit 8b83a60
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/org/cyclops/colossalchests/item/ItemUpgradeTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ protected L10NHelpers.UnlocalizedString attemptTransform(final World world, Bloc
Vec3i size = tile.getSize();

// Calculate required item blocks
final ItemStack requiredCores = new ItemStack(newType.getBlockCore());
final ItemStack requiredInterfaces = new ItemStack(newType.getBlockInterface());
final ItemStack requiredWalls = new ItemStack(newType.getBlockWall());
ChestMaterial validMaterial = null;
Wrapper<Integer> requiredCoresCount = new Wrapper<>(0);
Wrapper<Integer> requiredInterfacesCount = new Wrapper<>(0);
Wrapper<Integer> requiredWallsCount = new Wrapper<>(0);
for (ChestMaterial material : ChestMaterial.VALUES) {
DetectionResult result = material.getChestDetector().detect(world, pos, null, (location, blockState) -> {
if (blockState.getBlock() instanceof ColossalChest) {
requiredCores.grow(1);
requiredCoresCount.set(requiredCoresCount.get() + 1);
} else if (blockState.getBlock() instanceof Interface) {
requiredInterfaces.grow(1);
requiredInterfacesCount.set(requiredCoresCount.get() + 1);
} else if (blockState.getBlock() instanceof ChestWall) {
requiredWalls.grow(1);
requiredWallsCount.set(requiredCoresCount.get() + 1);
}
return null;
}, false);
Expand All @@ -115,6 +115,10 @@ protected L10NHelpers.UnlocalizedString attemptTransform(final World world, Bloc
}
}

ItemStack requiredCores = new ItemStack(newType.getBlockCore(), requiredCoresCount.get());
ItemStack requiredInterfaces = new ItemStack(newType.getBlockInterface(), requiredInterfacesCount.get());
ItemStack requiredWalls = new ItemStack(newType.getBlockWall(), requiredWallsCount.get());

if (validMaterial == null) {
return new L10NHelpers.UnlocalizedString("multiblock.colossalchests.error.unexpected");
}
Expand Down

0 comments on commit 8b83a60

Please sign in to comment.