|
32 | 32 | import net.minecraft.world.level.block.StainedGlassPaneBlock; |
33 | 33 | import net.minecraft.world.level.block.entity.BlockEntity; |
34 | 34 | import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; |
| 35 | +import net.minecraft.world.level.block.entity.SignBlockEntity; |
35 | 36 | import net.minecraft.world.level.block.state.BlockState; |
36 | 37 | import net.minecraft.world.level.block.state.properties.Property; |
37 | 38 | import net.minecraftforge.common.Tags; |
@@ -183,6 +184,10 @@ private boolean handleSpecialBlockEntities(BlockEntity first, DyeColor color, in |
183 | 184 | var player = context.getPlayer(); |
184 | 185 | if (player == null) return false; |
185 | 186 |
|
| 187 | + if (first instanceof SignBlockEntity sign) { |
| 188 | + return handleSignRecolor(sign, color, context); |
| 189 | + } |
| 190 | + |
186 | 191 | if (GTCEu.Mods.isAE2Loaded() && first instanceof IColorableBlockEntity) { |
187 | 192 | var collected = BreadthFirstBlockSearch.conditionalSearch( |
188 | 193 | IColorableBlockEntity.class, |
@@ -237,6 +242,38 @@ else if (first instanceof ShulkerBoxBlockEntity shulkerBox) { |
237 | 242 | return false; |
238 | 243 | } |
239 | 244 |
|
| 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 | + |
240 | 277 | private <T extends IPaintable> void paintPaintables(Set<T> paintables, DyeColor color) { |
241 | 278 | for (var c : paintables) { |
242 | 279 | paintPaintable(c, color); |
|
0 commit comments