diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java index d0c0fa6e9..2fc6de691 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java @@ -1,7 +1,5 @@ package com.jozufozu.flywheel.backend.instancing; -import javax.annotation.Nonnull; - import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.event.BeginFrameEvent; import com.jozufozu.flywheel.event.ReloadRenderersEvent; @@ -42,13 +40,11 @@ public class InstancedRenderDispatcher { getEntities(entity.level).queueUpdate(entity); } - @Nonnull public static InstanceManager getTiles(LevelAccessor world) { return instanceWorlds.get(world) .getTileEntityInstanceManager(); } - @Nonnull public static InstanceManager getEntities(LevelAccessor world) { return instanceWorlds.get(world) .getEntityInstanceManager(); diff --git a/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java index 847134b22..659f1bb0b 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java @@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; @Mixin(LevelRenderer.class) public class FixFabulousDepthMixin { - @Inject(method = "renderLevel", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;process(F)V")) + @Inject(method = "renderLevel", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/renderer/PostChain;process(F)V")) private void disableTransparencyShaderDepth(PoseStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, Camera p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { GlStateManager._depthMask(false); } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java index 228c37edc..f3d0b1a61 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java @@ -1,9 +1,5 @@ package com.jozufozu.flywheel.mixin; -import java.util.Set; - -import net.minecraft.world.level.block.entity.TickingBlockEntity; - import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -11,46 +7,28 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -@Mixin(value = Level.class, priority = 1100) // this and create.mixins.json have high priority to load after Performant +@Mixin(value = LevelChunk.class, priority = 1100) // this and create.mixins.json have high priority to load after Performant public class TileWorldHookMixin { - final Level self = (Level) (Object) this; - @Shadow @Final - public boolean isClientSide; + Level level; - @Shadow - @Final - protected Set f_46434_; // FIXME: is this correct? - - @Inject(at = @At("TAIL"), method = "addBlockEntityTicker(Lnet/minecraft/world/level/block/entity/TickingBlockEntity;)V") - private void onAddTile(TickingBlockEntity te, CallbackInfo ci) { - if (isClientSide) { - InstancedRenderDispatcher.getTiles(self) - .queueAdd((BlockEntity) te); - } - } - - /** - * Without this we don't unload instances when a chunk unloads. - */ - @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") - private void onChunkUnload(CallbackInfo ci) { - if (isClientSide) { - InstanceManager kineticRenderer = InstancedRenderDispatcher.getTiles(self); - for (BlockEntity tile : f_46434_) { - kineticRenderer.remove(tile); - } + @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/block/entity/BlockEntity;clearRemoved()V"), + method = "setBlockEntity") + private void onAddTile(BlockEntity te, CallbackInfo ci) { + if (level.isClientSide) { + InstancedRenderDispatcher.getTiles(level) + .queueAdd(te); } } }