From 594ecbf6903c9cc8825906fedc87f0af26d70dbe Mon Sep 17 00:00:00 2001 From: Mat0u5 Date: Wed, 24 Jun 2026 15:27:08 +0200 Subject: [PATCH 1/6] 26.2 init --- fabric/build.gradle | 2 +- fabric/src/main/resources/fabric.mod.json | 4 ++-- forge/src/main/resources/META-INF/mods.toml | 4 ++-- gradle.properties | 12 ++++++------ neoforge/build.gradle | 4 ++-- .../src/main/resources/META-INF/neoforge.mods.toml | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index e7a72e0..f0970a2 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -37,7 +37,7 @@ dependencies { implementation "com.electronwill.night-config:core:${project.nightconfigVersion}" implementation "com.electronwill.night-config:toml:${project.nightconfigVersion}" - implementation files("../libs/sodium-fabric-0.8.12+mc26.1.2.jar") + implementation files("../libs/sodium-fabric-0.9.0+mc26.2.jar") common(project(path: ":common")) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionFabric') diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 7fb7794..65d56d2 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -35,12 +35,12 @@ "depends": { "fabricloader": ">=0.16.0", "fabric-api": "*", - "minecraft": ">=26.1", + "minecraft": ">=26.2", "java": ">=25" }, "suggests": { "sodium": ">=0.6.0", - "prism": ">=1.1.0" + "prism": ">=1.1.2" }, "custom": { "modupdater": { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 00bfb34..cd694d6 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -15,14 +15,14 @@ description="A library containing events, helpers, and utilities to make modding [[dependencies.iceberg]] modId="forge" mandatory=true - versionRange="[64,)" + versionRange="[65,)" ordering="NONE" side="BOTH" [[dependencies.iceberg]] modId="minecraft" mandatory=true - versionRange="[26.1,)" + versionRange="[26.2,)" ordering="NONE" side="BOTH" diff --git a/gradle.properties b/gradle.properties index 7a6835b..9d53919 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,16 +7,16 @@ org.gradle.parallel=true name=Iceberg group=com.anthonyhilyard.iceberg author=anthonyhilyard -modVersion=1.4.1 +modVersion=1.4.2 enabledPlatforms=fabric,forge,neoforge fabric.loom.disableRemappedVariants=true # Minecraft properties -minecraftVersion=26.1.2 +minecraftVersion=26.2 # Dependencies -fabricLoaderVersion=0.19.2 -fabricVersion=0.149.1+26.1.2 -forgeVersion=26.1.2-64.0.8 -neoforgeVersion=26.1.2.66-beta +fabricLoaderVersion=0.19.3 +fabricVersion=0.153.0+26.2 +forgeVersion=26.2-65.0.0 +neoforgeVersion=26.2.0.7-beta nightconfigVersion=3.6.4 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 80fa3af..2ce1e63 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -34,8 +34,8 @@ repositories { dependencies { neoForge "net.neoforged:neoforge:$rootProject.neoforgeVersion" // For some reason sodium for neoforge bundles its main logic so we have to do compile only for the fabric version, to prevent errors. - compileOnly files("../libs/sodium-fabric-0.8.12+mc26.1.2.jar") - runtimeOnly files("../libs/sodium-neoforge-0.8.12+mc26.1.2.jar") + compileOnly files("../libs/sodium-fabric-0.9.0+mc26.2.jar") + runtimeOnly files("../libs/sodium-neoforge-0.9.0+mc26.2.jar") implementation "net.bytebuddy:byte-buddy:1.14.18" common(project(path: ":common")) { transitive false } diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index d7f2c25..ef51c8e 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -15,14 +15,14 @@ license="CC BY-NC-ND 4.0" [[dependencies.iceberg]] modId="neoforge" type="required" - versionRange="[26.1,)" + versionRange="[26.2,)" ordering="NONE" side="BOTH" [[dependencies.iceberg]] modId="minecraft" type="required" - versionRange="[26.1,)" + versionRange="[26.2,)" ordering="NONE" side="BOTH" From dc121ced25d88d0502c40700944fca331d6072d3 Mon Sep 17 00:00:00 2001 From: Mat0u5 Date: Thu, 25 Jun 2026 13:38:02 +0200 Subject: [PATCH 2/6] 26.2 progress --- .../iceberg/renderer/CustomItemRenderer.java | 95 +++++-------------- .../iceberg/util/ItemColor.java | 2 +- 2 files changed, 26 insertions(+), 71 deletions(-) diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java index 50755c5..97ba2d4 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java @@ -3,6 +3,7 @@ import com.anthonyhilyard.iceberg.util.EntityCollector; import com.anthonyhilyard.iceberg.util.IGuiRenderStateAccess; import com.anthonyhilyard.iceberg.util.ItemUtil; +import com.mojang.blaze3d.GpuFormat; import com.mojang.blaze3d.ProjectionType; import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.pipeline.TextureTarget; @@ -12,8 +13,6 @@ import com.mojang.blaze3d.textures.FilterMode; import com.mojang.blaze3d.textures.GpuSampler; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.QuadInstance; -import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.datafixers.util.Pair; import com.mojang.math.Axis; import net.minecraft.client.Minecraft; @@ -29,19 +28,13 @@ import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.client.renderer.item.TrackingItemStackRenderState; -import net.minecraft.client.renderer.rendertype.RenderType; import net.minecraft.client.renderer.state.gui.BlitRenderState; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.resources.model.geometry.BakedQuad; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.core.component.DataComponentMap; import net.minecraft.util.ARGB; import net.minecraft.util.LightCoordsUtil; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntitySpawnReason; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.*; import net.minecraft.world.entity.animal.equine.Horse; import net.minecraft.world.entity.animal.wolf.Wolf; import net.minecraft.world.entity.decoration.ArmorStand; @@ -55,20 +48,19 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -import org.joml.Matrix3x2f; -import org.joml.Matrix4f; -import org.joml.Matrix4fStack; -import org.joml.Quaternionf; +import org.joml.*; +import java.lang.Math; import java.util.List; +import java.util.Optional; import java.util.OptionalDouble; -import java.util.OptionalInt; public class CustomItemRenderer { private final Minecraft minecraft; private RenderTarget renderTarget; private final ProjectionMatrixBuffer projectionMatrixBuffer; + private final SubmitNodeStorage submitNodeStorage = new SubmitNodeStorage(); private boolean isClosed = false; private static ArmorStand armorStand = null; @@ -82,7 +74,6 @@ public class CustomItemRenderer private static Pair cachedEntityItem = null; private final BlockModelRenderState blockRenderState = new BlockModelRenderState(); - private final QuadInstance quadInstance = new QuadInstance(); public CustomItemRenderer(Minecraft mc) { @@ -132,13 +123,13 @@ private void drawAndBlit(GuiGraphicsExtractor graphics, ItemStack stack, int x, { renderTarget.destroyBuffers(); } - renderTarget = new TextureTarget("Iceberg Item Renderer", fboSize, fboSize, true); + renderTarget = new TextureTarget("Iceberg Item Renderer", fboSize, fboSize, true, GpuFormat.RGBA8_UNORM); } try (RenderPass clearPass = RenderSystem.getDevice().createCommandEncoder().createRenderPass( () -> "Item", // 0x00000000 is a transparent black (outline). - renderTarget.getColorTextureView(), OptionalInt.of(0x00000000), + renderTarget.getColorTextureView(), Optional.of(new Vector4f(0, 0, 0, 0)), renderTarget.getDepthTextureView(), OptionalDouble.of(1.0) )) {} @@ -168,11 +159,9 @@ private void drawAndBlit(GuiGraphicsExtractor graphics, ItemStack stack, int x, boolean is3D = itemState.usesBlockLight() || isSpinning; boolean renderedEntity = false; - MultiBufferSource.BufferSource bufferSource = minecraft.renderBuffers().bufferSource(); - if (renderEntities) { - if (tryEntityRenderers(stack, poseStack, rotation, bufferSource)) + if (tryEntityRenderers(stack, poseStack, rotation)) { renderedEntity = true; is3D = true; @@ -186,22 +175,20 @@ private void drawAndBlit(GuiGraphicsExtractor graphics, ItemStack stack, int x, if (!is3D) { - minecraft.gameRenderer.getLighting().setupFor(Lighting.Entry.ITEMS_FLAT); + minecraft.gameRenderer.lighting().setupFor(Lighting.Entry.ITEMS_FLAT); } if (!renderedEntity) { - SubmitNodeStorage submitNodeStorage = minecraft.gameRenderer.getSubmitNodeStorage(); itemState.submit(poseStack, submitNodeStorage, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, 0); } - minecraft.gameRenderer.getFeatureRenderDispatcher().renderAllFeatures(); - bufferSource.endBatch(); + minecraft.gameRenderer.featureRenderDispatcher().renderAllFeatures(submitNodeStorage); if (!is3D) { // We must set the renderer lighting back to 3D. - minecraft.gameRenderer.getLighting().setupFor(Lighting.Entry.ITEMS_3D); + minecraft.gameRenderer.lighting().setupFor(Lighting.Entry.ITEMS_3D); } modelViewStack.popMatrix(); @@ -224,7 +211,7 @@ private void drawAndBlit(GuiGraphicsExtractor graphics, ItemStack stack, int x, )); } - private boolean tryEntityRenderers(ItemStack stack, PoseStack poseStack, Quaternionf rotation, MultiBufferSource.BufferSource bufferSource) + private boolean tryEntityRenderers(ItemStack stack, PoseStack poseStack, Quaternionf rotation) { boolean renderedEntity = false; @@ -280,14 +267,14 @@ private boolean tryEntityRenderers(ItemStack stack, PoseStack poseStack, Quatern BlockState bottomState = blockState.setValue( BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER); - renderBlockState(bottomState, poseStack, bufferSource, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); + renderBlockState(bottomState, poseStack, submitNodeStorage, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); poseStack.pushPose(); poseStack.translate(0.0f, 1.0f, 0.0f); BlockState topState = blockState.setValue( BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.UPPER); - renderBlockState(topState, poseStack, bufferSource, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); + renderBlockState(topState, poseStack, submitNodeStorage, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); poseStack.popPose(); } else @@ -295,7 +282,7 @@ private boolean tryEntityRenderers(ItemStack stack, PoseStack poseStack, Quatern // Normal blocks logic. poseStack.scale(0.5f, 0.5f, 0.5f); poseStack.translate(-0.5f, -0.5f, -0.5f); - renderBlockState(blockState, poseStack, bufferSource, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); + renderBlockState(blockState, poseStack, submitNodeStorage, LightCoordsUtil.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); } // Renderer for block entities. @@ -311,43 +298,13 @@ private boolean tryEntityRenderers(ItemStack stack, PoseStack poseStack, Quatern return renderedEntity; } - private void renderBlockState(BlockState blockState, PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, int lightCoords, int overlayCoords) + private void renderBlockState(BlockState blockState, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords) { blockRenderState.clear(); - BlockStateModel model = minecraft.getModelManager().getBlockStateModelSet().get(blockState); - RenderType renderType = model.hasMaterialFlag(1) - ? Sheets.translucentBlockSheet() - : Sheets.cutoutBlockSheet(); - List parts = blockRenderState.setupModel(new Matrix4f(), model.hasMaterialFlag(1)); model.collectParts(blockRenderState.scratchRandomSource(1), parts); - - VertexConsumer buffer = bufferSource.getBuffer(renderType); - PoseStack.Pose pose = poseStack.last(); - int[] tints = blockRenderState.tintLayers().toArray(BlockModelRenderState.EMPTY_TINTS); - - quadInstance.setLightCoords(lightCoords); - quadInstance.setOverlayCoords(overlayCoords); - - for (BlockStateModelPart part : parts) - { - for (Direction dir : Direction.values()) - { - for (BakedQuad quad : part.getQuads(dir)) - { - int ti = quad.materialInfo().tintIndex(); - quadInstance.setColor(ti != -1 && ti < tints.length ? tints[ti] : -1); - buffer.putBakedQuad(pose, quad, quadInstance); - } - } - for (BakedQuad quad : part.getQuads(null)) - { - int ti = quad.materialInfo().tintIndex(); - quadInstance.setColor(ti != -1 && ti < tints.length ? tints[ti] : -1); - buffer.putBakedQuad(pose, quad, quadInstance); - } - } + blockRenderState.submit(poseStack, submitNodeCollector, lightCoords, overlayCoords, 0); } private boolean renderArmor(ItemStack stack, PoseStack poseStack) @@ -427,8 +384,7 @@ private void renderEntityModel(T try { - SubmitNodeCollector submitNodeCollector = minecraft.gameRenderer.getSubmitNodeStorage(); - renderer.submit(state, poseStack, submitNodeCollector, null); + renderer.submit(state, poseStack, submitNodeStorage, null); } catch (Exception e) {} poseStack.popPose(); @@ -453,8 +409,7 @@ private boolean render float partialTicks = minecraft.getDeltaTracker().getGameTimeDeltaTicks(); renderer.extractRenderState((T) blockEntity, state, partialTicks, net.minecraft.world.phys.Vec3.ZERO, null); - SubmitNodeCollector submitNodeCollector = minecraft.gameRenderer.getSubmitNodeStorage(); - renderer.submit(state, poseStack, submitNodeCollector, null); + renderer.submit(state, poseStack, submitNodeStorage, null); return true; } @@ -496,7 +451,7 @@ private boolean updateArmorStand(ItemStack itemStack) if (armorStand == null && minecraft.level != null) { - armorStand = EntityType.ARMOR_STAND.create(minecraft.level, EntitySpawnReason.COMMAND); + armorStand = EntityTypes.ARMOR_STAND.create(minecraft.level, EntitySpawnReason.COMMAND); if (armorStand != null) { armorStand.setInvisible(true); @@ -525,7 +480,7 @@ private boolean updateHorseArmor(ItemStack horseArmorItem) { if (horse == null && minecraft.level != null) { - horse = EntityType.HORSE.create(minecraft.level, EntitySpawnReason.COMMAND); + horse = EntityTypes.HORSE.create(minecraft.level, EntitySpawnReason.COMMAND); if (horse != null) { horse.setInvisible(true); @@ -540,7 +495,7 @@ private boolean updateHorseArmor(ItemStack horseArmorItem) Pair currentItem = Pair.of(horseArmorItem.getItem(), horseArmorItem.getComponents()); if (!currentItem.equals(cachedHorseArmorItem)) { - horse.setBodyArmorItem(horseArmorItem); + horse.setItemSlot(EquipmentSlot.BODY, horseArmorItem); cachedHorseArmorItem = currentItem; } return true; @@ -550,7 +505,7 @@ private boolean updateWolfArmor(ItemStack wolfArmorItem) { if (wolf == null && minecraft.level != null) { - wolf = EntityType.WOLF.create(minecraft.level, EntitySpawnReason.COMMAND); + wolf = EntityTypes.WOLF.create(minecraft.level, EntitySpawnReason.COMMAND); if (wolf != null) { wolf.setInvisible(true); @@ -565,7 +520,7 @@ private boolean updateWolfArmor(ItemStack wolfArmorItem) Pair currentItem = Pair.of(wolfArmorItem.getItem(), wolfArmorItem.getComponents()); if (!currentItem.equals(cachedWolfArmorItem)) { - wolf.setBodyArmorItem(wolfArmorItem); + wolf.setItemSlot(EquipmentSlot.BODY, wolfArmorItem); cachedWolfArmorItem = currentItem; } return true; diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java b/common/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java index b1dffa4..4ca34b2 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java @@ -47,7 +47,7 @@ public static TextColor findFirstColorCode(Component textComponent) try { ChatFormatting format = ChatFormatting.getByCode(rawTitle.charAt(i + 1)); - if (format != null && format.isColor()) + if (format != null) { return TextColor.fromLegacyFormat(format); } From 8af6dc5710ce75f2eb31419d6fb798bdd999fa67 Mon Sep 17 00:00:00 2001 From: Mat0u5 Date: Thu, 25 Jun 2026 14:26:10 +0200 Subject: [PATCH 3/6] 26.2 remaining --- .../iceberg/renderer/CheckedBufferSource.java | 11 ++++---- .../iceberg/renderer/VertexCollector.java | 5 ++-- .../iceberg/services/IBufferSource.java | 9 +++++++ .../anthonyhilyard/iceberg/util/Tooltips.java | 3 --- .../fabric/mixin/ClientLevelMixin.java | 8 +++--- .../fabric/mixin/GuiGraphicsMixin.java | 12 ++++----- .../services/FabricBufferSourceFactory.java | 25 +++++++++++-------- .../iceberg/forge/mixin/GuiGraphicsMixin.java | 6 ++--- .../neoforge/mixin/GuiGraphicsMixin.java | 6 ++--- .../services/NeoForgeBufferSourceFactory.java | 20 +++++++++------ 10 files changed, 59 insertions(+), 46 deletions(-) create mode 100644 common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java index 1cd9984..6420b65 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java @@ -1,5 +1,6 @@ package com.anthonyhilyard.iceberg.renderer; +import com.anthonyhilyard.iceberg.services.IBufferSource; import net.minecraft.client.renderer.rendertype.RenderType; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -7,21 +8,19 @@ import com.anthonyhilyard.iceberg.services.Services; import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.renderer.MultiBufferSource; - -public class CheckedBufferSource implements MultiBufferSource +public class CheckedBufferSource implements IBufferSource { protected boolean hasRendered = false; - protected final MultiBufferSource bufferSource; + protected final IBufferSource bufferSource; private static Boolean useSodiumVersion = null; - protected CheckedBufferSource(MultiBufferSource bufferSource) + protected CheckedBufferSource(IBufferSource bufferSource) { this.bufferSource = bufferSource; } - public static CheckedBufferSource create(MultiBufferSource bufferSource) + public static CheckedBufferSource create(IBufferSource bufferSource) { if (useSodiumVersion == null) { diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java index 28b1155..9c0e1c5 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java @@ -2,6 +2,7 @@ import java.util.Set; +import com.anthonyhilyard.iceberg.services.IBufferSource; import net.minecraft.client.renderer.rendertype.RenderType; import org.apache.commons.lang3.exception.ExceptionUtils; import org.joml.Vector3f; @@ -11,9 +12,7 @@ import com.google.common.collect.Sets; import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.renderer.MultiBufferSource; - -public class VertexCollector implements MultiBufferSource +public class VertexCollector implements IBufferSource { protected final Set vertices = Sets.newHashSet(); protected final Vector3f currentVertex = new Vector3f(); diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java b/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java new file mode 100644 index 0000000..dca401b --- /dev/null +++ b/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java @@ -0,0 +1,9 @@ +package com.anthonyhilyard.iceberg.services; + +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.renderer.rendertype.RenderType; + +public interface IBufferSource +{ + VertexConsumer getBuffer(RenderType renderType); +} diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/common/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java index bc44d97..205c34f 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java @@ -18,7 +18,6 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.screens.inventory.tooltip.*; -import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.Rect2i; import net.minecraft.client.renderer.item.ItemModelResolver; import net.minecraft.core.component.DataComponents; @@ -244,7 +243,6 @@ public static void renderItemTooltip(@NotNull final ItemStack stack, TooltipInfo Tooltips.gradientBackground = false; Tooltips.gradientBorder = false; - MultiBufferSource.BufferSource bufferSource = Minecraft.getInstance().renderBuffers().bufferSource(); graphics.nextStratum(); int tooltipTop = rectY; @@ -265,7 +263,6 @@ public static void renderItemTooltip(@NotNull final ItemStack stack, TooltipInfo } } - bufferSource.endBatch(); graphics.nextStratum(); tooltipTop = rectY; diff --git a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/ClientLevelMixin.java b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/ClientLevelMixin.java index 45f4d4a..fd9b0e0 100644 --- a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/ClientLevelMixin.java +++ b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/ClientLevelMixin.java @@ -1,5 +1,6 @@ package com.anthonyhilyard.iceberg.fabric.mixin; +import net.minecraft.client.renderer.extract.LevelExtractor; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -10,18 +11,15 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel.ClientLevelData; import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.core.Holder; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.dimension.DimensionType; @Mixin(ClientLevel.class) public class ClientLevelMixin { - @Inject(method = "(Lnet/minecraft/client/multiplayer/ClientPacketListener;Lnet/minecraft/client/multiplayer/ClientLevel$ClientLevelData;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/Holder;IILnet/minecraft/client/renderer/LevelRenderer;ZJI)V", + @Inject(method = "", at = @At("TAIL")) - private void levelLoadOnInit(ClientPacketListener clientPacketListener, ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, LevelRenderer levelRenderer, boolean bl, long l, int k, CallbackInfo info) + private void levelLoadOnInit(ClientPacketListener connection, ClientLevelData levelData, ResourceKey dimension, Holder dimensionType, int serverChunkRadius, int serverSimulationDistance, LevelExtractor levelExtractor, boolean isDebug, long biomeZoomSeed, int seaLevel, CallbackInfo ci) { LevelEvents.LOAD.invoker().onLoad((ClientLevel)(Object)this); } diff --git a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/GuiGraphicsMixin.java b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/GuiGraphicsMixin.java index c7cdee7..8d09f2a 100644 --- a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/GuiGraphicsMixin.java +++ b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/mixin/GuiGraphicsMixin.java @@ -77,7 +77,7 @@ public void clearTooltipStack(Font font, Component component, int x, int y, Call @Inject(method = "setTooltipForNextFrameInternal", at = @At("HEAD")) public void modifyGatheredComponents(Font font, List components, int x, int y, ClientTooltipPositioner positioner, Identifier resource, boolean bl, CallbackInfo info) { - Screen currentScreen = minecraft.screen; + Screen currentScreen = minecraft.gui.screen(); if (currentScreen instanceof AbstractContainerScreen containerScreen && ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot() != null) { if (icebergTooltipStack.isEmpty()) icebergTooltipStack = ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot().getItem(); @@ -100,7 +100,7 @@ private void preRenderTooltip(Font font, List components } else if (this.renderTooltipDepth == 1) { - if (minecraft.screen instanceof AbstractContainerScreen containerScreen && ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot() != null) + if (minecraft.gui.screen() instanceof AbstractContainerScreen containerScreen && ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot() != null) { containerStack = ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot().getItem(); } @@ -110,10 +110,10 @@ else if (this.renderTooltipDepth == 1) int width = minecraft.getWindow().getGuiScaledWidth(); int height = minecraft.getWindow().getGuiScaledHeight(); - if (minecraft.screen != null) + if (minecraft.gui.screen() != null) { - width = minecraft.screen.width; - height = minecraft.screen.height; + width = minecraft.gui.screen().width; + height = minecraft.gui.screen().height; } if (!containerStack.isEmpty()) @@ -185,7 +185,7 @@ private void postRenderTooltip(Font font, List component { containerStack = nestedTooltipStack; } - else if (this.renderTooltipDepth == 1 && minecraft.screen instanceof AbstractContainerScreen containerScreen && ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot() != null) + else if (this.renderTooltipDepth == 1 && minecraft.gui.screen() instanceof AbstractContainerScreen containerScreen && ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot() != null) { containerStack = ((AbstractContainerScreenAccessor)containerScreen).getHoveredSlot().getItem(); } diff --git a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java index 06a3724..8d69421 100644 --- a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java +++ b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java @@ -1,5 +1,8 @@ package com.anthonyhilyard.iceberg.fabric.services; +import com.anthonyhilyard.iceberg.services.IBufferSource; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraft.client.renderer.rendertype.RenderType; import org.joml.Vector3f; import org.lwjgl.system.MemoryStack; @@ -10,19 +13,16 @@ import com.anthonyhilyard.iceberg.util.UnsafeUtil; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.blaze3d.vertex.VertexFormatElement; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.renderer.MultiBufferSource; - public class FabricBufferSourceFactory implements IBufferSourceFactory { @Override public CheckedBufferSource createCheckedBufferSource(Object bufferSource) { - return new CheckedBufferSource((MultiBufferSource)bufferSource) { + return new CheckedBufferSource((IBufferSource)bufferSource) { @Override public VertexConsumer getBuffer(RenderType renderType) @@ -126,15 +126,21 @@ public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat { // Loop over each vertex, and add it to the list if it's opaque. // To determine this, we need to check the vertex format to find the vertex position and alpha. + VertexFormatElement posElement = format.getElement(DefaultVertexFormat.POSITION_SEMANTIC_NAME); + VertexFormatElement colorElement = format.getElement(DefaultVertexFormat.COLOR_SEMANTIC_NAME); + if (posElement == null || colorElement == null) + { + return; + } for (int i = 0; i < count; i++) { // Get the vertex position. - float x = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.POSITION)); - float y = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.POSITION) + 4); - float z = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.POSITION) + 8); + float x = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset()); + float y = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 4); + float z = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 8); // Get the vertex alpha. - int a = UnsafeUtil.readByte(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.COLOR) + 3) & 0xFF; + int a = UnsafeUtil.readByte(pointer + i * format.getVertexSize() + colorElement.offset() + 3) & 0xFF; // Add the vertex to the list if it's opaque. if (a >= 25) @@ -147,5 +153,4 @@ public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat } }; } - -} +} \ No newline at end of file diff --git a/forge/src/main/java/com/anthonyhilyard/iceberg/forge/mixin/GuiGraphicsMixin.java b/forge/src/main/java/com/anthonyhilyard/iceberg/forge/mixin/GuiGraphicsMixin.java index 534cbdc..d118a01 100644 --- a/forge/src/main/java/com/anthonyhilyard/iceberg/forge/mixin/GuiGraphicsMixin.java +++ b/forge/src/main/java/com/anthonyhilyard/iceberg/forge/mixin/GuiGraphicsMixin.java @@ -46,10 +46,10 @@ private void preRenderTooltipForge(Font font, List compo int width = minecraft.getWindow().getGuiScaledWidth(); int height = minecraft.getWindow().getGuiScaledHeight(); - if (minecraft.screen != null) + if (minecraft.gui.screen() != null) { - width = minecraft.screen.width; - height = minecraft.screen.height; + width = minecraft.gui.screen().width; + height = minecraft.gui.screen().height; } if (itemStack != null && itemStack.isEmpty()) diff --git a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/mixin/GuiGraphicsMixin.java b/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/mixin/GuiGraphicsMixin.java index c54a099..a11f184 100644 --- a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/mixin/GuiGraphicsMixin.java +++ b/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/mixin/GuiGraphicsMixin.java @@ -48,10 +48,10 @@ private void preRenderTooltipForge(Font font, List compo int width = minecraft.getWindow().getGuiScaledWidth(); int height = minecraft.getWindow().getGuiScaledHeight(); - if (minecraft.screen != null) + if (minecraft.gui.screen() != null) { - width = minecraft.screen.width; - height = minecraft.screen.height; + width = minecraft.gui.screen().width; + height = minecraft.gui.screen().height; } if (itemStack != null && itemStack.isEmpty()) diff --git a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java b/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java index 884c10f..5aad91d 100644 --- a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java +++ b/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java @@ -1,5 +1,7 @@ package com.anthonyhilyard.iceberg.neoforge.services; +import com.anthonyhilyard.iceberg.services.IBufferSource; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.minecraft.client.renderer.rendertype.RenderType; import org.joml.Vector3f; import org.lwjgl.system.MemoryStack; @@ -14,15 +16,13 @@ import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.renderer.MultiBufferSource; - public class NeoForgeBufferSourceFactory implements IBufferSourceFactory { @Override public CheckedBufferSource createCheckedBufferSource(Object bufferSource) { - return new CheckedBufferSource((MultiBufferSource)bufferSource) { + return new CheckedBufferSource((IBufferSource)bufferSource) { @Override public VertexConsumer getBuffer(RenderType renderType) @@ -126,15 +126,21 @@ public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat { // Loop over each vertex, and add it to the list if it's opaque. // To determine this, we need to check the vertex format to find the vertex position and alpha. + VertexFormatElement posElement = format.getElement(DefaultVertexFormat.POSITION_SEMANTIC_NAME); + VertexFormatElement colorElement = format.getElement(DefaultVertexFormat.COLOR_SEMANTIC_NAME); + if (posElement == null || colorElement == null) + { + return; + } for (int i = 0; i < count; i++) { // Get the vertex position. - float x = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.POSITION)); - float y = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.POSITION) + 4); - float z = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.POSITION) + 8); + float x = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset()); + float y = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 4); + float z = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 8); // Get the vertex alpha. - int a = UnsafeUtil.readByte(pointer + i * format.getVertexSize() + format.getOffset(VertexFormatElement.COLOR) + 3) & 0xFF; + int a = UnsafeUtil.readByte(pointer + i * format.getVertexSize() + colorElement.offset() + 3) & 0xFF; // Add the vertex to the list if it's opaque. if (a >= 25) From ce3b67840abc70bd84a242f8acfedab1a601e294 Mon Sep 17 00:00:00 2001 From: Mat0u5 Date: Sat, 27 Jun 2026 13:08:06 +0200 Subject: [PATCH 4/6] Fixed CustomItemRenderer --- .../iceberg/renderer/CustomItemRenderer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java index 97ba2d4..15117a6 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java @@ -60,6 +60,7 @@ public class CustomItemRenderer private final Minecraft minecraft; private RenderTarget renderTarget; private final ProjectionMatrixBuffer projectionMatrixBuffer; + private final Projection projection = new Projection(); private final SubmitNodeStorage submitNodeStorage = new SubmitNodeStorage(); private boolean isClosed = false; @@ -130,7 +131,7 @@ private void drawAndBlit(GuiGraphicsExtractor graphics, ItemStack stack, int x, () -> "Item", // 0x00000000 is a transparent black (outline). renderTarget.getColorTextureView(), Optional.of(new Vector4f(0, 0, 0, 0)), - renderTarget.getDepthTextureView(), OptionalDouble.of(1.0) + renderTarget.getDepthTextureView(), OptionalDouble.of(0.0) )) {} RenderSystem.outputColorTextureOverride = renderTarget.getColorTextureView(); @@ -141,9 +142,9 @@ private void drawAndBlit(GuiGraphicsExtractor graphics, ItemStack stack, int x, modelViewStack.pushMatrix(); modelViewStack.identity(); - Matrix4f ortho = new Matrix4f().setOrtho(0f, 16f, 16f, 0f, -1000f, 1000f); + this.projection.setupOrtho(-1000.0f, 1000.0f, 16, 16, true); RenderSystem.setProjectionMatrix( - this.projectionMatrixBuffer.getBuffer(ortho), + this.projectionMatrixBuffer.getBuffer(this.projection), ProjectionType.ORTHOGRAPHIC ); @@ -455,6 +456,7 @@ private boolean updateArmorStand(ItemStack itemStack) if (armorStand != null) { armorStand.setInvisible(true); + armorStand.setId(1); } } @@ -484,6 +486,7 @@ private boolean updateHorseArmor(ItemStack horseArmorItem) if (horse != null) { horse.setInvisible(true); + horse.setId(1); } } @@ -509,6 +512,7 @@ private boolean updateWolfArmor(ItemStack wolfArmorItem) if (wolf != null) { wolf.setInvisible(true); + wolf.setId(1); } } From 7e18b018f56b9981501602fd20c7e9e18fb878cb Mon Sep 17 00:00:00 2001 From: Mat0u5 Date: Sat, 27 Jun 2026 15:01:25 +0200 Subject: [PATCH 5/6] Fixed merge issues --- .../com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java index 2e82353..15117a6 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java @@ -258,7 +258,6 @@ private boolean tryEntityRenderers(ItemStack stack, PoseStack poseStack, Quatern poseStack.mulPose(Axis.YP.rotationDegrees(225.0f)); BlockState blockState = blockItem.getBlock().defaultBlockState(); - SubmitNodeStorage submitNodeStorage = minecraft.gameRenderer.getSubmitNodeStorage(); if (blockState.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF)) { From cfad78caba2c4ba0b152f2cdb194d62b3eee6269 Mon Sep 17 00:00:00 2001 From: Mat0u5 Date: Tue, 30 Jun 2026 21:01:49 +0200 Subject: [PATCH 6/6] Removed unused BufferSource related things. --- .../iceberg/renderer/CheckedBufferSource.java | 105 ------------ .../iceberg/renderer/VertexCollector.java | 113 ------------- .../iceberg/services/IBufferSource.java | 9 - .../services/IBufferSourceFactory.java | 11 -- .../iceberg/services/Services.java | 1 - fabric/build.gradle | 2 - .../services/FabricBufferSourceFactory.java | 156 ----------------- .../fabric/services/VertexConsumerSodium.java | 9 - ...yard.iceberg.services.IBufferSourceFactory | 1 - fabric/src/main/resources/fabric.mod.json | 1 - .../services/ForgeBufferSourceFactory.java | 21 --- ...yard.iceberg.services.IBufferSourceFactory | 1 - neoforge/build.gradle | 3 - .../services/NeoForgeBufferSourceFactory.java | 157 ------------------ .../services/VertexConsumerSodium.java | 9 - ...yard.iceberg.services.IBufferSourceFactory | 1 - 16 files changed, 600 deletions(-) delete mode 100644 common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java delete mode 100644 common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java delete mode 100644 common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java delete mode 100644 common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSourceFactory.java delete mode 100644 fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java delete mode 100644 fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/VertexConsumerSodium.java delete mode 100644 fabric/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory delete mode 100644 forge/src/main/java/com/anthonyhilyard/iceberg/forge/services/ForgeBufferSourceFactory.java delete mode 100644 forge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory delete mode 100644 neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java delete mode 100644 neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/VertexConsumerSodium.java delete mode 100644 neoforge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java deleted file mode 100644 index 6420b65..0000000 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/CheckedBufferSource.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.anthonyhilyard.iceberg.renderer; - -import com.anthonyhilyard.iceberg.services.IBufferSource; -import net.minecraft.client.renderer.rendertype.RenderType; -import org.apache.commons.lang3.exception.ExceptionUtils; - -import com.anthonyhilyard.iceberg.Iceberg; -import com.anthonyhilyard.iceberg.services.Services; -import com.mojang.blaze3d.vertex.VertexConsumer; - -public class CheckedBufferSource implements IBufferSource -{ - protected boolean hasRendered = false; - protected final IBufferSource bufferSource; - - private static Boolean useSodiumVersion = null; - - protected CheckedBufferSource(IBufferSource bufferSource) - { - this.bufferSource = bufferSource; - } - - public static CheckedBufferSource create(IBufferSource bufferSource) - { - if (useSodiumVersion == null) - { - try - { - if (Services.getPlatformHelper().getPlatformName().contentEquals("Fabric") || - Services.getPlatformHelper().getPlatformName().contentEquals("NeoForge")) - { - // If Sodium 0.6.0+ is installed on Fabric or NeoForge, use the Sodium implementation. - useSodiumVersion = Services.getPlatformHelper().isModLoaded("sodium") && Services.getPlatformHelper().modVersionMeets("sodium", "0.6.0"); - } - } - catch (Exception e) - { - Iceberg.LOGGER.error(ExceptionUtils.getStackTrace(e)); - } - } - - if (useSodiumVersion != null && useSodiumVersion) - { - // Instantiate the Sodium implementation using our factory service. - try - { - return Services.getBufferSourceFactory().createCheckedBufferSource(bufferSource); - } - catch (Exception e) - { - Iceberg.LOGGER.error(ExceptionUtils.getStackTrace(e)); - } - } - - return new CheckedBufferSource(bufferSource); - } - - @Override - public VertexConsumer getBuffer(RenderType renderType) - { - final VertexConsumer vertexConsumer = bufferSource.getBuffer(renderType); - VertexConsumer vertexConsumerWrap = new VertexConsumer() - { - @Override - public VertexConsumer addVertex(float x, float y, float z) - { - hasRendered = true; - return vertexConsumer.addVertex(x, y, z); - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) { return vertexConsumer.setColor(r, g, b, a); } - - @Override - public VertexConsumer setColor(int i) { return vertexConsumer.setColor(i); } - - @Override - public VertexConsumer setUv(float u, float v) { return vertexConsumer.setUv(u, v); } - - @Override - public VertexConsumer setUv1(int u, int v) { return vertexConsumer.setUv1(u, v); } - - @Override - public VertexConsumer setUv2(int u, int v) { return vertexConsumer.setUv2(u, v); } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { return vertexConsumer.setNormal(x, y, z); } - - @Override - public VertexConsumer setLineWidth(float f) { return vertexConsumer.setLineWidth(f); } - }; - - return vertexConsumerWrap; - } - - public boolean hasRendered() - { - return hasRendered; - } - - public void reset() - { - hasRendered = false; - } -} diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java b/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java deleted file mode 100644 index 9c0e1c5..0000000 --- a/common/src/main/java/com/anthonyhilyard/iceberg/renderer/VertexCollector.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.anthonyhilyard.iceberg.renderer; - -import java.util.Set; - -import com.anthonyhilyard.iceberg.services.IBufferSource; -import net.minecraft.client.renderer.rendertype.RenderType; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.joml.Vector3f; - -import com.anthonyhilyard.iceberg.Iceberg; -import com.anthonyhilyard.iceberg.services.Services; -import com.google.common.collect.Sets; -import com.mojang.blaze3d.vertex.VertexConsumer; - -public class VertexCollector implements IBufferSource -{ - protected final Set vertices = Sets.newHashSet(); - protected final Vector3f currentVertex = new Vector3f(); - protected int currentAlpha = 255; - - private static Boolean useSodiumVersion = null; - - protected VertexCollector() - { - super(); - } - - public static VertexCollector create() - { - if (useSodiumVersion == null) - { - try - { - if (Services.getPlatformHelper().getPlatformName().contentEquals("Fabric") || - Services.getPlatformHelper().getPlatformName().contentEquals("NeoForge")) - { - // If Sodium 0.6.0+ is installed on Fabric or NeoForge, use the Sodium implementation. - useSodiumVersion = Services.getPlatformHelper().isModLoaded("sodium") && Services.getPlatformHelper().modVersionMeets("sodium", "0.6.0"); - } - } - catch (Exception e) - { - Iceberg.LOGGER.error(ExceptionUtils.getStackTrace(e)); - } - } - - if (useSodiumVersion != null && useSodiumVersion) - { - // Instantiate the Sodium implementation using our factory service. - try - { - return Services.getBufferSourceFactory().createVertexCollector(); - } - catch (Exception e) - { - Iceberg.LOGGER.error(ExceptionUtils.getStackTrace(e)); - } - } - return new VertexCollector(); - } - - @Override - public VertexConsumer getBuffer(RenderType renderType) - { - return new VertexConsumer() - { - @Override - public VertexConsumer addVertex(float x, float y, float z) - { - if (currentAlpha >= 25) - { - vertices.add(new Vector3f(currentVertex.set(x, y, z))); - } - currentAlpha = 255; - return this; - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) - { - currentAlpha = a; - return this; - } - - @Override - public VertexConsumer setColor(int i) - { - currentAlpha = (i >> 24) & 0xFF; - return this; - } - - @Override - public VertexConsumer setUv(float u, float v) { return this; } - - @Override - public VertexConsumer setUv1(int u, int v) { return this; } - - @Override - public VertexConsumer setUv2(int u, int v) { return this; } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { return this; } - - @Override - public VertexConsumer setLineWidth(float f) { return this; } - }; - } - - public Set getVertices() - { - return vertices; - } -} \ No newline at end of file diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java b/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java deleted file mode 100644 index dca401b..0000000 --- a/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSource.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.anthonyhilyard.iceberg.services; - -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.renderer.rendertype.RenderType; - -public interface IBufferSource -{ - VertexConsumer getBuffer(RenderType renderType); -} diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSourceFactory.java b/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSourceFactory.java deleted file mode 100644 index 518a704..0000000 --- a/common/src/main/java/com/anthonyhilyard/iceberg/services/IBufferSourceFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.anthonyhilyard.iceberg.services; - -import com.anthonyhilyard.iceberg.renderer.CheckedBufferSource; -import com.anthonyhilyard.iceberg.renderer.VertexCollector; - -public interface IBufferSourceFactory -{ - CheckedBufferSource createCheckedBufferSource(Object bufferSource); - - VertexCollector createVertexCollector(); -} diff --git a/common/src/main/java/com/anthonyhilyard/iceberg/services/Services.java b/common/src/main/java/com/anthonyhilyard/iceberg/services/Services.java index ab2c338..350b97e 100644 --- a/common/src/main/java/com/anthonyhilyard/iceberg/services/Services.java +++ b/common/src/main/java/com/anthonyhilyard/iceberg/services/Services.java @@ -11,7 +11,6 @@ public class Services protected static final ConcurrentHashMap, Supplier> serviceCache = new ConcurrentHashMap<>(); public static IPlatformHelper getPlatformHelper() { return (IPlatformHelper) serviceCache.computeIfAbsent(IPlatformHelper.class, x -> createLazySupplier(x)).get(); } - public static IBufferSourceFactory getBufferSourceFactory() { return (IBufferSourceFactory) serviceCache.computeIfAbsent(IBufferSourceFactory.class, x -> createLazySupplier(x)).get(); } public static IIcebergConfigSpecBuilder getConfigSpecBuilder() { return (IIcebergConfigSpecBuilder) serviceCache.computeIfAbsent(IIcebergConfigSpecBuilder.class, x -> createLazySupplier(x)).get(); } public static IKeyMappingRegistrar getKeyMappingRegistrar() { return (IKeyMappingRegistrar) serviceCache.computeIfAbsent(IKeyMappingRegistrar.class, x -> createLazySupplier(x)).get(); } public static IReloadListenerRegistrar getReloadListenerRegistrar() { return (IReloadListenerRegistrar) serviceCache.computeIfAbsent(IReloadListenerRegistrar.class, x -> createLazySupplier(x)).get(); } diff --git a/fabric/build.gradle b/fabric/build.gradle index f0970a2..d1023ba 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -37,8 +37,6 @@ dependencies { implementation "com.electronwill.night-config:core:${project.nightconfigVersion}" implementation "com.electronwill.night-config:toml:${project.nightconfigVersion}" - implementation files("../libs/sodium-fabric-0.9.0+mc26.2.jar") - common(project(path: ":common")) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionFabric') } diff --git a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java deleted file mode 100644 index 8d69421..0000000 --- a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/FabricBufferSourceFactory.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.anthonyhilyard.iceberg.fabric.services; - -import com.anthonyhilyard.iceberg.services.IBufferSource; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormatElement; -import net.minecraft.client.renderer.rendertype.RenderType; -import org.joml.Vector3f; -import org.lwjgl.system.MemoryStack; - -import com.anthonyhilyard.iceberg.renderer.CheckedBufferSource; -import com.anthonyhilyard.iceberg.renderer.VertexCollector; -import com.anthonyhilyard.iceberg.services.IBufferSourceFactory; -import com.anthonyhilyard.iceberg.util.UnsafeUtil; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormat; - -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; - -public class FabricBufferSourceFactory implements IBufferSourceFactory -{ - - @Override - public CheckedBufferSource createCheckedBufferSource(Object bufferSource) - { - return new CheckedBufferSource((IBufferSource)bufferSource) { - - @Override - public VertexConsumer getBuffer(RenderType renderType) - { - final VertexConsumer vertexConsumer = bufferSource.getBuffer(renderType); - VertexConsumer vertexConsumerWrap = new VertexConsumerSodium() - { - @Override - public VertexConsumer addVertex(float x, float y, float z) - { - hasRendered = true; - return vertexConsumer.addVertex(x, y, z); - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) { return vertexConsumer.setColor(r, g, b, a); } - - @Override - public VertexConsumer setColor(int i) { return vertexConsumer.setColor(i); } - - @Override - public VertexConsumer setUv(float u, float v) { return vertexConsumer.setUv(u, v); } - - @Override - public VertexConsumer setUv1(int u, int v) { return vertexConsumer.setUv1(u, v); } - - @Override - public VertexConsumer setUv2(int u, int v) { return vertexConsumer.setUv2(u, v); } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { return vertexConsumer.setNormal(x, y, z); } - - @Override - public VertexConsumer setLineWidth(float f) { return vertexConsumer.setLineWidth(f); } - - @Override - public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat format) - { - hasRendered = true; - ((VertexBufferWriter)vertexConsumer).push(memoryStack, pointer, count, format); - } - }; - - return vertexConsumerWrap; - } - }; - } - - @Override - public VertexCollector createVertexCollector() - { - return new VertexCollector() { - - @Override - public VertexConsumer getBuffer(RenderType renderType) - { - return new VertexConsumerSodium() - { - @Override - public VertexConsumer addVertex(float x, float y, float z) - { - if (currentAlpha >= 25) - { - vertices.add(new Vector3f(currentVertex.set(x, y, z))); - } - currentAlpha = 255; - return this; - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) - { - currentAlpha = a; - return this; - } - - @Override - public VertexConsumer setColor(int i) - { - currentAlpha = (i >> 24) & 0xFF; - return this; - } - - @Override - public VertexConsumer setUv(float u, float v) { return this; } - - @Override - public VertexConsumer setUv1(int u, int v) { return this; } - - @Override - public VertexConsumer setUv2(int u, int v) { return this; } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { return this; } - - @Override - public VertexConsumer setLineWidth(float f) { return this; } - - @Override - public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat format) - { - // Loop over each vertex, and add it to the list if it's opaque. - // To determine this, we need to check the vertex format to find the vertex position and alpha. - VertexFormatElement posElement = format.getElement(DefaultVertexFormat.POSITION_SEMANTIC_NAME); - VertexFormatElement colorElement = format.getElement(DefaultVertexFormat.COLOR_SEMANTIC_NAME); - if (posElement == null || colorElement == null) - { - return; - } - for (int i = 0; i < count; i++) - { - // Get the vertex position. - float x = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset()); - float y = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 4); - float z = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 8); - - // Get the vertex alpha. - int a = UnsafeUtil.readByte(pointer + i * format.getVertexSize() + colorElement.offset() + 3) & 0xFF; - - // Add the vertex to the list if it's opaque. - if (a >= 25) - { - vertices.add(new Vector3f(x, y, z)); - } - } - } - }; - } - }; - } -} \ No newline at end of file diff --git a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/VertexConsumerSodium.java b/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/VertexConsumerSodium.java deleted file mode 100644 index 2603d5e..0000000 --- a/fabric/src/main/java/com/anthonyhilyard/iceberg/fabric/services/VertexConsumerSodium.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.anthonyhilyard.iceberg.fabric.services; - -import com.mojang.blaze3d.vertex.VertexConsumer; - -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; - -public interface VertexConsumerSodium extends VertexConsumer, VertexBufferWriter -{ -} diff --git a/fabric/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory b/fabric/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory deleted file mode 100644 index 8b24bf2..0000000 --- a/fabric/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory +++ /dev/null @@ -1 +0,0 @@ -com.anthonyhilyard.iceberg.fabric.services.FabricBufferSourceFactory \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 65d56d2..aaffdb9 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -39,7 +39,6 @@ "java": ">=25" }, "suggests": { - "sodium": ">=0.6.0", "prism": ">=1.1.2" }, "custom": { diff --git a/forge/src/main/java/com/anthonyhilyard/iceberg/forge/services/ForgeBufferSourceFactory.java b/forge/src/main/java/com/anthonyhilyard/iceberg/forge/services/ForgeBufferSourceFactory.java deleted file mode 100644 index c09e14b..0000000 --- a/forge/src/main/java/com/anthonyhilyard/iceberg/forge/services/ForgeBufferSourceFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.anthonyhilyard.iceberg.forge.services; - -import com.anthonyhilyard.iceberg.renderer.CheckedBufferSource; -import com.anthonyhilyard.iceberg.renderer.VertexCollector; -import com.anthonyhilyard.iceberg.services.IBufferSourceFactory; - -public class ForgeBufferSourceFactory implements IBufferSourceFactory -{ - @Override - public CheckedBufferSource createCheckedBufferSource(Object bufferSource) - { - throw new UnsupportedOperationException("This version of Iceberg is incompatible with Rubidium/Embeddium."); - } - - @Override - public VertexCollector createVertexCollector() - { - throw new UnsupportedOperationException("This version of Iceberg is incompatible with Rubidium/Embeddium."); - } - -} diff --git a/forge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory b/forge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory deleted file mode 100644 index 9466dde..0000000 --- a/forge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory +++ /dev/null @@ -1 +0,0 @@ -com.anthonyhilyard.iceberg.forge.services.ForgeBufferSourceFactory \ No newline at end of file diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 2ce1e63..43e2f20 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -33,9 +33,6 @@ repositories { dependencies { neoForge "net.neoforged:neoforge:$rootProject.neoforgeVersion" - // For some reason sodium for neoforge bundles its main logic so we have to do compile only for the fabric version, to prevent errors. - compileOnly files("../libs/sodium-fabric-0.9.0+mc26.2.jar") - runtimeOnly files("../libs/sodium-neoforge-0.9.0+mc26.2.jar") implementation "net.bytebuddy:byte-buddy:1.14.18" common(project(path: ":common")) { transitive false } diff --git a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java b/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java deleted file mode 100644 index 5aad91d..0000000 --- a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/NeoForgeBufferSourceFactory.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.anthonyhilyard.iceberg.neoforge.services; - -import com.anthonyhilyard.iceberg.services.IBufferSource; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import net.minecraft.client.renderer.rendertype.RenderType; -import org.joml.Vector3f; -import org.lwjgl.system.MemoryStack; - -import com.anthonyhilyard.iceberg.renderer.CheckedBufferSource; -import com.anthonyhilyard.iceberg.renderer.VertexCollector; -import com.anthonyhilyard.iceberg.services.IBufferSourceFactory; -import com.anthonyhilyard.iceberg.util.UnsafeUtil; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.blaze3d.vertex.VertexFormatElement; - -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; - -public class NeoForgeBufferSourceFactory implements IBufferSourceFactory -{ - - @Override - public CheckedBufferSource createCheckedBufferSource(Object bufferSource) - { - return new CheckedBufferSource((IBufferSource)bufferSource) { - - @Override - public VertexConsumer getBuffer(RenderType renderType) - { - final VertexConsumer vertexConsumer = bufferSource.getBuffer(renderType); - VertexConsumer vertexConsumerWrap = new VertexConsumerSodium() - { - @Override - public VertexConsumer addVertex(float x, float y, float z) - { - hasRendered = true; - return vertexConsumer.addVertex(x, y, z); - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) { return vertexConsumer.setColor(r, g, b, a); } - - @Override - public VertexConsumer setColor(int i) { return vertexConsumer.setColor(i); } - - @Override - public VertexConsumer setUv(float u, float v) { return vertexConsumer.setUv(u, v); } - - @Override - public VertexConsumer setUv1(int u, int v) { return vertexConsumer.setUv1(u, v); } - - @Override - public VertexConsumer setUv2(int u, int v) { return vertexConsumer.setUv2(u, v); } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { return vertexConsumer.setNormal(x, y, z); } - - @Override - public VertexConsumer setLineWidth(float f) { return vertexConsumer.setLineWidth(f); } - - @Override - public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat format) - { - hasRendered = true; - ((VertexBufferWriter)vertexConsumer).push(memoryStack, pointer, count, format); - } - }; - - return vertexConsumerWrap; - } - }; - } - - @Override - public VertexCollector createVertexCollector() - { - return new VertexCollector() { - - @Override - public VertexConsumer getBuffer(RenderType renderType) - { - return new VertexConsumerSodium() - { - @Override - public VertexConsumer addVertex(float x, float y, float z) - { - if (currentAlpha >= 25) - { - vertices.add(new Vector3f(currentVertex.set(x, y, z))); - } - currentAlpha = 255; - return this; - } - - @Override - public VertexConsumer setColor(int r, int g, int b, int a) - { - currentAlpha = a; - return this; - } - - @Override - public VertexConsumer setColor(int i) - { - currentAlpha = (i >> 24) & 0xFF; - return this; - } - - @Override - public VertexConsumer setUv(float u, float v) { return this; } - - @Override - public VertexConsumer setUv1(int u, int v) { return this; } - - @Override - public VertexConsumer setUv2(int u, int v) { return this; } - - @Override - public VertexConsumer setNormal(float x, float y, float z) { return this; } - - @Override - public VertexConsumer setLineWidth(float f) { return this; } - - @Override - public void push(MemoryStack memoryStack, long pointer, int count, VertexFormat format) - { - // Loop over each vertex, and add it to the list if it's opaque. - // To determine this, we need to check the vertex format to find the vertex position and alpha. - VertexFormatElement posElement = format.getElement(DefaultVertexFormat.POSITION_SEMANTIC_NAME); - VertexFormatElement colorElement = format.getElement(DefaultVertexFormat.COLOR_SEMANTIC_NAME); - if (posElement == null || colorElement == null) - { - return; - } - for (int i = 0; i < count; i++) - { - // Get the vertex position. - float x = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset()); - float y = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 4); - float z = UnsafeUtil.readFloat(pointer + i * format.getVertexSize() + posElement.offset() + 8); - - // Get the vertex alpha. - int a = UnsafeUtil.readByte(pointer + i * format.getVertexSize() + colorElement.offset() + 3) & 0xFF; - - // Add the vertex to the list if it's opaque. - if (a >= 25) - { - vertices.add(new Vector3f(x, y, z)); - } - } - } - }; - } - }; - } - -} diff --git a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/VertexConsumerSodium.java b/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/VertexConsumerSodium.java deleted file mode 100644 index 5a30df1..0000000 --- a/neoforge/src/main/java/com/anthonyhilyard/iceberg/neoforge/services/VertexConsumerSodium.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.anthonyhilyard.iceberg.neoforge.services; - -import com.mojang.blaze3d.vertex.VertexConsumer; - -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; - -public interface VertexConsumerSodium extends VertexConsumer, VertexBufferWriter -{ -} diff --git a/neoforge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory b/neoforge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory deleted file mode 100644 index 97deb22..0000000 --- a/neoforge/src/main/resources/META-INF/services/com.anthonyhilyard.iceberg.services.IBufferSourceFactory +++ /dev/null @@ -1 +0,0 @@ -com.anthonyhilyard.iceberg.neoforge.services.NeoForgeBufferSourceFactory \ No newline at end of file