mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
update
This commit is contained in:
parent
d9bf9cc4ab
commit
c586355463
2 changed files with 31 additions and 12 deletions
|
|
@ -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<ContentType, TypeParser<?>> parsers = ObjectMap.of(
|
||||
ContentType.block, (TypeParser<Block>)(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;
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue