*WIP:* Started code migration

This commit is contained in:
Frank 2022-03-07 22:09:57 +01:00
parent 557e69080b
commit 48db196c7b
22 changed files with 233 additions and 323 deletions

View file

@ -24,10 +24,10 @@ public interface BiomeGenerationSettingsAccessor {
void bclib_setFeatures(List<List<Supplier<PlacedFeature>>> value);
@Accessor("featureSet")
Set<PlacedFeature> bclib_getFeatureSet();
Supplier<Set<PlacedFeature>> bclib_getFeatureSet();
@Accessor("featureSet")
void bclib_setFeatureSet(Set<PlacedFeature> features);
void bclib_setFeatureSet(Supplier<Set<PlacedFeature>> features);
@Accessor("carvers")
Map<Carving, List<Supplier<ConfiguredWorldCarver<?>>>> bclib_getCarvers();

View file

@ -1,17 +1,23 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Registry;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.structure.StructureSet;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.interfaces.ChunkGeneratorAccessor;
@Mixin(ChunkGenerator.class)
public class ChunkGeneratorMixin {
public class ChunkGeneratorMixin implements ChunkGeneratorAccessor {
@Shadow @Final protected Registry<StructureSet> structureSets;
private int bclib_featureIteratorSeed;
@ModifyArg(method = "applyBiomeDecoration", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/WorldgenRandom;setFeatureSeed(JII)V"))
@ -23,4 +29,8 @@ public class ChunkGeneratorMixin {
private void bclib_obBiomeGenerate(WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureFeatureManager structureFeatureManager, CallbackInfo ci) {
bclib_featureIteratorSeed = 0;
}
public Registry<StructureSet> bclib_getStructureSetsRegistry(){
return structureSets;
}
}

View file

@ -0,0 +1,21 @@
package ru.bclib.mixin.common;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.function.Supplier;
@Mixin(DiggerItem.class)
public interface DiggerItemAccessor {
@Accessor("blocks")
@Mutable
TagKey<Block> bclib_getBlockTag();
}

View file

@ -2,7 +2,6 @@ package ru.bclib.mixin.common;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.FallbackResourceManager;
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -12,28 +11,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
@Mixin(SimpleReloadableResourceManager.class)
public class SimpleReloadableResourceManagerMixin {
@Final
@Shadow
private Map<String, FallbackResourceManager> namespacedPacks;
private static final String[] BCLIB_MISSING_RESOURCES = new String[] {
"dimension/the_end.json",
"dimension/the_nether.json",
"dimension_type/the_end.json",
"dimension_type/the_nether.json"
};
@Inject(method = "hasResource", at = @At("HEAD"), cancellable = true)
private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
if (resourceLocation.getNamespace().equals("minecraft")) {
for (String key: BCLIB_MISSING_RESOURCES) {
if (resourceLocation.getPath().equals(key)) {
info.setReturnValue(false);
return;
}
}
}
}
}
//TODO: 1.18.2 Disabled to have a compilable Version
//@Mixin(SimpleReloadableResourceManager.class)
//public class SimpleReloadableResourceManagerMixin {
// @Final
// @Shadow
// private Map<String, FallbackResourceManager> namespacedPacks;
//
// private static final String[] BCLIB_MISSING_RESOURCES = new String[] {
// "dimension/the_end.json",
// "dimension/the_nether.json",
// "dimension_type/the_end.json",
// "dimension_type/the_nether.json"
// };
//
// @Inject(method = "hasResource", at = @At("HEAD"), cancellable = true)
// private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
// if (resourceLocation.getNamespace().equals("minecraft")) {
// for (String key: BCLIB_MISSING_RESOURCES) {
// if (resourceLocation.getPath().equals(key)) {
// info.setReturnValue(false);
// return;
// }
// }
// }
// }
//}

View file

@ -1,32 +0,0 @@
package ru.bclib.mixin.common;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.StructureSettings;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Map;
@Mixin(StructureSettings.class)
public interface StructureSettingsAccessor {
@Accessor("configuredStructures")
ImmutableMap<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> bcl_getConfiguredStructures();
@Accessor("structureConfig")
Map<StructureFeature<?>, StructureFeatureConfiguration> bcl_getStructureConfig();
@Accessor("configuredStructures")
@Mutable
void bcl_setConfiguredStructures(ImmutableMap<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> configuredStructures);
@Accessor("structureConfig")
@Mutable
void bcl_setStructureConfig(Map<StructureFeature<?>, StructureFeatureConfiguration> structureConfig);
}

View file

@ -1,5 +1,6 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkAccess;
@ -25,10 +26,7 @@ public interface SurfaceRulesContextAccessor {
int getSurfaceDepth();
@Accessor("biome")
Supplier<Biome> getBiome();
@Accessor("biomeKey")
Supplier<ResourceKey<Biome>> getBiomeKey();
Supplier<Holder<Biome>> getBiome();
@Accessor("chunk")
ChunkAccess getChunk();