|
1 | 1 | package net.neganote.gtutilities.common.item; |
2 | 2 |
|
| 3 | +import appeng.api.util.AEColor; |
3 | 4 | import com.gregtechceu.gtceu.GTCEu; |
4 | 5 | import com.gregtechceu.gtceu.api.blockentity.IPaintable; |
5 | 6 | import com.gregtechceu.gtceu.api.item.component.IAddInformation; |
@@ -182,13 +183,28 @@ 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 | + |
| 200 | + AEColor ae2Color = color == null ? |
| 201 | + AEColor.TRANSPARENT : |
| 202 | + AEColor.values()[color.ordinal()]; |
| 203 | + |
| 204 | + for (IColorableBlockEntity colorable : collected) { |
| 205 | + if (colorable.getColor() != ae2Color) { |
| 206 | + colorable.recolourBlock(null, ae2Color, player); |
| 207 | + } |
192 | 208 | } |
193 | 209 | return true; |
194 | 210 | } |
|
0 commit comments