All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.silkmc.silk.persistence.mixin.chunk.LevelChunkMixin Maven / Gradle / Ivy

There is a newer version: 1.10.7
Show newest version
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