Use multiple stacks to give blocks. This closes
@@ -327,11 +327,14 @@ private String giveBlock(BlockFamily blockFamily, int quantity, EntityRef client
if (quantity < 1) {
return "Here, have these zero (0) blocks just like you wanted";
}
-
- EntityRef item = blockItemFactory.newInstance(blockFamily, quantity);
+ //continue giving blocks until there are no more blocks to give
+ //TODO reference maxStackSize instead of explicitely subtracting 99
+ for(int quantityLeft = quantity; quantityLeft > 0; quantityLeft -= 99) {
+ EntityRef item = blockItemFactory.newInstance(blockFamily, quantityLeft > 99 ? 99 : quantityLeft);
if (!item.exists()) {
throw new IllegalArgumentException("Unknown block or item");
}
+
EntityRef playerEntity = client.getComponent(ClientComponent.class).character;
GiveItemEvent giveItemEvent = new GiveItemEvent(playerEntity);
@@ -339,6 +342,7 @@ private String giveBlock(BlockFamily blockFamily, int quantity, EntityRef client
if (!giveItemEvent.isHandled()) {
item.destroy();
}
+ }
return "You received " + quantity + " blocks of " + blockFamily.getDisplayName();
}
