Skip to content

Commit 9b672be

Browse files
Signs.
1 parent 11d67be commit 9b672be

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import net.minecraft.world.level.block.StainedGlassPaneBlock;
3333
import net.minecraft.world.level.block.entity.BlockEntity;
3434
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
35+
import net.minecraft.world.level.block.entity.SignBlockEntity;
3536
import net.minecraft.world.level.block.state.BlockState;
3637
import net.minecraft.world.level.block.state.properties.Property;
3738
import net.minecraftforge.common.Tags;
@@ -183,6 +184,10 @@ private boolean handleSpecialBlockEntities(BlockEntity first, DyeColor color, in
183184
var player = context.getPlayer();
184185
if (player == null) return false;
185186

187+
if (first instanceof SignBlockEntity sign) {
188+
return handleSignRecolor(sign, color, context);
189+
}
190+
186191
if (GTCEu.Mods.isAE2Loaded() && first instanceof IColorableBlockEntity) {
187192
var collected = BreadthFirstBlockSearch.conditionalSearch(
188193
IColorableBlockEntity.class,
@@ -237,6 +242,38 @@ else if (first instanceof ShulkerBoxBlockEntity shulkerBox) {
237242
return false;
238243
}
239244

245+
private boolean handleSignRecolor(SignBlockEntity sign, @Nullable DyeColor color, UseOnContext context) {
246+
Level level = context.getLevel();
247+
Player player = context.getPlayer();
248+
if (player == null) return false;
249+
250+
boolean isFront = sign.isFacingFrontText(player);
251+
252+
var signText = sign.getText(isFront);
253+
254+
if (sign.isWaxed()) return false;
255+
256+
DyeColor targetColor = (color == null) ? DyeColor.BLACK : color;
257+
boolean changed = false;
258+
259+
if (signText.getColor() != targetColor) {
260+
sign.updateText(text -> text.setColor(targetColor), isFront);
261+
changed = true;
262+
}
263+
264+
if (color == null && signText.hasGlowingText()) {
265+
sign.updateText(text -> text.setHasGlowingText(false), isFront);
266+
changed = true;
267+
}
268+
269+
if (changed && level != null) {
270+
level.sendBlockUpdated(sign.getBlockPos(), sign.getBlockState(), sign.getBlockState(), 3);
271+
return true;
272+
}
273+
274+
return false;
275+
}
276+
240277
private <T extends IPaintable> void paintPaintables(Set<T> paintables, DyeColor color) {
241278
for (var c : paintables) {
242279
paintPaintable(c, color);

0 commit comments

Comments
 (0)