net.silkmc.silk.persistence.mixin.chunk.LevelChunkMixin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of silk-persistence Show documentation
Show all versions of silk-persistence Show documentation
Silk is a Minecraft API for Kotlin
package net.silkmc.silk.persistence.mixin.chunk;
import net.minecraft.class_2818;
import net.minecraft.class_2839;
import net.minecraft.class_3218;
import net.silkmc.silk.persistence.CompoundProvider;
import net.silkmc.silk.persistence.PersistentCompound;
import net.silkmc.silk.persistence.PersistentCompoundImpl;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(class_2818.class)
public class LevelChunkMixin implements CompoundProvider {
@Unique
private PersistentCompound compound = new PersistentCompoundImpl();
// this targets the constructor which creates a WorldChunk from a ProtoChunk
@Inject(
method = "(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;)V",
at = @At("RETURN")
)
private void initFromProtoChunk(class_3218 serverLevel,
class_2839 protoChunk,
class_2818.class_6829 postLoadProcessor,
CallbackInfo ci) {
compound = ((CompoundProvider) protoChunk).getCompound();
}
@NotNull
@Override
public PersistentCompound getCompound() {
return compound;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy