22
33import com .mojang .serialization .MapCodec ;
44import net .minecraft .client .Minecraft ;
5+ import net .minecraft .client .player .LocalPlayer ;
56import net .minecraft .core .BlockPos ;
67import net .minecraft .core .Direction ;
78import net .minecraft .util .RandomSource ;
89import net .minecraft .world .InteractionHand ;
910import net .minecraft .world .InteractionResult ;
10- import net .minecraft .world .entity .LivingEntity ;
1111import net .minecraft .world .entity .player .Player ;
1212import net .minecraft .world .item .context .BlockPlaceContext ;
1313import net .minecraft .world .level .BlockGetter ;
2020import net .minecraft .world .level .block .state .properties .BlockStateProperties ;
2121import net .minecraft .world .level .block .state .properties .EnumProperty ;
2222import net .minecraft .world .phys .BlockHitResult ;
23- import net .minecraft .world .phys .Vec3 ;
2423import net .minecraft .world .phys .shapes .CollisionContext ;
2524import net .minecraft .world .phys .shapes .VoxelShape ;
2625import org .jspecify .annotations .Nullable ;
2726import org .vfast .backrooms .blocks .entity .TextSignBlockEntity ;
2827import org .vfast .backrooms .blocks .interfaces .CeilingSupportSign ;
2928import org .vfast .backrooms .client .gui .TextSignEditScreen ;
29+ import org .vfast .backrooms .interfaces .GuiOpener ;
3030
3131public class TextSignBlock extends BaseEntityBlock implements CeilingSupportSign {
3232 public static final MapCodec <TextSignBlock > CODEC = simpleCodec (TextSignBlock ::new );
@@ -50,9 +50,8 @@ protected MapCodec<TextSignBlock> codec() {
5050 @ Override
5151 protected InteractionResult useWithoutItem (BlockState state , Level level , BlockPos pos , Player player , BlockHitResult hitResult ) {
5252 TextSignBlock .TextDirection direction = this .getFacingText (hitResult , state );
53- if (level .isClientSide () && direction != TextDirection .NONE && level .getBlockEntity (pos ) instanceof TextSignBlockEntity blockEntity ) {
54- TextSignEditScreen editScreen = new TextSignEditScreen (blockEntity , pos , this .getFacingText (hitResult , state ) == TextDirection .FRONT );
55- Minecraft .getInstance ().setScreen (editScreen );
53+ if (player instanceof GuiOpener && direction != TextDirection .NONE && level .getBlockEntity (pos ) instanceof TextSignBlockEntity blockEntity ) {
54+ ((GuiOpener ) player ).openTextSignEdit (blockEntity , pos , this .getFacingText (hitResult , state ) == TextDirection .FRONT );
5655 player .swing (InteractionHand .MAIN_HAND );
5756 return InteractionResult .SUCCESS ;
5857 } else {
0 commit comments