mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 06:22:17 -08:00
Fixed #11465
This commit is contained in:
parent
fb94d9777a
commit
7ca16fee2a
2 changed files with 22 additions and 2 deletions
|
|
@ -370,10 +370,10 @@ public class DataPatcher{
|
|||
Reflect.set(fobj, fdata.field, fv);
|
||||
}, value, true);
|
||||
}else if(value instanceof JsonValue jsv && object instanceof Block bl && jsv.isObject() && field.equals("consumes")){
|
||||
modifiedField(bl, "consumeBuilder", Reflect.<Seq<Consume>>get(Block.class, bl, "consumeBuilder").copy());
|
||||
modifiedField(bl, "consumers", Reflect.<Consume[]>get(Block.class, bl, "consumers"));
|
||||
Seq<Consume> prevBuilder = Reflect.<Seq<Consume>>get(Block.class, bl, "consumeBuilder").copy();
|
||||
boolean hadItems = bl.hasItems, hadLiquids = bl.hasLiquids, hadPower = bl.hasPower, acceptedItems = bl.acceptsItems;
|
||||
reset(() -> {
|
||||
Reflect.set(Block.class, bl, "consumeBuilder", prevBuilder);
|
||||
bl.reinitializeConsumers();
|
||||
bl.hasItems = hadItems;
|
||||
bl.hasLiquids = hadLiquids;
|
||||
|
|
|
|||
|
|
@ -138,6 +138,26 @@ public class PatcherTests{
|
|||
assertEquals(prev, reconstructor.upgrades);
|
||||
}
|
||||
|
||||
@Test
|
||||
void consumeApply() throws Exception{
|
||||
Vars.state.patcher.apply(Seq.with(
|
||||
"""
|
||||
block.conveyor.consumes: {power: 1}
|
||||
"""
|
||||
));
|
||||
|
||||
assertNoWarnings();
|
||||
assertTrue(Blocks.conveyor.hasPower);
|
||||
assertNotNull(Blocks.conveyor.consPower);
|
||||
assertEquals(1, Blocks.conveyor.consumers.length);
|
||||
|
||||
resetAfter();
|
||||
|
||||
assertFalse(Blocks.conveyor.hasPower);
|
||||
assertNull(Blocks.conveyor.consPower);
|
||||
assertEquals(0, Blocks.conveyor.consumers.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unitWeapons() throws Exception{
|
||||
UnitTypes.dagger.checkStats();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue