2021-06-16 20:19:33 +02:00
|
|
|
package com.jozufozu.flywheel.mixin;
|
2021-03-30 23:14:58 +02:00
|
|
|
|
|
|
|
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;
|
2021-03-30 23:14:58 +02:00
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
import net.minecraft.world.level.Level;
|
2021-09-17 05:03:45 +02:00
|
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
2021-09-15 23:28:44 +02:00
|
|
|
import net.minecraft.world.level.chunk.LevelChunk;
|
2021-03-30 23:14:58 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-09-17 05:03:45 +02:00
|
|
|
@Mixin(LevelChunk.class)
|
|
|
|
public class InstanceAddMixin {
|
2021-03-30 23:14:58 +02:00
|
|
|
|
2021-04-08 19:22:11 +02:00
|
|
|
@Shadow
|
|
|
|
@Final
|
2021-09-15 23:28:44 +02:00
|
|
|
Level level;
|
|
|
|
|
2021-09-17 05:03:45 +02:00
|
|
|
@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);
|
2021-03-30 23:14:58 +02:00
|
|
|
}
|
|
|
|
}
|