|
38 | 38 | import net.minecraftforge.common.util.TriPredicate; |
39 | 39 |
|
40 | 40 | import appeng.api.implementations.blockentities.IColorableBlockEntity; |
| 41 | +import appeng.api.util.AEColor; |
41 | 42 | import com.google.common.collect.ImmutableMap; |
42 | 43 | import org.jetbrains.annotations.NotNull; |
43 | 44 | import org.jetbrains.annotations.Nullable; |
@@ -182,13 +183,27 @@ private boolean handleSpecialBlockEntities(BlockEntity first, DyeColor color, in |
182 | 183 | var player = context.getPlayer(); |
183 | 184 | if (player == null) return false; |
184 | 185 |
|
185 | | - if (GTCEu.Mods.isAE2Loaded() && first instanceof IColorableBlockEntity colorable) { |
186 | | - appeng.api.util.AEColor ae2Color = color == null ? |
187 | | - appeng.api.util.AEColor.TRANSPARENT : |
188 | | - appeng.api.util.AEColor.values()[color.ordinal()]; |
189 | | - |
190 | | - if (colorable.getColor() != ae2Color) { |
191 | | - colorable.recolourBlock(null, ae2Color, player); |
| 186 | + if (GTCEu.Mods.isAE2Loaded() && first instanceof IColorableBlockEntity) { |
| 187 | + var collected = BreadthFirstBlockSearch.conditionalSearch( |
| 188 | + IColorableBlockEntity.class, |
| 189 | + (IColorableBlockEntity) first, |
| 190 | + first.getLevel(), |
| 191 | + be -> ((BlockEntity) be).getBlockPos(), |
| 192 | + (parent, child, dir) -> { |
| 193 | + if (parent == null) return true; |
| 194 | + return parent.getColor() == child.getColor(); |
| 195 | + }, |
| 196 | + limit, |
| 197 | + limit * 6); |
| 198 | + |
| 199 | + AEColor ae2Color = color == null ? |
| 200 | + AEColor.TRANSPARENT : |
| 201 | + AEColor.values()[color.ordinal()]; |
| 202 | + |
| 203 | + for (IColorableBlockEntity colorable : collected) { |
| 204 | + if (colorable.getColor() != ae2Color) { |
| 205 | + colorable.recolourBlock(null, ae2Color, player); |
| 206 | + } |
192 | 207 | } |
193 | 208 | return true; |
194 | 209 | } |
|
0 commit comments