@@ -25,14 +25,19 @@ import kotlinx.coroutines.isActive
25
25
import kotlinx.coroutines.launch
26
26
import net.minecraft.block.BlockEnderChest
27
27
import net.minecraft.block.BlockShulkerBox
28
+ import net.minecraft.block.BlockStandingSign
29
+ import net.minecraft.block.BlockWallSign
30
+ import net.minecraft.block.state.BlockStateContainer.StateImplementation
28
31
import net.minecraft.block.state.IBlockState
29
32
import net.minecraft.entity.EntityList
30
33
import net.minecraft.entity.item.EntityItemFrame
31
34
import net.minecraft.init.Blocks
32
35
import net.minecraft.network.play.server.SPacketBlockChange
33
36
import net.minecraft.network.play.server.SPacketMultiBlockChange
37
+ import net.minecraft.tileentity.TileEntitySign
34
38
import net.minecraft.util.math.BlockPos
35
39
import net.minecraft.util.math.ChunkPos
40
+ import net.minecraft.util.text.TextComponentString
36
41
import net.minecraft.world.chunk.Chunk
37
42
import net.minecraftforge.fml.common.gameevent.TickEvent
38
43
import java.util.concurrent.ConcurrentHashMap
@@ -51,6 +56,7 @@ object Search : Module(
51
56
private val blockSearch by setting(" Block Search" , true )
52
57
private val illegalBedrock = setting(" Illegal Bedrock" , false )
53
58
private val illegalNetherWater = setting(" Illegal Nether Water" , false )
59
+ private val oldSigns = setting(" Old Signs" , true )
54
60
private val range by setting(" Search Range" , 512 , 0 .. 4096 , 8 )
55
61
private val yRangeBottom by setting(" Top Y" , 256 , 0 .. 256 , 1 )
56
62
private val yRangeTop by setting(" Bottom Y" , 0 , 0 .. 256 , 1 )
@@ -90,6 +96,7 @@ object Search : Module(
90
96
blockSearchList.editListeners.add { blockSearchListUpdateListener(isEnabled) }
91
97
illegalBedrock.listeners.add { blockSearchListUpdateListener(illegalBedrock.value) }
92
98
illegalNetherWater.listeners.add { blockSearchListUpdateListener(illegalNetherWater.value) }
99
+ oldSigns.listeners.add { blockSearchListUpdateListener(oldSigns.value) }
93
100
94
101
onEnable {
95
102
if (! overrideWarning && ShaderHelper .isIntegratedGraphics) {
@@ -274,6 +281,11 @@ object Search : Module(
274
281
for (y in yRange) for (x in xRange) for (z in zRange) {
275
282
val pos = BlockPos (x, y, z)
276
283
val blockState = chunk.getBlockState(pos)
284
+ if (isOldSign(blockState, pos)) {
285
+ val signState = if (blockState.block == Blocks .STANDING_SIGN ) OldStandingSign (blockState) else OldWallSign (blockState)
286
+ blocks.add((pos to signState))
287
+ continue // skip searching for regular sign at this pos
288
+ }
277
289
if (searchQuery(blockState, pos)) blocks.add((pos to blockState))
278
290
}
279
291
return blocks
@@ -311,6 +323,22 @@ object Search : Module(
311
323
return player.dimension == - 1 && state.isWater
312
324
}
313
325
326
+ private fun SafeClientEvent.isOldSign (state : IBlockState , pos : BlockPos ): Boolean {
327
+ if (! oldSigns.value) return false
328
+ return (state.block == Blocks .STANDING_SIGN || state.block == Blocks .WALL_SIGN ) && isOldSignText(pos)
329
+ }
330
+
331
+ private fun SafeClientEvent.isOldSignText (pos : BlockPos ): Boolean {
332
+ // Explanation: Old signs on 2b2t (pre-2015 <1.9 ?) have older style NBT text tags.
333
+ // we can tell them apart by checking if there are siblings in the tag. Old signs won't have siblings.
334
+ val signTextComponents = listOf (world.getTileEntity(pos))
335
+ .filterIsInstance<TileEntitySign >()
336
+ .flatMap { it.signText.toList() }
337
+ .filterIsInstance<TextComponentString >()
338
+ .toList()
339
+ return signTextComponents.isNotEmpty() && signTextComponents.all { it.siblings.size == 0 }
340
+ }
341
+
314
342
private fun SafeClientEvent.getBlockColor (pos : BlockPos , blockState : IBlockState ): ColorHolder {
315
343
val block = blockState.block
316
344
return if (autoBlockColor) {
@@ -325,6 +353,12 @@ object Search : Module(
325
353
is BlockEnderChest -> {
326
354
ColorHolder (64 , 49 , 114 )
327
355
}
356
+ is BlockOldStandingSign -> {
357
+ ColorHolder (0 , 0 , 220 , 100 )
358
+ }
359
+ is BlockOldWallSign -> {
360
+ ColorHolder (0 , 0 , 220 , 100 )
361
+ }
328
362
else -> {
329
363
val colorInt = blockState.getMapColor(world, pos).colorValue
330
364
ColorHolder ((colorInt shr 16 ), (colorInt shr 8 and 255 ), (colorInt and 255 ))
@@ -341,4 +375,8 @@ object Search : Module(
341
375
}
342
376
}
343
377
378
+ class OldWallSign (blockStateIn : IBlockState ): StateImplementation(BlockOldWallSign , blockStateIn.properties)
379
+ class OldStandingSign (blockStateIn : IBlockState ): StateImplementation(BlockOldStandingSign , blockStateIn.properties)
380
+ object BlockOldWallSign: BlockWallSign()
381
+ object BlockOldStandingSign: BlockStandingSign()
344
382
}
0 commit comments