mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
working 1.21.1
This commit is contained in:
@@ -29,7 +29,7 @@ object Versions {
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricAPI = "0.97.8+${Mod.minecraft}"
|
||||
const val fabricAPI = "0.104.0+${Mod.minecraft}"
|
||||
}
|
||||
//
|
||||
// object Quilt {
|
||||
@@ -40,8 +40,8 @@ object Versions {
|
||||
object Mod {
|
||||
const val mixin = "0.15.3+mixin.0.8.7"
|
||||
|
||||
const val minecraft = "1.20.6"
|
||||
const val yarn = "$minecraft+build.1"
|
||||
const val minecraft = "1.21.1"
|
||||
const val yarn = "$minecraft+build.3"
|
||||
const val fabricLoader = "0.16.5"
|
||||
|
||||
const val architecuryLoom = "1.7.413"
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.mod;
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.registry.Registry;
|
||||
@@ -116,6 +117,8 @@ public abstract class ModPlatform extends AbstractPlatform {
|
||||
|
||||
public abstract Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry();
|
||||
|
||||
public abstract Registry<Enchantment> enchantmentRegistry();
|
||||
|
||||
@Override
|
||||
public @NotNull WorldHandle getWorldHandle() {
|
||||
return worldHandle;
|
||||
@@ -125,4 +128,6 @@ public abstract class ModPlatform extends AbstractPlatform {
|
||||
public @NotNull ItemHandle getItemHandle() {
|
||||
return itemHandle;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -111,10 +111,9 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
return settings.value().generationShapeConfig().height();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig,
|
||||
StructureAccessor structureAccessor, Chunk chunk) {
|
||||
public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor,
|
||||
Chunk chunk) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||
|
||||
@@ -62,11 +62,11 @@ public class MinecraftItemHandle implements ItemHandle {
|
||||
|
||||
@Override
|
||||
public Enchantment getEnchantment(String id) {
|
||||
return (Enchantment) (Registries.ENCHANTMENT.get(Identifier.tryParse(id)));
|
||||
return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().get(Identifier.tryParse(id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
|
||||
@Shadow
|
||||
public abstract MobSpawnerLogic getLogic();
|
||||
|
||||
//method_46408
|
||||
@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() {
|
||||
return (EntityType) Registries.ENTITY_TYPE.get(
|
||||
@@ -64,7 +64,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
} else {
|
||||
rand = Random.create();
|
||||
}
|
||||
method_46408((net.minecraft.entity.EntityType<?>) creatureType, rand);
|
||||
setEntityType((net.minecraft.entity.EntityType<?>) creatureType, rand);
|
||||
}
|
||||
|
||||
public int terra$getDelay() {
|
||||
|
||||
@@ -39,14 +39,14 @@ public abstract class EntityMixin {
|
||||
private BlockPos blockPos;
|
||||
|
||||
@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() {
|
||||
return MinecraftAdapter.adapt(blockPos);
|
||||
}
|
||||
|
||||
public void terra$position(Vector3 location) {
|
||||
teleport(location.getX(), location.getY(), location.getZ());
|
||||
updatePosition(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public ServerWorld terra$world() {
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.component.Component;
|
||||
import net.minecraft.component.ComponentChanges;
|
||||
import net.minecraft.component.ComponentMap;
|
||||
import net.minecraft.component.ComponentMapImpl;
|
||||
import net.minecraft.component.DataComponentType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -17,8 +17,13 @@
|
||||
|
||||
package com.dfsek.terra.mod.mixin.implementations.terra.inventory.meta;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
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.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -28,6 +33,8 @@ import java.util.Objects;
|
||||
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
import static net.minecraft.enchantment.Enchantment.canBeCombined;
|
||||
|
||||
|
||||
@Mixin(Enchantment.class)
|
||||
@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);
|
||||
|
||||
@Shadow
|
||||
public abstract boolean canCombine(Enchantment other);
|
||||
@Final
|
||||
private RegistryEntryList<Enchantment> exclusiveSet;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
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) {
|
||||
return !canCombine((Enchantment) other);
|
||||
return canBeCombined(RegistryEntry.of((Enchantment) (Object) this), RegistryEntry.of((Enchantment) (Object) other));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Intrinsic;
|
||||
@@ -46,10 +47,10 @@ public abstract class ItemStackMetaMixin {
|
||||
public abstract ItemEnchantmentsComponent getEnchantments();
|
||||
|
||||
@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) {
|
||||
addEnchantment((net.minecraft.enchantment.Enchantment) enchantment, level);
|
||||
public void terra$addEnchantment(Enchantment enchantment, int level) { ;
|
||||
addEnchantment(RegistryEntry.of((net.minecraft.enchantment.Enchantment) (Object) enchantment), level);
|
||||
}
|
||||
|
||||
@Intrinsic(displace = true)
|
||||
@@ -60,7 +61,7 @@ public abstract class ItemStackMetaMixin {
|
||||
ItemEnchantmentsComponent enchantments = getEnchantments();
|
||||
enchantments.getEnchantments().forEach(enchantment -> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -21,10 +21,12 @@ import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker;
|
||||
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.util.collection.BoundedRegionArray;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkGenerationStep;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.tick.MultiTickScheduler;
|
||||
import net.minecraft.world.tick.OrderedTick;
|
||||
@@ -76,10 +78,9 @@ public abstract class ChunkRegionMixin {
|
||||
|
||||
|
||||
@Inject(at = @At("RETURN"),
|
||||
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V")
|
||||
public void injectConstructor(net.minecraft.server.world.ServerWorld world, List<net.minecraft.world.chunk.Chunk> list,
|
||||
ChunkStatus chunkStatus, int i,
|
||||
CallbackInfo ci) {
|
||||
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, BoundedRegionArray chunks,
|
||||
ChunkGenerationStep generationStep, Chunk centerPos, CallbackInfo ci) {
|
||||
this.terra$config = ((ServerWorld) world).getPack();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PresetUtil {
|
||||
.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));
|
||||
|
||||
PRESETS.add(generatorID);
|
||||
|
||||
@@ -4,6 +4,7 @@ import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import net.minecraft.MinecraftVersion;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
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<ChunkGeneratorSettings>> SETTINGS = new AtomicReference<>();
|
||||
private static final AtomicReference<Registry<MultiNoiseBiomeSourceParameterList>> NOISE = new AtomicReference<>();
|
||||
private static final AtomicReference<Registry<Enchantment>> ENCHANTMENT = new AtomicReference<>();
|
||||
private static MinecraftServer server;
|
||||
|
||||
public LifecyclePlatform() {
|
||||
@@ -44,11 +46,13 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
public static void setRegistries(Registry<Biome> biomeRegistry,
|
||||
Registry<DimensionType> dimensionTypeRegistry,
|
||||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry,
|
||||
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry) {
|
||||
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterListRegistry,
|
||||
Registry<Enchantment> enchantmentRegistry) {
|
||||
BIOMES.set(biomeRegistry);
|
||||
DIMENSIONS.set(dimensionTypeRegistry);
|
||||
SETTINGS.set(chunkGeneratorSettingsRegistry);
|
||||
NOISE.set(multiNoiseBiomeSourceParameterListRegistry);
|
||||
ENCHANTMENT.set(enchantmentRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,5 +145,10 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
return NOISE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<Enchantment> enchantmentRegistry() {
|
||||
return ENCHANTMENT.get();
|
||||
}
|
||||
|
||||
protected abstract Collection<BaseAddon> getPlatformMods();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.DynamicRegistryManager.Immutable;
|
||||
import net.minecraft.registry.MutableRegistry;
|
||||
@@ -70,8 +71,9 @@ public class RegistryLoaderMixin {
|
||||
RegistryKeys.CHUNK_GENERATOR_SETTINGS).orElseThrow();
|
||||
MutableRegistry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists = extractRegistry(instance,
|
||||
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);
|
||||
});
|
||||
initialized = true;
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class BiomeUtil {
|
||||
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(biome, Objects.requireNonNull(registry.get(vanilla)),
|
||||
vanillaBiomeProperties);
|
||||
|
||||
Identifier identifier = new Identifier("terra", MinecraftUtil.createBiomeID(pack, id));
|
||||
Identifier identifier = Identifier.of("terra", MinecraftUtil.createBiomeID(pack, id));
|
||||
|
||||
if(registry.containsId(identifier)) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(MinecraftUtil.getEntry(registry, identifier)
|
||||
|
||||
@@ -13,7 +13,7 @@ public final class RegistryUtil {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
Registry.register(Registries.CHUNK_GENERATOR, new Identifier("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
|
||||
Registry.register(Registries.BIOME_SOURCE, new Identifier("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
|
||||
Registry.register(Registries.CHUNK_GENERATOR, Identifier.of("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
|
||||
Registry.register(Registries.BIOME_SOURCE, Identifier.of("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user