diff --git a/gradle.properties b/gradle.properties index eb73e929..147d4045 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ loader_version=0.14.22 fabric_version=0.89.3+1.20.2 -mod_version = 0.9+1.20.2 +mod_version = 0.9.1+1.20.2 maven_group = foundationgames archives_base_name = enhancedblockentities diff --git a/src/main/java/foundationgames/enhancedblockentities/config/gui/screen/EBEConfigScreen.java b/src/main/java/foundationgames/enhancedblockentities/config/gui/screen/EBEConfigScreen.java index 4e9ee1ae..d813996f 100644 --- a/src/main/java/foundationgames/enhancedblockentities/config/gui/screen/EBEConfigScreen.java +++ b/src/main/java/foundationgames/enhancedblockentities/config/gui/screen/EBEConfigScreen.java @@ -86,6 +86,10 @@ protected void init() { public void renderBackgroundTexture(DrawContext context) { } + @Override + public void renderInGameBackground(DrawContext context) { + } + @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { if (this.client.world == null) { diff --git a/src/main/java/foundationgames/enhancedblockentities/mixin/WorldRendererMixin.java b/src/main/java/foundationgames/enhancedblockentities/mixin/WorldRendererMixin.java index 8cda2153..d64ce1e9 100644 --- a/src/main/java/foundationgames/enhancedblockentities/mixin/WorldRendererMixin.java +++ b/src/main/java/foundationgames/enhancedblockentities/mixin/WorldRendererMixin.java @@ -1,14 +1,34 @@ package foundationgames.enhancedblockentities.mixin; import foundationgames.enhancedblockentities.util.WorldUtil; +import net.minecraft.client.render.Camera; import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.chunk.ChunkBuilder; +import net.minecraft.client.render.chunk.ChunkRendererRegionBuilder; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.ChunkSectionPos; +import net.minecraft.world.chunk.light.LightingProvider; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(WorldRenderer.class) public class WorldRendererMixin { + private ChunkSectionPos enhanced_bes$updatingChunk = null; + + @ModifyVariable(method = "updateChunks", + at = @At(value = "INVOKE_ASSIGN", shift = At.Shift.AFTER, target = "Lnet/minecraft/util/math/ChunkSectionPos;from(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/ChunkSectionPos;"), + index = 8) + private ChunkSectionPos enhanced_bes$cacheUpdatedChunkPos(ChunkSectionPos c) { + enhanced_bes$updatingChunk = c; + return c; + } + /* X------------------------updateChunks(Camera camera)-------------------------X |---> HERE <--- | | if (bl) { | @@ -17,10 +37,14 @@ public class WorldRendererMixin { X----------------------------[END: 5 LINES DOWN]-----------------------------X */ @ModifyVariable(method = "updateChunks", at = @At(value = "JUMP", shift = At.Shift.BEFORE, opcode = Opcodes.IFEQ, ordinal = 4), index = 9) private boolean enhanced_bes$forceSynchronousChunkRebuild(boolean old) { - if (WorldUtil.FORCE_SYNCHRONOUS_CHUNK_REBUILD) { - WorldUtil.FORCE_SYNCHRONOUS_CHUNK_REBUILD = false; + if (enhanced_bes$updatingChunk != null && WorldUtil.FORCE_SYNCHRONOUS_CHUNK_REBUILD.contains(enhanced_bes$updatingChunk)) { + WorldUtil.FORCE_SYNCHRONOUS_CHUNK_REBUILD.remove(enhanced_bes$updatingChunk); + + enhanced_bes$updatingChunk = null; return true; } + + enhanced_bes$updatingChunk = null; return old; } } diff --git a/src/main/java/foundationgames/enhancedblockentities/util/WorldUtil.java b/src/main/java/foundationgames/enhancedblockentities/util/WorldUtil.java index 62485674..1163d412 100644 --- a/src/main/java/foundationgames/enhancedblockentities/util/WorldUtil.java +++ b/src/main/java/foundationgames/enhancedblockentities/util/WorldUtil.java @@ -3,15 +3,21 @@ import foundationgames.enhancedblockentities.EnhancedBlockEntities; import net.minecraft.client.MinecraftClient; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.world.World; +import java.util.HashSet; +import java.util.Set; + public enum WorldUtil {; - public static boolean FORCE_SYNCHRONOUS_CHUNK_REBUILD = false; + public static Set FORCE_SYNCHRONOUS_CHUNK_REBUILD = new HashSet<>(); public static void rebuildChunkSynchronously(World world, BlockPos pos, boolean forceSync) { var bState = world.getBlockState(pos); try { - WorldUtil.FORCE_SYNCHRONOUS_CHUNK_REBUILD = forceSync; + if (forceSync) { + WorldUtil.FORCE_SYNCHRONOUS_CHUNK_REBUILD.add(ChunkSectionPos.from(pos)); + } MinecraftClient.getInstance().worldRenderer.updateBlock(world, pos, bState, bState, 8); } catch (NullPointerException ignored) { EnhancedBlockEntities.LOG.warn("Error rebuilding chunk at block pos "+pos);