working 1.21.1

This commit is contained in:
Zoe Gidiere
2024-09-17 17:40:56 -06:00
parent 664d1a3191
commit 15a298304e
15 changed files with 55 additions and 31 deletions

View File

@@ -29,7 +29,7 @@ object Versions {
} }
object Fabric { object Fabric {
const val fabricAPI = "0.97.8+${Mod.minecraft}" const val fabricAPI = "0.104.0+${Mod.minecraft}"
} }
// //
// object Quilt { // object Quilt {
@@ -40,8 +40,8 @@ object Versions {
object Mod { object Mod {
const val mixin = "0.15.3+mixin.0.8.7" const val mixin = "0.15.3+mixin.0.8.7"
const val minecraft = "1.20.6" const val minecraft = "1.21.1"
const val yarn = "$minecraft+build.1" const val yarn = "$minecraft+build.3"
const val fabricLoader = "0.16.5" const val fabricLoader = "0.16.5"
const val architecuryLoom = "1.7.413" const val architecuryLoom = "1.7.413"

View File

@@ -3,6 +3,7 @@ package com.dfsek.terra.mod;
import com.dfsek.tectonic.api.TypeRegistry; import com.dfsek.tectonic.api.TypeRegistry;
import com.dfsek.tectonic.api.depth.DepthTracker; import com.dfsek.tectonic.api.depth.DepthTracker;
import com.dfsek.tectonic.api.exception.LoadException; import com.dfsek.tectonic.api.exception.LoadException;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnGroup;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
@@ -116,6 +117,8 @@ public abstract class ModPlatform extends AbstractPlatform {
public abstract Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry(); public abstract Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry();
public abstract Registry<Enchantment> enchantmentRegistry();
@Override @Override
public @NotNull WorldHandle getWorldHandle() { public @NotNull WorldHandle getWorldHandle() {
return worldHandle; return worldHandle;
@@ -125,4 +128,6 @@ public abstract class ModPlatform extends AbstractPlatform {
public @NotNull ItemHandle getItemHandle() { public @NotNull ItemHandle getItemHandle() {
return itemHandle; return itemHandle;
} }
} }

View File

@@ -111,10 +111,9 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
return settings.value().generationShapeConfig().height(); return settings.value().generationShapeConfig().height();
} }
@Override @Override
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig, public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor,
StructureAccessor structureAccessor, Chunk chunk) { Chunk chunk) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld(); ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
BiomeProvider biomeProvider = pack.getBiomeProvider(); BiomeProvider biomeProvider = pack.getBiomeProvider();

View File

@@ -62,11 +62,11 @@ public class MinecraftItemHandle implements ItemHandle {
@Override @Override
public Enchantment getEnchantment(String id) { public Enchantment getEnchantment(String id) {
return (Enchantment) (Registries.ENCHANTMENT.get(Identifier.tryParse(id))); return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().get(Identifier.tryParse(id)));
} }
@Override @Override
public Set<Enchantment> getEnchantments() { public Set<Enchantment> getEnchantments() {
return Registries.ENCHANTMENT.stream().map(enchantment -> (Enchantment) enchantment).collect(Collectors.toSet()); return CommonPlatform.get().enchantmentRegistry().stream().map(enchantment -> (Enchantment) (Object) enchantment).collect(Collectors.toSet());
} }
} }

View File

@@ -48,9 +48,9 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
@Shadow @Shadow
public abstract MobSpawnerLogic getLogic(); public abstract MobSpawnerLogic getLogic();
//method_46408
@Shadow @Shadow
public abstract void method_46408(net.minecraft.entity.EntityType<?> entityType, Random random); public abstract void setEntityType(net.minecraft.entity.EntityType<?> entityType, Random random);
public EntityType terra$getSpawnedType() { public EntityType terra$getSpawnedType() {
return (EntityType) Registries.ENTITY_TYPE.get( return (EntityType) Registries.ENTITY_TYPE.get(
@@ -64,7 +64,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
} else { } else {
rand = Random.create(); rand = Random.create();
} }
method_46408((net.minecraft.entity.EntityType<?>) creatureType, rand); setEntityType((net.minecraft.entity.EntityType<?>) creatureType, rand);
} }
public int terra$getDelay() { public int terra$getDelay() {

View File

@@ -39,14 +39,14 @@ public abstract class EntityMixin {
private BlockPos blockPos; private BlockPos blockPos;
@Shadow @Shadow
public abstract void teleport(double destX, double destY, double destZ); public abstract void updatePosition(double destX, double destY, double destZ);
public Vector3 terra$position() { public Vector3 terra$position() {
return MinecraftAdapter.adapt(blockPos); return MinecraftAdapter.adapt(blockPos);
} }
public void terra$position(Vector3 location) { public void terra$position(Vector3 location) {
teleport(location.getX(), location.getY(), location.getZ()); updatePosition(location.getX(), location.getY(), location.getZ());
} }
public ServerWorld terra$world() { public ServerWorld terra$world() {

View File

@@ -21,7 +21,6 @@ import net.minecraft.component.Component;
import net.minecraft.component.ComponentChanges; import net.minecraft.component.ComponentChanges;
import net.minecraft.component.ComponentMap; import net.minecraft.component.ComponentMap;
import net.minecraft.component.ComponentMapImpl; import net.minecraft.component.ComponentMapImpl;
import net.minecraft.component.DataComponentType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@@ -17,8 +17,13 @@
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta; package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta;
import com.dfsek.terra.mod.CommonPlatform;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.Registries; import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntryList;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -28,6 +33,8 @@ import java.util.Objects;
import com.dfsek.terra.api.inventory.ItemStack; import com.dfsek.terra.api.inventory.ItemStack;
import static net.minecraft.enchantment.Enchantment.canBeCombined;
@Mixin(Enchantment.class) @Mixin(Enchantment.class)
@Implements(@Interface(iface = com.dfsek.terra.api.inventory.item.Enchantment.class, prefix = "terra$")) @Implements(@Interface(iface = com.dfsek.terra.api.inventory.item.Enchantment.class, prefix = "terra$"))
@@ -36,7 +43,8 @@ public abstract class EnchantmentMixin {
public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack); public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack);
@Shadow @Shadow
public abstract boolean canCombine(Enchantment other); @Final
private RegistryEntryList<Enchantment> exclusiveSet;
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public boolean terra$canEnchantItem(ItemStack itemStack) { public boolean terra$canEnchantItem(ItemStack itemStack) {
@@ -44,10 +52,10 @@ public abstract class EnchantmentMixin {
} }
public boolean terra$conflictsWith(com.dfsek.terra.api.inventory.item.Enchantment other) { public boolean terra$conflictsWith(com.dfsek.terra.api.inventory.item.Enchantment other) {
return !canCombine((Enchantment) other); return canBeCombined(RegistryEntry.of((Enchantment) (Object) this), RegistryEntry.of((Enchantment) (Object) other));
} }
public String terra$getID() { public String terra$getID() {
return Objects.requireNonNull(Registries.ENCHANTMENT.getId((Enchantment) (Object) this)).toString(); return Objects.requireNonNull(CommonPlatform.get().enchantmentRegistry().getId((Enchantment) (Object) this)).toString();
} }
} }

View File

@@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtList;
import net.minecraft.registry.Registries; import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic; import org.spongepowered.asm.mixin.Intrinsic;
@@ -46,10 +47,10 @@ public abstract class ItemStackMetaMixin {
public abstract ItemEnchantmentsComponent getEnchantments(); public abstract ItemEnchantmentsComponent getEnchantments();
@Shadow @Shadow
public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level); public abstract void addEnchantment(RegistryEntry<net.minecraft.enchantment.Enchantment> enchantment, int level);
public void terra$addEnchantment(Enchantment enchantment, int level) { public void terra$addEnchantment(Enchantment enchantment, int level) { ;
addEnchantment((net.minecraft.enchantment.Enchantment) enchantment, level); addEnchantment(RegistryEntry.of((net.minecraft.enchantment.Enchantment) (Object) enchantment), level);
} }
@Intrinsic(displace = true) @Intrinsic(displace = true)
@@ -60,7 +61,7 @@ public abstract class ItemStackMetaMixin {
ItemEnchantmentsComponent enchantments = getEnchantments(); ItemEnchantmentsComponent enchantments = getEnchantments();
enchantments.getEnchantments().forEach(enchantment -> { enchantments.getEnchantments().forEach(enchantment -> {
net.minecraft.enchantment.Enchantment enchantmentValue = enchantment.value(); net.minecraft.enchantment.Enchantment enchantmentValue = enchantment.value();
map.put((Enchantment) enchantmentValue, enchantments.getLevel(enchantmentValue)); map.put((Enchantment) (Object) enchantmentValue, enchantments.getLevel(RegistryEntry.of(enchantmentValue)));
}); });
return map; return map;
} }

View File

@@ -21,10 +21,12 @@ import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker;
import net.minecraft.block.FluidBlock; import net.minecraft.block.FluidBlock;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.util.collection.BoundedRegionArray;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion; import net.minecraft.world.ChunkRegion;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkGenerationStep;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.tick.MultiTickScheduler; import net.minecraft.world.tick.MultiTickScheduler;
import net.minecraft.world.tick.OrderedTick; import net.minecraft.world.tick.OrderedTick;
@@ -76,10 +78,9 @@ public abstract class ChunkRegionMixin {
@Inject(at = @At("RETURN"), @Inject(at = @At("RETURN"),
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V") method = "<init>(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/collection/BoundedRegionArray;Lnet/minecraft/world/chunk/ChunkGenerationStep;Lnet/minecraft/world/chunk/Chunk;)V")
public void injectConstructor(net.minecraft.server.world.ServerWorld world, List<net.minecraft.world.chunk.Chunk> list, public void injectConstructor(net.minecraft.server.world.ServerWorld world, BoundedRegionArray chunks,
ChunkStatus chunkStatus, int i, ChunkGenerationStep generationStep, Chunk centerPos, CallbackInfo ci) {
CallbackInfo ci) {
this.terra$config = ((ServerWorld) world).getPack(); this.terra$config = ((ServerWorld) world).getPack();
} }

View File

@@ -45,7 +45,7 @@ public class PresetUtil {
.orElseThrow(); .orElseThrow();
Identifier generatorID = Identifier.of("terra", pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase( Identifier generatorID = Identifier.tryParse("terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase(
Locale.ROOT)); Locale.ROOT));
PRESETS.add(generatorID); PRESETS.add(generatorID);

View File

@@ -4,6 +4,7 @@ import ca.solostudios.strata.Versions;
import ca.solostudios.strata.parser.tokenizer.ParseException; import ca.solostudios.strata.parser.tokenizer.ParseException;
import ca.solostudios.strata.version.Version; import ca.solostudios.strata.version.Version;
import net.minecraft.MinecraftVersion; import net.minecraft.MinecraftVersion;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@@ -34,6 +35,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
private static final AtomicReference<Registry<DimensionType>> DIMENSIONS = new AtomicReference<>(); private static final AtomicReference<Registry<DimensionType>> DIMENSIONS = new AtomicReference<>();
private static final AtomicReference<Registry<ChunkGeneratorSettings>> SETTINGS = new AtomicReference<>(); private static final AtomicReference<Registry<ChunkGeneratorSettings>> SETTINGS = new AtomicReference<>();
private static final AtomicReference<Registry<MultiNoiseBiomeSourceParameterList>> NOISE = new AtomicReference<>(); private static final AtomicReference<Registry<MultiNoiseBiomeSourceParameterList>> NOISE = new AtomicReference<>();
private static final AtomicReference<Registry<Enchantment>> ENCHANTMENT = new AtomicReference<>();
private static MinecraftServer server; private static MinecraftServer server;
public LifecyclePlatform() { public LifecyclePlatform() {
@@ -44,11 +46,13 @@ public abstract class LifecyclePlatform extends ModPlatform {
public static void setRegistries(Registry<Biome> biomeRegistry, public static void setRegistries(Registry<Biome> biomeRegistry,
Registry<DimensionType> dimensionTypeRegistry, Registry<DimensionType> dimensionTypeRegistry,
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry, Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry,
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry) { Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry,
Registry<Enchantment> enchantmentRegistry) {
BIOMES.set(biomeRegistry); BIOMES.set(biomeRegistry);
DIMENSIONS.set(dimensionTypeRegistry); DIMENSIONS.set(dimensionTypeRegistry);
SETTINGS.set(chunkGeneratorSettingsRegistry); SETTINGS.set(chunkGeneratorSettingsRegistry);
NOISE.set(multiNoiseBiomeSourceParameterListRegistry); NOISE.set(multiNoiseBiomeSourceParameterListRegistry);
ENCHANTMENT.set(enchantmentRegistry);
} }
@Override @Override
@@ -141,5 +145,10 @@ public abstract class LifecyclePlatform extends ModPlatform {
return NOISE.get(); return NOISE.get();
} }
@Override
public Registry<Enchantment> enchantmentRegistry() {
return ENCHANTMENT.get();
}
protected abstract Collection<BaseAddon> getPlatformMods(); protected abstract Collection<BaseAddon> getPlatformMods();
} }

View File

@@ -1,6 +1,7 @@
package com.dfsek.terra.lifecycle.mixin.lifecycle; package com.dfsek.terra.lifecycle.mixin.lifecycle;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.DynamicRegistryManager.Immutable; import net.minecraft.registry.DynamicRegistryManager.Immutable;
import net.minecraft.registry.MutableRegistry; import net.minecraft.registry.MutableRegistry;
@@ -70,8 +71,9 @@ public class RegistryLoaderMixin {
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow(); RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance, MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow(); RegistryKeys.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST).orElseThrow();
MutableRegistry<Enchantment> enchantments = extractRegistry(instance, RegistryKeys.ENCHANTMENT).orElseThrow();
LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists); LifecyclePlatform.setRegistries(biomes, dimensionTypes, chunkGeneratorSettings, multiNoiseBiomeSourceParameterLists, enchantments);
LifecycleUtil.initialize(biomes, worldPresets); LifecycleUtil.initialize(biomes, worldPresets);
}); });
initialized = true; initialized = true;

View File

@@ -58,7 +58,7 @@ public final class BiomeUtil {
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome, Objects.requireNonNull(registry.get(vanilla)), net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome, Objects.requireNonNull(registry.get(vanilla)),
vanillaBiomeProperties); vanillaBiomeProperties);
Identifier identifier = new Identifier("terra", MinecraftUtil.createBiomeID(pack, id)); Identifier identifier = Identifier.of("terra", MinecraftUtil.createBiomeID(pack, id));
if(registry.containsId(identifier)) { if(registry.containsId(identifier)) {
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier) ((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier)

View File

@@ -13,7 +13,7 @@ public final class RegistryUtil {
} }
public static void register() { public static void register() {
Registry.register(Registries.CHUNK_GENERATOR, new Identifier("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER); Registry.register(Registries.CHUNK_GENERATOR, Identifier.of("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
Registry.register(Registries.BIOME_SOURCE, new Identifier("terra:terra"), Codecs.TERRA_BIOME_SOURCE); Registry.register(Registries.BIOME_SOURCE, Identifier.of("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
} }
} }