Improve items for GameModeConfig

This commit is contained in:
2026-08-24 20:05:58 +02:00
parent 72b70a62e1
commit 5a52771ec1
12 changed files with 200 additions and 101 deletions
@@ -197,27 +197,32 @@ public class SchematicCommand extends SWCommand {
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
}
if (type.Schematic.MaxDispenserItems > 0) {
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) {
if (entry.getValue() <= type.Schematic.MaxDispenserItems) {
for (Map.Entry<BlockPos, Map<Material, Integer>> posEntry : result.getBlockScanResult().getInventoryItemCounts().entrySet()) {
BlockPos pos = posEntry.getKey();
Material inventory = result.getBlockScanResult().getInventoryBlockType().get(pos);
Map<Material, Integer> caps = type.Schematic.ItemsInInventory.getOrDefault(inventory, Collections.emptyMap());
for (Map.Entry<Material, Integer> itemEntry : posEntry.getValue().entrySet()) {
Material itemType = itemEntry.getKey();
int cap = caps.getOrDefault(itemType, Integer.MAX_VALUE);
if (itemEntry.getValue() <= cap) {
continue;
}
BlockPos pos = entry.getKey();
BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
BaseBlock block = clipboard.getFullBlock(vector);
CompoundTag tag = block.getNbtData();
CompoundTagBuilder builder = tag.createBuilder();
List<CompoundTag> items = new ArrayList<>(tag.getList("Items", CompoundTag.class));
Collections.reverse(items); // To let the first item be in the Dispenser
Collections.reverse(items); // To let the first item be in the inventory
List<CompoundTag> list = new ArrayList<>();
int diff = entry.getValue() - type.Schematic.MaxDispenserItems;
int diff = itemEntry.getValue() - cap;
for (CompoundTag item : items) {
if (item == null) {
continue;
}
if (diff == 0) {
if (diff == 0 || Material.matchMaterial(item.getString("id")) != itemType) {
list.add(item);
continue;
}