Fix Biome/BlockState Wrapper in 1.18 and 1.19
This commit is contained in:
+10
@@ -44,6 +44,11 @@ import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.resources.RegistryReadOps;
|
||||
import net.minecraft.resources.RegistryWriteOps;
|
||||
#elif MC_1_18_2
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
#else
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -110,6 +115,8 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
ResourceLocation resourceLocation;
|
||||
#if MC_1_16_5
|
||||
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome);
|
||||
#elif MC_1_18_2
|
||||
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value());
|
||||
#else
|
||||
resourceLocation = registryAccess.registryOrThrow(Registries.BIOME).getKey(this.biome.value());
|
||||
#endif
|
||||
@@ -150,6 +157,9 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
|
||||
#if MC_1_16_5
|
||||
Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
|
||||
#elif MC_1_18_2
|
||||
Biome unwrappedBiome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
|
||||
Holder<Biome> biome = new Holder.Direct<>(unwrappedBiome);
|
||||
#else
|
||||
Biome unwrappedBiome = registryAccess.registryOrThrow(Registries.BIOME).get(resourceLocation);
|
||||
Holder<Biome> biome = new Holder.Direct<>(unwrappedBiome);
|
||||
|
||||
+10
@@ -16,6 +16,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
#if MC_1_16_5
|
||||
import net.minecraft.core.Registry;
|
||||
#elif MC_1_18_2
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
#else
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -99,6 +103,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
ResourceLocation resourceLocation;
|
||||
#if MC_1_16_5
|
||||
resourceLocation = Registry.BLOCK.getKey(this.blockState.getBlock());
|
||||
#elif MC_1_18_2
|
||||
net.minecraft.core.RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess();
|
||||
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(this.blockState.getBlock());
|
||||
#else
|
||||
net.minecraft.core.RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess();
|
||||
resourceLocation = registryAccess.registryOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock());
|
||||
@@ -143,6 +150,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
Block block;
|
||||
#if MC_1_16_5
|
||||
block = Registry.BLOCK.get(resourceLocation);
|
||||
#elif MC_1_18_2
|
||||
net.minecraft.core.RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess();
|
||||
block = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).get(resourceLocation);
|
||||
#else
|
||||
net.minecraft.core.RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess();
|
||||
block = registryAccess.registryOrThrow(Registries.BLOCK).get(resourceLocation);
|
||||
|
||||
Reference in New Issue
Block a user