Skip to content

Commit bb5527b

Browse files
Fixed shift spray paint on ae2 cables (#34)
* Fixed shift spray paint. * Spotless
1 parent dc46244 commit bb5527b

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

src/main/java/net/neganote/gtutilities/common/item/InfiniteSprayCanBehaviour.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import net.minecraftforge.common.util.TriPredicate;
3939

4040
import appeng.api.implementations.blockentities.IColorableBlockEntity;
41+
import appeng.api.util.AEColor;
4142
import com.google.common.collect.ImmutableMap;
4243
import org.jetbrains.annotations.NotNull;
4344
import org.jetbrains.annotations.Nullable;
@@ -182,13 +183,27 @@ private boolean handleSpecialBlockEntities(BlockEntity first, DyeColor color, in
182183
var player = context.getPlayer();
183184
if (player == null) return false;
184185

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+
}
192207
}
193208
return true;
194209
}

0 commit comments

Comments
 (0)