1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-04 07:32:59 +00:00

Fix signs being empty when placed

As of 1.20, sign messages are immutable - we need to do
text = text.setMesssage(...) instead. Also do a tiny bit of cleanup to
this function while we're here.

Probably not the best use of my lunch break :D:.

Fixes #1611.
This commit is contained in:
Jonathan Coates
2023-10-20 13:32:38 +01:00
parent e3ced84885
commit 8eabd4f303
3 changed files with 170 additions and 16 deletions

View File

@@ -37,6 +37,7 @@ import net.minecraft.world.item.Items
import net.minecraft.world.item.enchantment.Enchantments
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.FenceBlock
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.array
@@ -86,6 +87,26 @@ class Turtle_Test {
thenExecute { helper.assertBlockPresent(Blocks.LAVA, BlockPos(2, 2, 2)) }
}
/**
* Checks turtles can write to signs.
*
* @see [#1611](https://github.com/cc-tweaked/CC-Tweaked/issues/1611)
*/
@GameTest
fun Place_sign(helper: GameTestHelper) = helper.sequence {
thenOnComputer {
turtle.place(ObjectArguments("Test\nmessage")).await()
.assertArrayEquals(true, message = "Placed sign")
}
thenExecute {
val sign = helper.getBlockEntity(BlockPos(2, 2, 1), BlockEntityType.SIGN)
val lines = listOf("", "Test", "message", "")
for ((i, line) in lines.withIndex()) {
assertEquals(line, sign.frontText.getMessage(i, false).string, "Line $i")
}
}
}
/**
* Checks that calling [net.minecraft.world.item.Item.use] will not place blocks too far away.
*