More adaptations

This commit is contained in:
Frank 2022-07-08 11:51:43 +02:00
parent cee6f167c7
commit 0c557e119b
11 changed files with 47 additions and 63 deletions

View file

@ -12,8 +12,9 @@ import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.StructureManager; import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.Rotation;
@ -66,7 +67,7 @@ public class TemplatePiece extends TemplateStructurePiece {
} }
public TemplatePiece( public TemplatePiece(
StructureTemplateManager structureTemplateManager, StructureManager structureTemplateManager,
ResourceLocation resourceLocation, ResourceLocation resourceLocation,
BlockPos centerPos, BlockPos centerPos,
Rotation rotation, Rotation rotation,
@ -161,9 +162,9 @@ public class TemplatePiece extends TemplateStructurePiece {
@Override @Override
public void postProcess( public void postProcess(
WorldGenLevel world, WorldGenLevel world,
StructureManager structureManager, StructureFeatureManager structureManager,
ChunkGenerator chunkGenerator, ChunkGenerator chunkGenerator,
RandomSource random, Random random,
BoundingBox boundingBox, BoundingBox boundingBox,
ChunkPos chunkPos, ChunkPos chunkPos,
BlockPos blockPos BlockPos blockPos

View file

@ -14,7 +14,7 @@ import net.minecraft.world.item.TieredItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.OreBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
@ -28,7 +28,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
public class BaseOreBlock extends DropExperienceBlock implements BlockModelProvider { public class BaseOreBlock extends OreBlock implements BlockModelProvider {
private final Supplier<Item> dropItem; private final Supplier<Item> dropItem;
private final int minCount; private final int minCount;
private final int maxCount; private final int maxCount;

View file

@ -7,10 +7,10 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.RandomSource;
import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;

View file

@ -1,5 +1,8 @@
package org.betterx.bclib.util; package org.betterx.bclib.util;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;

View file

@ -19,6 +19,7 @@ import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;

View file

@ -3,14 +3,12 @@ package org.betterx.worlds.together.mixin.client;
import org.betterx.worlds.together.WorldsTogether; import org.betterx.worlds.together.WorldsTogether;
import org.betterx.worlds.together.world.event.WorldBootstrap; import org.betterx.worlds.together.world.event.WorldBootstrap;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.WorldStem;
import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.WorldData;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -19,59 +17,64 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Optional; import java.util.function.Function;
@Mixin(WorldOpenFlows.class) @Mixin(Minecraft.class)
public abstract class WorldOpenFlowsMixin { public abstract class MinecraftMixin {
@Shadow
protected abstract void doLoadLevel(
String string,
Function<LevelStorageSource.LevelStorageAccess, WorldStem.DataPackConfigSupplier> function,
Function<LevelStorageSource.LevelStorageAccess, WorldStem.WorldDataSupplier> function2,
boolean bl,
Minecraft.ExperimentalDialogType experimentalDialogType
);
@Shadow @Shadow
@Final @Final
private LevelStorageSource levelSource; private LevelStorageSource levelSource;
@Shadow
protected abstract void doLoadLevel(Screen screen, String levelID, boolean safeMode, boolean canAskForBackup);
@Inject(method = "loadLevel", cancellable = true, at = @At("HEAD")) @Inject(method = "loadLevel", cancellable = true, at = @At("HEAD"))
private void wt_callFixerOnLoad(Screen screen, String levelID, CallbackInfo ci) { private void wt_callFixerOnLoad(String levelID, CallbackInfo ci) {
WorldBootstrap.InGUI.setupLoadedWorld(levelID, this.levelSource); WorldBootstrap.InGUI.setupLoadedWorld(levelID, this.levelSource);
//if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> { //if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> {
if (WorldBootstrap.InGUI.applyWorldPatches(levelSource, levelID, (appliedFixes) -> { if (WorldBootstrap.InGUI.applyWorldPatches(levelSource, levelID, (appliedFixes) -> {
WorldBootstrap.InGUI.finishedWorldLoad(levelID, this.levelSource); WorldBootstrap.InGUI.finishedWorldLoad(levelID, this.levelSource);
this.doLoadLevel(screen, levelID, false, false); this.doLoadLevel(
levelID,
WorldStem.DataPackConfigSupplier::loadFromWorld,
WorldStem.WorldDataSupplier::loadFromWorld,
false,
Minecraft.ExperimentalDialogType.NONE
);
})) { })) {
//cancel call when fix-screen is presented //cancel call when fix-screen is presented
ci.cancel(); ci.cancel();
} else { } else {
WorldBootstrap.InGUI.finishedWorldLoad(levelID, this.levelSource); WorldBootstrap.InGUI.finishedWorldLoad(levelID, this.levelSource);
if (WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG) { if (WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG) {
this.doLoadLevel(screen, levelID, false, false); this.doLoadLevel(
levelID,
WorldStem.DataPackConfigSupplier::loadFromWorld,
WorldStem.WorldDataSupplier::loadFromWorld,
false,
Minecraft.ExperimentalDialogType.NONE
);
//cancel call as we manually start the level load here //cancel call as we manually start the level load here
ci.cancel(); ci.cancel();
} }
} }
} }
@Inject(method = "createFreshLevel", at = @At("HEAD")) @Inject(method = "createLevel", at = @At("HEAD"))
public void wt_createFreshLevel( private void wt_callOnCreate(
String levelID, String levelID,
LevelSettings levelSettings, LevelSettings levelSettings,
RegistryAccess registryAccess, RegistryAccess registryAccess,
WorldGenSettings worldGenSettings, WorldGenSettings worldGenSettings,
CallbackInfo ci CallbackInfo ci
) { ) {
WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty());
}
@Inject(method = "createLevelFromExistingSettings", at = @At("HEAD"))
public void wt_createLevelFromExistingSettings(
LevelStorageSource.LevelStorageAccess levelStorageAccess,
ReloadableServerResources reloadableServerResources,
RegistryAccess.Frozen frozen,
WorldData worldData,
CallbackInfo ci
) {
//called from the CreateWorldScreenMixin now
//LifeCycleAPI.newWorldSetup(levelStorageAccess, worldData.worldGenSettings());
} }
} }

View file

@ -1,22 +0,0 @@
package org.betterx.worlds.together.mixin.common;
import org.betterx.worlds.together.world.event.WorldBootstrap;
import net.minecraft.core.RegistryAccess;
import net.minecraft.server.WorldLoader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(WorldLoader.class)
public class WorldLoaderMixin {
//this is the place a new Registry access gets first istantiated
//either when a new Datapack was added to a world on the create-screen
//or because we did start world loading
@ModifyArg(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/ReloadableServerResources;loadResources(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$Frozen;Lnet/minecraft/commands/Commands$CommandSelection;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
private static RegistryAccess.Frozen wt_newRegistry(RegistryAccess.Frozen frozen) {
WorldBootstrap.InGUI.registryReady(frozen);
return frozen;
}
}

View file

@ -1,14 +1,13 @@
package org.betterx.worlds.together.world.event; package org.betterx.worlds.together.world.event;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagLoader; import net.minecraft.tags.Tag;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface BeforeAddingTags { public interface BeforeAddingTags {
void apply( void apply(
String directory, String directory,
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap Map<ResourceLocation, Tag.Builder> tagsMap
); );
} }

View file

@ -9,12 +9,12 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyXZCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
accessible class net/minecraft/data/BuiltinRegistries$RegistryBootstrap
accessible class net/minecraft/core/Registry$RegistryBootstrap accessible class net/minecraft/core/Registry$RegistryBootstrap
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/core/Registry$RegistryBootstrap accessible class net/minecraft/core/Registry$RegistryBootstrap
accessible class net/minecraft/tags/Tag$ElementEntry accessible class net/minecraft/tags/Tag$ElementEntry
accessible class net/minecraft/tags/Tag$TagEntry accessible class net/minecraft/tags/Tag$TagEntry
accessible class net/minecraft/client/Minecraft$ExperimentalDialogType
#Methods #Methods
accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V

View file

@ -5,8 +5,8 @@
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"client": [ "client": [
"CreateWorldScreenMixin", "CreateWorldScreenMixin",
"WorldGenSettingsComponentMixin", "MinecraftMixin",
"WorldOpenFlowsMixin" "WorldGenSettingsComponentMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1

View file

@ -17,7 +17,6 @@
"RegistryOpsAccessor", "RegistryOpsAccessor",
"TagLoaderMixin", "TagLoaderMixin",
"WorldGenPropertiesMixin", "WorldGenPropertiesMixin",
"WorldLoaderMixin",
"WorldPresetAccessor", "WorldPresetAccessor",
"WorldPresetMixin", "WorldPresetMixin",
"WorldPresetsBootstrapMixin" "WorldPresetsBootstrapMixin"