Some Sign-Related changes (have to rework Signs for the new 1.20 mechanics)

This commit is contained in:
Frank 2023-05-17 15:09:53 +02:00
parent 145e6168c3
commit 465497db9a
2 changed files with 14 additions and 9 deletions

View file

@ -28,10 +28,7 @@ import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
@ -83,6 +80,11 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
return new BaseSignBlockEntity(blockPos, blockState);
}
@Override
public float getYRotationDegrees(BlockState blockState) {
return RotationSegment.convertToDegrees(blockState.getValue(ROTATION));
}
@Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
if (placer instanceof Player) {
@ -90,9 +92,9 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
if (sign != null) {
if (!world.isClientSide) {
sign.setAllowedPlayerEditor(placer.getUUID());
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos));
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos, true));
} else {
sign.setEditable(true);
//sign.setEditable(true);
}
}
}

View file

@ -23,6 +23,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(SignEditScreen.class)
public abstract class SignEditScreenMixin extends AbstractSignEditScreen {
@Shadow
private final SignBlockEntity sign;
@Shadow
private SignRenderer.SignModel signModel;
@ -31,8 +33,9 @@ public abstract class SignEditScreenMixin extends AbstractSignEditScreen {
@Unique
private boolean bclib_isSign;
public SignEditScreenMixin(SignBlockEntity signBlockEntity, boolean bl) {
super(signBlockEntity, bl);
public SignEditScreenMixin(SignBlockEntity signBlockEntity, boolean bl, boolean bl2) {
super(signBlockEntity, bl, bl2);
sign = null;
}
@ -51,7 +54,7 @@ public abstract class SignEditScreenMixin extends AbstractSignEditScreen {
private VertexConsumer bclib_renderSignBackground(VertexConsumer consumer) {
if (bclib_isSign) {
signModel.stick.visible = bclib_renderStick;
Block block = sign.getBlockState().getBlock();
Block block = this.sign.getBlockState().getBlock();
MultiBufferSource.BufferSource bufferSource = this.minecraft.renderBuffers().bufferSource();
return BaseSignBlockEntityRenderer.getConsumer(bufferSource, block);
}