mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-10 14:26:10 +01:00
eb8dc6bc07
- Combine InstanceFactories and FlywheelRendered into InstancingControllers - Store these controllers directly in the BlockEntity/Entity type instead of a map for efficiency - Redo InstancedRenderRegistry to fit these changes - Rename all tile to block entity - Remove all interface I prefixes - Organize imports - Bump version to 0.5.1
42 lines
1.3 KiB
Java
42 lines
1.3 KiB
Java
package com.jozufozu.flywheel.mixin;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
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;
|
|
|
|
import com.jozufozu.flywheel.backend.Backend;
|
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
|
|
|
import net.minecraft.client.multiplayer.ClientLevel;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
|
|
@Mixin(BlockEntity.class)
|
|
public class InstanceRemoveMixin {
|
|
|
|
@Shadow
|
|
@Nullable
|
|
protected Level level;
|
|
|
|
@Inject(at = @At("TAIL"), method = "setRemoved")
|
|
private void removeInstance(CallbackInfo ci) {
|
|
if (level instanceof ClientLevel && Backend.isOn()) {
|
|
InstancedRenderDispatcher.getBlockEntities(this.level)
|
|
.remove((BlockEntity) (Object) this);
|
|
}
|
|
}
|
|
|
|
// /**
|
|
// * Don't do this.
|
|
// * It can cause infinite loops if an instance class tries to access another block entity in its constructor.
|
|
// */
|
|
// @Inject(at = @At("TAIL"), method = "clearRemoved")
|
|
// private void addInstance(CallbackInfo ci) {
|
|
// if (level.isClientSide) InstancedRenderDispatcher.getBlockEntities(this.level)
|
|
// .add((BlockEntity) (Object) this);
|
|
// }
|
|
}
|