Flywheel/src/main/java/com/jozufozu/flywheel/mixin/InstanceAddMixin.java

33 lines
1.1 KiB
Java
Raw Normal View History

2021-06-16 20:19:33 +02:00
package com.jozufozu.flywheel.mixin;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2021-06-05 00:56:46 +02:00
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
@Mixin(LevelChunk.class)
public class InstanceAddMixin {
@Shadow
@Final
Level level;
@Inject(method = "setBlockEntity",
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
private void tileAdded(BlockEntity be, CallbackInfo ci) {
if (level.isClientSide) InstancedRenderDispatcher.getTiles(this.level)
.add(be);
}
}