diff --git a/src/main/java/dev/hephaestus/glowcase/Glowcase.java b/src/main/java/dev/hephaestus/glowcase/Glowcase.java index bfcb531..3f46e45 100644 --- a/src/main/java/dev/hephaestus/glowcase/Glowcase.java +++ b/src/main/java/dev/hephaestus/glowcase/Glowcase.java @@ -3,7 +3,6 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.hephaestus.glowcase.block.HyperlinkBlock; import dev.hephaestus.glowcase.block.ItemDisplayBlock; import dev.hephaestus.glowcase.block.MailboxBlock; @@ -14,15 +13,14 @@ import dev.hephaestus.glowcase.block.entity.TextBlockEntity; import dev.hephaestus.glowcase.compat.PolydexCompatibility; import dev.hephaestus.glowcase.networking.GlowcaseCommonNetworking; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.command.argument.BlockPosArgumentType; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.item.*; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKeys; @@ -33,10 +31,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; - public class Glowcase implements ModInitializer { public static final String MODID = "glowcase"; @@ -94,7 +88,7 @@ public void onInitialize() { } } - private int sendMessage(CommandContext ctx) throws CommandSyntaxException { + private int sendMessage(CommandContext ctx) { BlockPos pos = BlockPosArgumentType.getBlockPos(ctx, "pos"); String message = ctx.getArgument("message", String.class); PlayerEntity sender = ctx.getSource().getPlayer(); diff --git a/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java b/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java index a6d342f..04f393e 100644 --- a/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java +++ b/src/main/java/dev/hephaestus/glowcase/GlowcaseClient.java @@ -2,10 +2,10 @@ import dev.hephaestus.glowcase.block.entity.MailboxBlockEntity; import dev.hephaestus.glowcase.client.GlowcaseClientProxy; +import dev.hephaestus.glowcase.client.render.block.entity.BakedBlockEntityRenderer; import dev.hephaestus.glowcase.client.render.block.entity.HyperlinkBlockEntityRenderer; import dev.hephaestus.glowcase.client.render.block.entity.ItemDisplayBlockEntityRenderer; import dev.hephaestus.glowcase.client.render.block.entity.TextBlockEntityRenderer; -import dev.hephaestus.glowcase.client.render.block.entity.BakedBlockEntityRenderer; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/dev/hephaestus/glowcase/block/HyperlinkBlock.java b/src/main/java/dev/hephaestus/glowcase/block/HyperlinkBlock.java index f0dee95..9b9adea 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/HyperlinkBlock.java +++ b/src/main/java/dev/hephaestus/glowcase/block/HyperlinkBlock.java @@ -10,9 +10,7 @@ import net.minecraft.component.type.NbtComponent; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.ItemActionResult; diff --git a/src/main/java/dev/hephaestus/glowcase/block/MailboxBlock.java b/src/main/java/dev/hephaestus/glowcase/block/MailboxBlock.java index b96da3a..dd017df 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/MailboxBlock.java +++ b/src/main/java/dev/hephaestus/glowcase/block/MailboxBlock.java @@ -2,8 +2,10 @@ import dev.hephaestus.glowcase.Glowcase; import dev.hephaestus.glowcase.block.entity.MailboxBlockEntity; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEntityProvider; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; @@ -14,7 +16,6 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; diff --git a/src/main/java/dev/hephaestus/glowcase/block/entity/ItemDisplayBlockEntity.java b/src/main/java/dev/hephaestus/glowcase/block/entity/ItemDisplayBlockEntity.java index 0da3fa0..85e1587 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/entity/ItemDisplayBlockEntity.java +++ b/src/main/java/dev/hephaestus/glowcase/block/entity/ItemDisplayBlockEntity.java @@ -6,7 +6,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; -import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.SpawnEggItem; diff --git a/src/main/java/dev/hephaestus/glowcase/block/entity/MailboxBlockEntity.java b/src/main/java/dev/hephaestus/glowcase/block/entity/MailboxBlockEntity.java index e80bdd1..1f49f8a 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/entity/MailboxBlockEntity.java +++ b/src/main/java/dev/hephaestus/glowcase/block/entity/MailboxBlockEntity.java @@ -1,13 +1,7 @@ package dev.hephaestus.glowcase.block.entity; -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.UUID; - import dev.hephaestus.glowcase.Glowcase; import dev.hephaestus.glowcase.block.MailboxBlock; -import net.minecraft.registry.RegistryWrapper; -import org.jetbrains.annotations.Nullable; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; @@ -16,9 +10,15 @@ import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.UUID; public class MailboxBlockEntity extends BlockEntity { private final Deque messages = new ArrayDeque<>(); @@ -117,7 +117,7 @@ public void removeAllMessagesFromMostRecentSender() { } } - public static record Message(UUID sender, String senderName, String message) {} + public record Message(UUID sender, String senderName, String message) {} // standard blockentity boilerplate diff --git a/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java b/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java index cd17bce..67e10ec 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java +++ b/src/main/java/dev/hephaestus/glowcase/block/entity/TextBlockEntity.java @@ -1,18 +1,10 @@ package dev.hephaestus.glowcase.block.entity; -import java.util.ArrayList; -import java.util.List; - import dev.hephaestus.glowcase.Glowcase; import dev.hephaestus.glowcase.client.render.block.entity.BakedBlockEntityRenderer; - import eu.pb4.placeholders.api.ParserContext; import eu.pb4.placeholders.api.parsers.NodeParser; import eu.pb4.placeholders.api.parsers.TagParser; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.text.Style; -import org.jetbrains.annotations.Nullable; - import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; @@ -22,14 +14,19 @@ import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.MutableText; +import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; public class TextBlockEntity extends BlockEntity { public static final NodeParser PARSER = TagParser.DEFAULT; - public List lines = new ArrayList<>(); + public List lines = new ArrayList<>(); public TextAlignment textAlignment = TextAlignment.CENTER; public ZOffset zOffset = ZOffset.CENTER; public ShadowType shadowType = ShadowType.DROP; @@ -39,7 +36,7 @@ public class TextBlockEntity extends BlockEntity { public TextBlockEntity(BlockPos pos, BlockState state) { super(Glowcase.TEXT_BLOCK_ENTITY, pos, state); - lines.add((MutableText) Text.empty()); + lines.add(Text.empty()); } @Override @@ -54,7 +51,7 @@ protected void writeNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryL tag.putString("shadow_type", this.shadowType.name()); NbtList lines = tag.getList("lines", 8); - for (MutableText text : this.lines) { + for (var text : this.lines) { lines.add(NbtString.of(Text.Serialization.toJsonString(text, registryLookup))); } diff --git a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/HyperlinkBlockEditScreen.java b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/HyperlinkBlockEditScreen.java index 4791621..db8fd90 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/HyperlinkBlockEditScreen.java +++ b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/HyperlinkBlockEditScreen.java @@ -4,9 +4,9 @@ import dev.hephaestus.glowcase.networking.GlowcaseClientNetworking; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import org.lwjgl.glfw.GLFW; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.text.Text; +import org.lwjgl.glfw.GLFW; @Environment(EnvType.CLIENT) public class HyperlinkBlockEditScreen extends GlowcaseScreen { @@ -24,8 +24,6 @@ public void init() { if (this.client == null) return; - // this.client.keyboard.setRepeatEvents(true); - this.urlEntryWidget = new TextFieldWidget(this.client.textRenderer, width / 10, height / 2 - 10, 8 * width / 10, 20, Text.empty()); this.urlEntryWidget.setText(this.hyperlinkBlockEntity.getUrl()); this.urlEntryWidget.setMaxLength(Integer.MAX_VALUE); diff --git a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java index f399dc2..2e077e0 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java +++ b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/TextBlockEditScreen.java @@ -4,24 +4,19 @@ import com.mojang.blaze3d.systems.RenderSystem; import dev.hephaestus.glowcase.block.entity.TextBlockEntity; import dev.hephaestus.glowcase.networking.GlowcaseClientNetworking; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.BufferRenderer; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.VertexFormats; +import net.minecraft.client.render.*; import net.minecraft.client.util.SelectionManager; import net.minecraft.text.Text; import net.minecraft.text.TextColor; import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - //TODO: multi-character selection at some point? it may be a bit complex but it'd be nice @Environment(EnvType.CLIENT) public class TextBlockEditScreen extends GlowcaseScreen { @@ -50,10 +45,6 @@ public void init() { int innerPadding = width / 100; - // if (this.client != null) { - // this.client.keyboard.setRepeatEvents(true); - // } - this.selectionManager = new SelectionManager( () -> this.textBlockEntity.getRawLine(this.currentRow), (string) -> { diff --git a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java index 6579f83..9baed96 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java +++ b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java @@ -3,13 +3,7 @@ import com.google.common.collect.Sets; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.logging.LogUtils; - -import it.unimi.dsi.fastutil.objects.Object2ReferenceMap; -import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap; -import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; -import it.unimi.dsi.fastutil.objects.ReferenceArrayList; +import it.unimi.dsi.fastutil.objects.*; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.MinecraftClient; @@ -22,7 +16,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import org.joml.Matrix4f; import org.slf4j.Logger; @@ -39,7 +33,8 @@ protected BakedBlockEntityRenderer(BlockEntityRendererFactory.Context context) { /** * Handles invalidation and passing of rendered vertices to the baking system. - * Override renderBaked and renderUnbaked instead of this method. + * Override {@link #renderBaked(BlockEntity, MatrixStack, VertexConsumerProvider, int, int)} and + * {@link #renderBaked(BlockEntity, MatrixStack, VertexConsumerProvider, int, int)} instead of this method. */ @Override public final void render(T entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { @@ -49,9 +44,8 @@ public final void render(T entity, float tickDelta, MatrixStack matrices, Vertex /** * Render vertices to be baked into the render region. This method will be called every time the render region is rebuilt - so - * you should only render vertices that don't move here. You can call invalidateSelf or VertexBufferManager.invalidate to + * you should only render vertices that don't move here. You can call {@link Manager#markForRebuild(BlockPos)} to * cause the render region to be rebuilt, but do not call this too frequently as it will affect performance. - * * You must use the provided VertexConsumerProvider and MatrixStack to render your vertices - any use of Tessellator * or RenderSystem here will not work. If you need custom rendering settings, you can use a custom RenderLayer. */ @@ -59,14 +53,14 @@ public final void render(T entity, float tickDelta, MatrixStack matrices, Vertex /** * Render vertices immediately. This works exactly the same way as a normal BER render method, and can be used for dynamic - * rendering that changes every frame. In this method you can also check for render invalidation and call invalidateSelf + * rendering that changes every frame. In this method you can also check for render invalidation and call {@link Manager#markForRebuild(BlockPos)} * as appropriate. */ public abstract void renderUnbaked(T entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay); public abstract boolean shouldBake(T entity); - private static record RenderRegionPos(int x, int z, @Nullable BlockPos origin) { + private record RenderRegionPos(int x, int z, @NotNull BlockPos origin) { public RenderRegionPos(int x, int z) { this(x, z, new BlockPos(x << Manager.REGION_SHIFT, 0, z << Manager.REGION_SHIFT)); } @@ -201,12 +195,10 @@ public static void render(WorldRenderContext wrc) { wrc.profiler().push("rebuild"); // Make builders for regions that are marked for rebuild, render and upload to RegionBuffers - Set rebuilt = Sets.newHashSet(); Set removing = Sets.newHashSet(); List blockEntities = new ArrayList<>(); MatrixStack bakeMatrices = new MatrixStack(); for (RenderRegionPos rrp : needsRebuild) { - rebuilt.add(rrp); if (isVisiblePos(rrp, cam)) { // For the current region, rebuild each render layer using the buffer builders // Find all block entities in this region @@ -248,7 +240,9 @@ public static void render(WorldRenderContext wrc) { } } } - rebuilt.forEach(needsRebuild::remove); + // We've processed all pending rebuilds now + needsRebuild.clear(); + // These regions no longer contain anything removing.forEach(rrp -> { RegionBuffer buf = regions.get(rrp); if (buf != null) { @@ -263,10 +257,10 @@ public static void render(WorldRenderContext wrc) { if (!regions.isEmpty()) { wrc.profiler().push("render"); - /** - * Set the fog end to a extremely high value, this is a total hack but. + /* + * Set the fog end to an extremely high value, this is a total hack but. * It's needed to make fog not bleed into text blocks - */ + */ float originalFogEnd = RenderSystem.getShaderFogEnd(); RenderSystem.setShaderFogEnd(Float.MAX_VALUE); // Iterate over all RegionBuffers, render visible and remove non-visible RegionBuffers diff --git a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/ItemDisplayBlockEntityRenderer.java b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/ItemDisplayBlockEntityRenderer.java index 789989e..ac1dfb8 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/ItemDisplayBlockEntityRenderer.java +++ b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/ItemDisplayBlockEntityRenderer.java @@ -1,7 +1,6 @@ package dev.hephaestus.glowcase.client.render.block.entity; import dev.hephaestus.glowcase.block.entity.ItemDisplayBlockEntity; - import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer.TextLayerType; import net.minecraft.client.render.LightmapTextureManager; @@ -14,7 +13,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.component.DataComponentTypes; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.SpawnEggItem; import net.minecraft.state.property.Properties; diff --git a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/TextBlockEntityRenderer.java b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/TextBlockEntityRenderer.java index 7b8097a..53e124b 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/TextBlockEntityRenderer.java +++ b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/TextBlockEntityRenderer.java @@ -1,16 +1,17 @@ package dev.hephaestus.glowcase.client.render.block.entity; -import org.joml.Matrix4f; - import dev.hephaestus.glowcase.block.entity.TextBlockEntity; import dev.hephaestus.glowcase.client.GlowcaseRenderLayers; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer.TextLayerType; -import net.minecraft.client.render.*; +import net.minecraft.client.render.LightmapTextureManager; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.state.property.Properties; import net.minecraft.util.math.RotationAxis; +import org.joml.Matrix4f; public class TextBlockEntityRenderer extends BakedBlockEntityRenderer { public TextBlockEntityRenderer(BlockEntityRendererFactory.Context context) { diff --git a/src/main/java/dev/hephaestus/glowcase/mixin/client/render/entity/EntityRenderDispatcherAccessor.java b/src/main/java/dev/hephaestus/glowcase/mixin/client/render/entity/EntityRenderDispatcherAccessor.java deleted file mode 100644 index aec8dd4..0000000 --- a/src/main/java/dev/hephaestus/glowcase/mixin/client/render/entity/EntityRenderDispatcherAccessor.java +++ /dev/null @@ -1,18 +0,0 @@ -package dev.hephaestus.glowcase.mixin.client.render.entity; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.entity.EntityType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -@Environment(EnvType.CLIENT) -@Mixin(EntityRenderDispatcher.class) -public interface EntityRenderDispatcherAccessor { - @Accessor - Map, EntityRenderer> getRenderers(); -} diff --git a/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseClientNetworking.java b/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseClientNetworking.java index d83fb42..a1ed3ed 100644 --- a/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseClientNetworking.java +++ b/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseClientNetworking.java @@ -2,18 +2,12 @@ import dev.hephaestus.glowcase.block.entity.ItemDisplayBlockEntity; import dev.hephaestus.glowcase.block.entity.TextBlockEntity; -import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.client.MinecraftClient; -import net.minecraft.network.PacketByteBuf; import net.minecraft.state.property.Properties; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec2f; -import java.util.ArrayList; - public class GlowcaseClientNetworking { public static void editHyperlinkBlock(BlockPos pos, String url) { ClientPlayNetworking.send(new GlowcaseCommonNetworking.EditHyperlinkBlock(pos, url)); @@ -49,9 +43,8 @@ public static void editTextBlock(TextBlockEntity be) { be.shadowType, new GlowcaseCommonNetworking.TextBlockValues( be.scale, - be.lines.size(), be.color, - (ArrayList) (Object) be.lines + be.lines ) )); } diff --git a/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseCommonNetworking.java b/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseCommonNetworking.java index 504c592..8704148 100644 --- a/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseCommonNetworking.java +++ b/src/main/java/dev/hephaestus/glowcase/networking/GlowcaseCommonNetworking.java @@ -21,6 +21,7 @@ import net.minecraft.util.math.RotationPropertyHelper; import java.util.ArrayList; +import java.util.List; public class GlowcaseCommonNetworking { @@ -92,10 +93,9 @@ public Id getId() { } // separated for tuple call - public record TextBlockValues(float scale, int lineCount, int color, ArrayList lines) { + public record TextBlockValues(float scale, int color, List lines) { public static final PacketCodec PACKET_CODEC = PacketCodec.tuple( PacketCodecs.FLOAT, TextBlockValues::scale, - PacketCodecs.INTEGER, TextBlockValues::lineCount, PacketCodecs.INTEGER, TextBlockValues::color, PacketCodecs.collection(ArrayList::new, TextCodecs.REGISTRY_PACKET_CODEC), TextBlockValues::lines, TextBlockValues::new @@ -118,7 +118,7 @@ public static void receive(EditTextBlock payload, ServerPlayNetworking.Context c context.player().server.execute(() -> { if(canEditGlowcase(context.player(), payload.pos(), Glowcase.TEXT_BLOCK) && context.player().getServerWorld().getBlockEntity(payload.pos()) instanceof TextBlockEntity be) { be.scale = payload.values().scale(); - be.lines = payload.values().lines().stream().map(Text::copy).toList(); + be.lines = payload.values().lines(); be.textAlignment = payload.alignment(); be.color = payload.values().color(); be.zOffset = payload.offset(); diff --git a/src/main/resources/glowcase.mixins.json b/src/main/resources/glowcase.mixins.json index d2044b9..eb40a5d 100644 --- a/src/main/resources/glowcase.mixins.json +++ b/src/main/resources/glowcase.mixins.json @@ -5,8 +5,7 @@ "mixins": [], "client": [ "client.MinecraftClientAccessor", - "client.render.ber.WorldRendererMixin", - "client.render.entity.EntityRenderDispatcherAccessor" + "client.render.ber.WorldRendererMixin" ], "injectors": { "defaultRequire": 1