Skip to content

Commit d734db7

Browse files
authored
Merge pull request #147 from jchung01/modifier-fix
Fix SingleBlockModifier applying to all blocks of the same base type in certain circumstances
2 parents dfad691 + 8cf2b3e commit d734db7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/github/kasuminova/mmce/client/gui/widget/impl/preview/WorldSceneRendererWidget.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ protected void addUpgradeIngredientToPattern(final DynamicMachine machine) {
177177
Map<BlockPos, BlockArray.BlockInformation> pattern = this.pattern.getPattern();
178178
machine.getModifiersAsMatchingReplacements().forEach((pos, infoList) -> infoList.forEach(info -> {
179179
if (pattern.containsKey(pos)) {
180-
pattern.get(pos).addMatchingStates(info.getMatchingStates());
180+
// Clone the block info, we don't want to modify the canonical instance.
181+
BlockArray.BlockInformation newInfo = pattern.get(pos).copy();
182+
newInfo.addMatchingStates(info.getMatchingStates());
183+
this.pattern.addBlock(pos, newInfo);
181184
} else {
182185
this.pattern.addBlock(pos, info);
183186
}

src/main/java/hellfirepvp/modularmachinery/client/util/DynamicMachineRenderContext.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ public static void addReplacementToBlockArray(
136136
for (BlockArray.BlockInformation info : informationList) {
137137
Map<BlockPos, BlockArray.BlockInformation> pattern = blockArray.getPattern();
138138
if (pattern.containsKey(pos)) {
139-
pattern.get(pos).addMatchingStates(info.getMatchingStates());
139+
// Clone the block info, we don't want to modify the canonical instance.
140+
BlockArray.BlockInformation newInfo = pattern.get(pos).copy();
141+
newInfo.addMatchingStates(info.getMatchingStates());
142+
blockArray.addBlock(pos, newInfo);
140143
} else {
141-
pattern.put(pos, info);
144+
blockArray.addBlock(pos, info);
142145
}
143146
}
144147
}

0 commit comments

Comments
 (0)