Add missing patch to structure data
This commit is contained in:
parent
3e29d3e24d
commit
0d02fdb5a4
@ -1,59 +1,25 @@
|
||||
package io.izzel.arclight.common.mixin.core.world.chunk.storage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.SharedConstants;
|
||||
import net.minecraft.util.datafix.DefaultTypeReferences;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.storage.ChunkLoader;
|
||||
import net.minecraft.world.gen.feature.structure.LegacyStructureDataUtil;
|
||||
import net.minecraft.world.storage.DimensionSavedDataManager;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(ChunkLoader.class)
|
||||
public abstract class ChunkLoaderMixin {
|
||||
|
||||
// @formatter:off
|
||||
@Shadow public static int getDataVersion(CompoundNBT compound) { return 0; }
|
||||
@Shadow @Final protected DataFixer dataFixer;
|
||||
@Shadow @Nullable private LegacyStructureDataUtil field_219167_a;
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
* @author IzzelAliz
|
||||
* @reason
|
||||
*/
|
||||
@Overwrite
|
||||
public CompoundNBT func_235968_a_(RegistryKey<?> p_235968_1_, Supplier<DimensionSavedDataManager> p_235968_2_, CompoundNBT nbt) {
|
||||
int i = getDataVersion(nbt);
|
||||
if (i < 1493) {
|
||||
nbt = NBTUtil.update(this.dataFixer, DefaultTypeReferences.CHUNK, nbt, i, 1493);
|
||||
if (nbt.getCompound("Level").getBoolean("hasLegacyStructureData")) {
|
||||
if (this.field_219167_a == null) {
|
||||
this.field_219167_a = legacyDataOf(p_235968_1_, p_235968_2_.get());
|
||||
}
|
||||
|
||||
nbt = this.field_219167_a.func_212181_a(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
nbt = NBTUtil.update(this.dataFixer, DefaultTypeReferences.CHUNK, nbt, Math.max(1493, i));
|
||||
if (i < SharedConstants.getVersion().getWorldVersion()) {
|
||||
nbt.putInt("DataVersion", SharedConstants.getVersion().getWorldVersion());
|
||||
}
|
||||
|
||||
return nbt;
|
||||
@Redirect(method = "func_235968_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/gen/feature/structure/LegacyStructureDataUtil;func_236992_a_(Lnet/minecraft/util/RegistryKey;Lnet/minecraft/world/storage/DimensionSavedDataManager;)Lnet/minecraft/world/gen/feature/structure/LegacyStructureDataUtil;"))
|
||||
private LegacyStructureDataUtil arclight$legacyData(RegistryKey<World> p_236992_0_, DimensionSavedDataManager p_236992_1_) {
|
||||
return legacyDataOf(p_236992_0_, p_236992_1_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user