From c586355463b4e63f613803fd9d2c025c2b4298bb Mon Sep 17 00:00:00 2001 From: m1cxzfw3q Date: Sat, 29 Nov 2025 14:50:12 +0800 Subject: [PATCH] update --- core/src/mindustry/mod/ContentParser.java | 31 +++++++++++++++++++++++ core/src/mindustry/world/Block.java | 12 --------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index dd93a8a1df..7e4e9e614d 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -522,6 +522,32 @@ public class ContentParser{ value.remove("consumes"); } + public void readBlockCanInputItems(Block block, JsonValue value){ + boolean[] booleans = block.itemFilter; + for(JsonValue child : value){ + switch(child.name){ + case "add" -> { + Item[] arr = child.isArray()? new Item[]{parser.readValue(Item.class, child)} : new Item[]{}; + for (Item it : arr) { + if (!booleans[it.id]) { + block.itemFilter[it.id] = true; + } + } + } + case "remove" -> { + Item[] arr = child.isArray()? new Item[]{parser.readValue(Item.class, child)} : new Item[]{}; + for (Item it : arr) { + if(booleans[it.id]){ + block.itemFilter[it.id] = false; + } + } + } + default -> throw new IllegalArgumentException("Unknown consumption type: '" + child.name + "' for block '" + block.name + "'."); + } + } + value.remove("canInputItems"); + } + private ObjectMap> parsers = ObjectMap.of( ContentType.block, (TypeParser)(mod, name, value) -> { readBundle(ContentType.block, name, value); @@ -557,6 +583,11 @@ public class ContentParser{ if(value.has("requirements") && block.buildVisibility == BuildVisibility.hidden){ block.buildVisibility = BuildVisibility.shown; } + + if(value.has("canInputItems") && value.get("canInputItems").isObject()){ + readBlockCanInputItems(block, value.get("canInputItems")); + value.remove("canInputItems"); + } }); return block; diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index b74fd04bb6..87e68b7471 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -385,8 +385,6 @@ public class Block extends UnlockableContent implements Senseable{ /** Consumption filters. */ @NoPatch public boolean[] itemFilter = {}, liquidFilter = {}; - /** Added interface for modifying itemFilter in ContentPatches */ - public Item[] acceptsItemInput = {}, denyItemInput = {}; /** Array of consumers used by this block. Only populated after init(). */ @NoPatch public Consume[] consumers = {}, optionalConsumers = {}, nonOptionalConsumers = {}, updateConsumers = {}; @@ -722,16 +720,6 @@ public class Block extends UnlockableContent implements Senseable{ setBars(); offset = ((size + 1) % 2) * tilesize / 2f; sizeOffset = -((size - 1) / 2); - for (Item it : acceptsItemInput) { - if (!itemFilter[it.id]){ - itemFilter[it.id] = true; - } - } - for (Item it : denyItemInput) { - if (itemFilter[it.id]) { - itemFilter[it.id] = false; - } - } } public boolean consumesItem(Item item){