diff --git a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java index 686cf96c..77ec7654 100644 --- a/src/main/java/ru/bclib/api/biomes/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/biomes/BiomeAPI.java @@ -1,19 +1,15 @@ package ru.bclib.api.biomes; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.impl.biome.NetherBiomeData; import net.fabricmc.fabric.impl.biome.TheEndBiomeData; -import net.fabricmc.fabric.impl.structure.FabricStructureImpl; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.data.BuiltinRegistries; import net.minecraft.resources.ResourceKey; @@ -26,11 +22,7 @@ import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.BiomeGenerationSettings; -import net.minecraft.world.level.biome.BiomeSource; -import net.minecraft.world.level.biome.Biomes; -import net.minecraft.world.level.biome.Climate; +import net.minecraft.world.level.biome.*; import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -41,27 +33,20 @@ import net.minecraft.world.level.levelgen.GenerationStep.Carving; import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; -import net.minecraft.world.level.levelgen.StructureSettings; import net.minecraft.world.level.levelgen.SurfaceRules; import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; 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 net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.minecraft.world.level.levelgen.structure.StructureSet; import org.apache.commons.lang3.mutable.MutableInt; import org.jetbrains.annotations.Nullable; import ru.bclib.BCLib; import ru.bclib.entity.BCLEntityWrapper; -import ru.bclib.interfaces.BiomeSourceAccessor; -import ru.bclib.interfaces.NoiseGeneratorSettingsProvider; -import ru.bclib.interfaces.SurfaceMaterialProvider; -import ru.bclib.interfaces.SurfaceProvider; -import ru.bclib.interfaces.SurfaceRuleProvider; +import ru.bclib.interfaces.*; import ru.bclib.mixin.common.BiomeGenerationSettingsAccessor; import ru.bclib.mixin.common.MobSpawnSettingsAccessor; -import ru.bclib.mixin.common.StructureSettingsAccessor; import ru.bclib.util.CollectionsUtil; import ru.bclib.util.MHelper; import ru.bclib.world.biomes.BCLBiome; @@ -69,18 +54,9 @@ import ru.bclib.world.biomes.FabricBiomesData; import ru.bclib.world.biomes.VanillaBiomeSettings; import ru.bclib.world.features.BCLFeature; import ru.bclib.world.generator.BiomePicker; -import ru.bclib.world.structures.BCLStructureFeature; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.Random; -import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -102,8 +78,7 @@ public class BiomeAPI { private static final Map FEATURE_ORDER = Maps.newHashMap(); private static final MutableInt FEATURE_ORDER_ID = new MutableInt(0); - - private final static Map, Multimap, ResourceKey>>, Map, StructureFeatureConfiguration>>> STRUCTURE_STARTS = new HashMap<>(); + private static final Map>> MODIFICATIONS = Maps.newHashMap(); private static final Map SURFACE_RULES = Maps.newHashMap(); private static final Set MODIFIED_SURFACE_PROVIDERS = new HashSet<>(8); @@ -161,8 +136,6 @@ public class BiomeAPI { * called from {@link ru.bclib.mixin.client.MinecraftMixin} */ public static void prepareNewLevel(){ - STRUCTURE_STARTS.clear(); - MODIFIED_SURFACE_PROVIDERS.forEach(p->p.bclib_clearBiomeSources()); MODIFIED_SURFACE_PROVIDERS.clear(); } @@ -375,6 +348,19 @@ public class BiomeAPI { } return id == null ? EMPTY_BIOME.getID() : id; } + + /** + * Get biome {@link ResourceLocation} from given {@link Biome}. + * @param biome - {@link Holder} from server world. + * @return biome {@link ResourceLocation}. + */ + public static ResourceLocation getBiomeID(Holder biome) { + var oKey = biome.unwrapKey(); + if (oKey.isPresent()){ + return oKey.get().location(); + } + return null; + } /** * Get {@link BCLBiome} from given {@link ResourceLocation}. @@ -393,6 +379,15 @@ public class BiomeAPI { public static BCLBiome getBiome(Biome biome) { return getBiome(BiomeAPI.getBiomeID(biome)); } + + /** + * Get {@link BCLBiome} from given {@link Biome}. + * @param biome - biome {@link Biome}. + * @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}. + */ + public static BCLBiome getBiome(Holder biome) { + return getBiome(BiomeAPI.getBiomeID(biome)); + } /** * Check if biome with {@link ResourceLocation} exists in API registry. @@ -491,40 +486,54 @@ public class BiomeAPI { * @param level */ public static void applyModifications(ServerLevel level) { - final BiomeSource source = level.getChunkSource().getGenerator().getBiomeSource(); - final StructureSettings settings = level.getChunkSource().getGenerator().getSettings(); - final Set biomes = source.possibleBiomes(); + NoiseGeneratorSettings noiseGeneratorSettings = null; + final ChunkGenerator chunkGenerator = level.getChunkSource().getGenerator(); + final BiomeSource source = chunkGenerator.getBiomeSource(); + final Set> biomes = source.possibleBiomes(); - NoiseGeneratorSettings generator = level + //TODO: 1.18.2 Is this stilla valid way to determine the correct noiseGeneratorSettings for the level? + + final Registry structureSetRegistry; + if (chunkGenerator instanceof ChunkGeneratorAccessor acc) { + structureSetRegistry = acc.bclib_getStructureSetsRegistry(); + } else { + structureSetRegistry = null; + } + + + noiseGeneratorSettings = level .getServer() .getWorldData() .worldGenSettings() .dimensions() .stream() .map(dim->dim.generator()) - .filter(gen->(gen instanceof NoiseGeneratorSettingsProvider) && gen.getSettings()==settings) + .filter(gen-> structureSetRegistry!=null && (gen instanceof NoiseGeneratorSettingsProvider) && (gen instanceof ChunkGeneratorAccessor) && ((ChunkGeneratorAccessor)gen).bclib_getStructureSetsRegistry()==structureSetRegistry) .map(gen->((NoiseGeneratorSettingsProvider)gen).bclib_getNoiseGeneratorSettings()) .findFirst() .orElse(null); + // Datapacks (like Amplified Nether)will change the GeneratorSettings upon load, so we will // only use the default Setting for Nether/End if we were unable to find a settings object - if (generator==null){ + if (noiseGeneratorSettings==null){ if (level.dimension() == Level.NETHER) { - generator = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.NETHER); + noiseGeneratorSettings = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.NETHER); } else if (level.dimension() == Level.END) { - generator = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.END); + noiseGeneratorSettings = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.END); } } List> modifications = MODIFICATIONS.get(level.dimension()); - for (Biome biome : biomes) { - applyModificationsAndUpdateFeatures(modifications, biome); + for (Holder biomeHolder : biomes) { + if (biomeHolder.isBound()) { + applyModificationsAndUpdateFeatures(modifications, biomeHolder.value()); + } } - if (generator != null) { - final SurfaceRuleProvider provider = SurfaceRuleProvider.class.cast(generator); + if (noiseGeneratorSettings != null) { + final SurfaceRuleProvider provider = SurfaceRuleProvider.class.cast(noiseGeneratorSettings); // Multiple Biomes can use the same generator. So we need to keep track of all Biomes that are // Provided by all the BiomeSources that use the same generator. // This happens for example when using the MiningDimensions, which reuses the generator for the @@ -535,16 +544,6 @@ public class BiomeAPI { BCLib.LOGGER.warning("No generator for " + source); } - if (settings!=null){ - final StructureSettingsAccessor settingsAccessor = (StructureSettingsAccessor)settings; - final Set biomeIDs = biomes.stream().map(BiomeAPI::getBiomeID).collect(Collectors.toSet()); - for (Entry, Multimap, ResourceKey>>, Map, StructureFeatureConfiguration>>> e : STRUCTURE_STARTS.entrySet()) { - if (biomeIDs.contains(e.getKey().biomeID)) { - applyStructureStarts(settingsAccessor, e.getValue()); - } - } - } - ((BiomeSourceAccessor) source).bclRebuildFeatures(); } @@ -581,7 +580,7 @@ public class BiomeAPI { accessor.bclib_setFeatures(featureList); } - private static List getRuleSourcesForBiomes(Set biomes) { + private static List getRuleSourcesForBiomes(Set> biomes) { Set biomeIDs = biomes .stream() .map(biome -> getBiomeID(biome)) @@ -600,7 +599,7 @@ public class BiomeAPI { * @return A list of {@link RuleSource}-Objects that are needed to create those Biomes */ public static List getRuleSources(Set sources) { - final Set biomes = new HashSet<>(); + final Set> biomes = new HashSet<>(); for (BiomeSource s : sources) { biomes.addAll(s.possibleBiomes()); } @@ -683,68 +682,6 @@ public class BiomeAPI { accessor.bclib_setFeatureSet(set); } - /** - * Adds new structure feature to existing biome. - * @param biomeKey {@link ResourceKey} for the {@link Biome} to add structure feature in. - * @param structure {@link ConfiguredStructureFeature} to add. - */ - public static void addBiomeStructure(ResourceKey biomeKey, ConfiguredStructureFeature structure) { - if (biomeKey == null){ - BCLib.LOGGER.error("null is not a valid biomeKey for " + structure); - return; - } - changeStructureStarts(biomeKey.location(), structure, (structureMap, configMap) -> { - Multimap, ResourceKey> configuredMap = structureMap.computeIfAbsent(structure.feature, k -> HashMultimap.create()); - configuredMap.put(structure, biomeKey); - - StructureFeatureConfiguration config = FabricStructureImpl.STRUCTURE_TO_CONFIG_MAP.get(structure.feature); - if (config != null){ - configMap.put(structure.feature, config); - } - }); - } - - /** - * Add an existing StructureFeature to a Biome - * @param biome The {@link Biome} you want to add teh feature to - * @param structure The {@link ConfiguredStructureFeature} to add - */ - public static void addBiomeStructure(Biome biome, ConfiguredStructureFeature structure) { - changeStructureStarts(BiomeAPI.getBiomeID(biome), structure, (structureMap, configMap) -> { - Multimap, ResourceKey> configuredMap = structureMap.computeIfAbsent(structure.feature, k -> HashMultimap.create()); - var key = getBiomeKey(biome); - if (key != null) { - StructureFeatureConfiguration config = FabricStructureImpl.STRUCTURE_TO_CONFIG_MAP.get(structure.feature); - if (config != null) { - configMap.put(structure.feature, config); - } - configuredMap.put(structure, key); - } else { - BCLib.LOGGER.warning("Unable to find Biome " + getBiomeID(biome)); - } - }); - } - - /** - * Adds new structure feature to existing biome. - * @param biomeKey {@link ResourceKey} for the {@link Biome} to add structure feature in. - * @param structure {@link BCLStructureFeature} to add. - */ - public static void addBiomeStructure(ResourceKey biomeKey, BCLStructureFeature structure) { - addBiomeStructure(biomeKey, structure.getFeatureConfigured()); - } - - /** - * Adds new structure features to existing biome. - * @param biomeKey {@link ResourceKey} for the {@link Biome} to add structure features in. - * @param structures array of {@link BCLStructureFeature} to add. - */ - public static void addBiomeStructures(ResourceKey biomeKey, BCLStructureFeature... structures) { - for (BCLStructureFeature structure: structures) { - addBiomeStructure(biomeKey, structure.getFeatureConfigured()); - } - } - /** * Adds new carver into existing biome. * @param biome {@link Biome} to add carver in. @@ -862,11 +799,11 @@ public class BiomeAPI { * Set biome in chunk at specified position. * @param chunk {@link ChunkAccess} chunk to set biome in. * @param pos {@link BlockPos} biome position. - * @param biome {@link Biome} instance. Should be biome from world. + * @param biome {@link Holder} instance. Should be biome from world. */ - public static void setBiome(ChunkAccess chunk, BlockPos pos, Biome biome) { + public static void setBiome(ChunkAccess chunk, BlockPos pos, Holder biome) { int sectionY = (pos.getY() - chunk.getMinBuildHeight()) >> 4; - PalettedContainer biomes = chunk.getSection(sectionY).getBiomes(); + PalettedContainer> biomes = chunk.getSection(sectionY).getBiomes(); biomes.set((pos.getX() & 15) >> 2, (pos.getY() & 15) >> 2, (pos.getZ() & 15) >> 2, biome); } @@ -874,9 +811,9 @@ public class BiomeAPI { * Set biome in world at specified position. * @param level {@link LevelAccessor} world to set biome in. * @param pos {@link BlockPos} biome position. - * @param biome {@link Biome} instance. Should be biome from world. + * @param biome {@link Holder} instance. Should be biome from world. */ - public static void setBiome(LevelAccessor level, BlockPos pos, Biome biome) { + public static void setBiome(LevelAccessor level, BlockPos pos, Holder biome) { ChunkAccess chunk = level.getChunk(pos); setBiome(chunk, pos, biome); } @@ -909,23 +846,6 @@ public class BiomeAPI { } } - private static void changeStructureStarts(ResourceLocation biomeID, ConfiguredStructureFeature structure, BiConsumer, Multimap, ResourceKey>>, Map, StructureFeatureConfiguration>> modifier) { - STRUCTURE_STARTS.put(new StructureID(biomeID, structure), modifier); - } - - private static void applyStructureStarts(StructureSettingsAccessor access, BiConsumer, Multimap, ResourceKey>>, Map, StructureFeatureConfiguration>> modifier) { - Map, Multimap, ResourceKey>> structureMap; - Map, StructureFeatureConfiguration> configMap; - - structureMap = getMutableConfiguredStructures(access); - configMap = getMutableStructureConfig(access); - - modifier.accept(structureMap, configMap); - - setMutableConfiguredStructures(access, structureMap); - setMutableStructureConfig(access, configMap); - } - private static void sortFeatures(List> features) { initFeatureOrder(); @@ -976,34 +896,4 @@ public class BiomeAPI { features.set(index, mutable); return mutable; } - - //inspired by net.fabricmc.fabric.impl.biome.modification.BiomeStructureStartsImpl - private static Map, Multimap, ResourceKey>> getMutableConfiguredStructures(StructureSettingsAccessor access) { - ImmutableMap, ImmutableMultimap, ResourceKey>> configuredStructures = access.bcl_getConfiguredStructures(); - Map, Multimap, ResourceKey>> result = new HashMap<>(configuredStructures.size()); - - for (Map.Entry, ImmutableMultimap, ResourceKey>> entry : configuredStructures.entrySet()) { - result.put(entry.getKey(), HashMultimap.create(entry.getValue())); - } - - return result; - } - - //inspired by net.fabricmc.fabric.impl.biome.modification.BiomeStructureStartsImpl - private static void setMutableConfiguredStructures(StructureSettingsAccessor access, Map, Multimap, ResourceKey>> structureStarts) { - access.bcl_setConfiguredStructures( - structureStarts - .entrySet() - .stream() - .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, e -> ImmutableMultimap.copyOf(e.getValue()))) - ); - } - - private static Map, StructureFeatureConfiguration> getMutableStructureConfig(StructureSettingsAccessor access) { - return CollectionsUtil.getMutable(access.bcl_getStructureConfig()); - } - - private static void setMutableStructureConfig(StructureSettingsAccessor access, Map, StructureFeatureConfiguration> structureConfig) { - access.bcl_setStructureConfig(structureConfig); - } } diff --git a/src/main/java/ru/bclib/api/tag/TagAPI.java b/src/main/java/ru/bclib/api/tag/TagAPI.java index 3c055087..126a8b7e 100644 --- a/src/main/java/ru/bclib/api/tag/TagAPI.java +++ b/src/main/java/ru/bclib/api/tag/TagAPI.java @@ -2,21 +2,20 @@ package ru.bclib.api.tag; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import net.fabricmc.fabric.api.tag.TagFactory; -import net.fabricmc.fabric.impl.tag.extension.TagDelegate; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.tags.Tag; -import net.minecraft.tags.Tag.Named; -import net.minecraft.tags.TagCollection; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import ru.bclib.mixin.common.DiggerItemAccessor; import java.util.List; import java.util.Map; @@ -29,44 +28,44 @@ public class TagAPI { private static final Map> TAGS_ITEM = Maps.newConcurrentMap(); /** - * Get or create {@link Tag.Named}. + * Get or create {@link TagNamed}. * * @param containerSupplier - {@link TagCollection} {@link Supplier} tag collection; * @param id - {@link ResourceLocation} tag id. - * @return {@link Tag.Named}. + * @return {@link TagNamed}. */ public static TagNamed makeTag(Supplier> containerSupplier, TagLocation id) { Tag tag = containerSupplier.get().getTag(id); - return tag == null ? new Delegate<>(id, containerSupplier) : CommonDelegate.proxy((Named) tag); + return tag == null ? new Delegate<>(id, containerSupplier) : CommonDelegate.proxy((TagKey) tag); } /** - * Get or create {@link Block} {@link Tag.Named} with mod namespace. + * Get or create {@link Block} {@link TagNamed} with mod namespace. * * @param modID - {@link String} mod namespace (mod id); * @param name - {@link String} tag name. - * @return {@link Block} {@link Tag.Named}. + * @return {@link Block} {@link TagNamed}. */ public static TagNamed makeBlockTag(String modID, String name) { return makeTag(BlockTags::getAllTags, new TagLocation<>(modID, name)); } /** - * Get or create {@link Item} {@link Tag.Named} with mod namespace. + * Get or create {@link Item} {@link TagNamed} with mod namespace. * * @param modID - {@link String} mod namespace (mod id); * @param name - {@link String} tag name. - * @return {@link Item} {@link Tag.Named}. + * @return {@link Item} {@link TagNamed}. */ public static TagNamed makeItemTag(String modID, String name) { return makeTag(ItemTags::getAllTags, new TagLocation<>(modID, name)); } /** - * Get or create {@link Block} {@link Tag.Named}. + * Get or create {@link Block} {@link TagNamed}. * * @param name - {@link String} tag name. - * @return {@link Block} {@link Tag.Named}. + * @return {@link Block} {@link TagNamed}. * @see Fabric Wiki (Tags) */ public static TagNamed makeCommonBlockTag(String name) { @@ -74,10 +73,10 @@ public class TagAPI { } /** - * Get or create {@link Item} {@link Tag.Named}. + * Get or create {@link Item} {@link TagNamed}. * * @param name - {@link String} tag name. - * @return {@link Item} {@link Tag.Named}. + * @return {@link Item} {@link TagNamed}. * @see Fabric Wiki (Tags) */ public static TagNamed makeCommonItemTag(String name) { @@ -85,16 +84,16 @@ public class TagAPI { } /** - * Get or create Minecraft {@link Block} {@link Tag.Named}. + * Get or create Minecraft {@link Block} {@link TagNamed}. * * @param name - {@link String} tag name. - * @return {@link Block} {@link Tag.Named}. + * @return {@link Block} {@link TagNamed}. */ @Deprecated(forRemoval = true) public static TagNamed getMCBlockTag(String name) { ResourceLocation id = new ResourceLocation(name); Tag tag = BlockTags.getAllTags().getTag(id); - return CommonDelegate.proxy(tag == null ? (Named) TagFactory.BLOCK.create(id): (Named) tag); + return CommonDelegate.proxy(tag == null ? (TagKey) TagFactory.BLOCK.create(id): (TagKey) tag); } /** @@ -217,11 +216,11 @@ public class TagAPI { } /** - * Extends {@link Tag.Named} to return a type safe {@link TagLocation}. This Type was introduced to + * Extends {@link TagNamed} to return a type safe {@link TagLocation}. This Type was introduced to * allow type-safe definition of Tags using their ResourceLocation. * @param The Type of the underlying {@link Tag} */ - public interface TagNamed extends Tag.Named{ + public interface TagNamed extends TagKey{ TagLocation getName(); } @@ -243,18 +242,18 @@ public class TagAPI { super(location.getNamespace(), location.getPath()); } - public static TagLocation of(Tag.Named tag){ + public static TagLocation of(TagKey tag){ return new TagLocation(tag.getName()); } } private abstract static class CommonDelegate implements TagNamed { - protected final Tag.Named delegate; - protected CommonDelegate(Tag.Named source){ + protected final TagKey delegate; + protected CommonDelegate(TagKey source){ this.delegate = source; } - public static TagNamed proxy(Tag.Named source){ + public static TagNamed proxy(TagKey source){ if (source instanceof TagNamed typed) return typed; return new ProxyDelegate<>(source); } @@ -298,4 +297,11 @@ public class TagAPI { return (TagLocation)delegate.getName(); } } + + public static boolean isToolWithMineableTag(ItemStack stack, TagLocation tag){ + if (stack.getItem() instanceof DiggerItemAccessor dig){ + return dig.bclib_getBlockTag().location().equals(tag); + } + return false; + } } diff --git a/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java b/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java index 7c80d49e..02ae6b35 100644 --- a/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java @@ -2,7 +2,6 @@ package ru.bclib.blocks; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -45,7 +44,8 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R public BaseDoublePlantBlock() { this( FabricBlockSettings.of(Material.PLANT) - .breakByHand(true) + //TODO: 1.18.2 make sure this works with the new tag system + //.breakByHand(true) .sound(SoundType.GRASS) .noCollission() ); diff --git a/src/main/java/ru/bclib/blocks/BaseOreBlock.java b/src/main/java/ru/bclib/blocks/BaseOreBlock.java index abe61807..8b0573bf 100644 --- a/src/main/java/ru/bclib/blocks/BaseOreBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseOreBlock.java @@ -1,8 +1,6 @@ package ru.bclib.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.fabricmc.fabric.impl.object.builder.FabricBlockInternals; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -60,7 +58,8 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider { } private static Properties makeProps(Properties properties, int level){ - FabricBlockInternals.computeExtraData(properties).addMiningLevel(FabricToolTags.PICKAXES, level); + //TODO: 1.18.2 make sure this works with the new tag system + //FabricBlockInternals.computeExtraData(properties).addMiningLevel(FabricToolTags.PICKAXES, level); return properties; } diff --git a/src/main/java/ru/bclib/blocks/BasePlantBlock.java b/src/main/java/ru/bclib/blocks/BasePlantBlock.java index e469ccd7..eaffbcdc 100644 --- a/src/main/java/ru/bclib/blocks/BasePlantBlock.java +++ b/src/main/java/ru/bclib/blocks/BasePlantBlock.java @@ -4,7 +4,6 @@ import com.google.common.collect.Lists; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -60,7 +59,8 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL this( FabricBlockSettings .of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT) - .breakByHand(true) + //TODO: 1.18.2 make sure this works with the new tag system + //.breakByHand(true) .sound(SoundType.GRASS) .noCollission() ); diff --git a/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java b/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java index 28127de4..84864803 100644 --- a/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java @@ -1,7 +1,6 @@ package ru.bclib.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; @@ -15,6 +14,8 @@ import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.BlockHitResult; +import ru.bclib.api.tag.NamedMineableTags; +import ru.bclib.api.tag.TagAPI; public class BaseStripableLogBlock extends BaseRotatedPillarBlock { private final Block striped; @@ -27,7 +28,9 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock { @Override @SuppressWarnings("deprecation") public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { + //TODO: 1.18.2 check + if (TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.AXE)){ + //if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlock(pos, diff --git a/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java b/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java index 96b77c0e..aa98e969 100644 --- a/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java @@ -3,8 +3,8 @@ package ru.bclib.blocks; import com.google.common.collect.Maps; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.core.BlockPos; @@ -33,6 +33,8 @@ import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.Nullable; +import ru.bclib.api.tag.NamedMineableTags; +import ru.bclib.api.tag.TagAPI; import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; @@ -69,7 +71,9 @@ public class BaseTerrainBlock extends BaseBlock { @Override public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (pathBlock != null && FabricToolTags.SHOVELS.contains(player.getMainHandItem().getItem())) { + //TODO: 1.18.2 check + if (pathBlock != null && TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.SHOVEL)){ + //if (pathBlock != null && FabricTagProvider.SHOVELS.contains(player.getMainHandItem().getItem())) { world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlockAndUpdate(pos, pathBlock.defaultBlockState()); diff --git a/src/main/java/ru/bclib/blocks/BaseVineBlock.java b/src/main/java/ru/bclib/blocks/BaseVineBlock.java index 6e156b43..2b36688c 100644 --- a/src/main/java/ru/bclib/blocks/BaseVineBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseVineBlock.java @@ -2,7 +2,6 @@ package ru.bclib.blocks; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -53,7 +52,8 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid this( FabricBlockSettings .of(Material.PLANT) - .breakByHand(true) + //TODO: 1.18.2 make sure this works with the new tag system + //.breakByHand(true) .sound(SoundType.GRASS) .lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light) .noCollission() diff --git a/src/main/java/ru/bclib/blocks/StripableBarkBlock.java b/src/main/java/ru/bclib/blocks/StripableBarkBlock.java index 328c6f1d..9118f66b 100644 --- a/src/main/java/ru/bclib/blocks/StripableBarkBlock.java +++ b/src/main/java/ru/bclib/blocks/StripableBarkBlock.java @@ -1,7 +1,6 @@ package ru.bclib.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; @@ -15,6 +14,8 @@ import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.BlockHitResult; +import ru.bclib.api.tag.NamedMineableTags; +import ru.bclib.api.tag.TagAPI; public class StripableBarkBlock extends BaseBarkBlock { private final Block striped; @@ -27,7 +28,9 @@ public class StripableBarkBlock extends BaseBarkBlock { @Override @SuppressWarnings("deprecation") public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { + //TODO: 1.18.2 check + if (TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.AXE)){ + //if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlock(pos, diff --git a/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java b/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java index 486b96ac..5f71bf5d 100644 --- a/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java +++ b/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java @@ -2,7 +2,6 @@ package ru.bclib.blocks; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -47,7 +46,8 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R this( FabricBlockSettings .of(Material.WATER_PLANT) - .breakByHand(true) + //TODO: 1.18.2 make sure this works with the new tag system + //.breakByHand(true) .sound(SoundType.WET_GRASS) .noCollission() ); diff --git a/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java b/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java index f58e5526..9fdfe7e6 100644 --- a/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java +++ b/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java @@ -2,7 +2,6 @@ package ru.bclib.blocks; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; @@ -39,7 +38,8 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements Rende public UpDownPlantBlock() { this(FabricBlockSettings .of(Material.PLANT) - .breakByHand(true) + //TODO: 1.18.2 make sure this works with the new tag system + //.breakByHand(true) .sound(SoundType.GRASS) .noCollission() ); diff --git a/src/main/java/ru/bclib/complexmaterials/ComplexMaterial.java b/src/main/java/ru/bclib/complexmaterials/ComplexMaterial.java index 022e5eaf..1684c162 100644 --- a/src/main/java/ru/bclib/complexmaterials/ComplexMaterial.java +++ b/src/main/java/ru/bclib/complexmaterials/ComplexMaterial.java @@ -7,6 +7,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.Tag; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.Nullable; @@ -32,8 +33,8 @@ public abstract class ComplexMaterial { private final List defaultBlockEntries = Lists.newArrayList(); private final List defaultItemEntries = Lists.newArrayList(); - private final Map> blockTags = Maps.newHashMap(); - private final Map> itemTags = Maps.newHashMap(); + private final Map> blockTags = Maps.newHashMap(); + private final Map> itemTags = Maps.newHashMap(); private final Map blocks = Maps.newHashMap(); private final Map items = Maps.newHashMap(); diff --git a/src/main/java/ru/bclib/integration/ModIntegration.java b/src/main/java/ru/bclib/integration/ModIntegration.java index e1d93576..ddfb76a6 100644 --- a/src/main/java/ru/bclib/integration/ModIntegration.java +++ b/src/main/java/ru/bclib/integration/ModIntegration.java @@ -1,6 +1,5 @@ package ru.bclib.integration; -import net.fabricmc.fabric.api.tag.TagFactory; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.Registry; import net.minecraft.data.BuiltinRegistries; @@ -9,7 +8,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.Tag; -import net.minecraft.tags.Tag.Named; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; @@ -197,18 +196,18 @@ public abstract class ModIntegration { return null; } - public Tag.Named getItemTag(String name) { + public TagKey getItemTag(String name) { ResourceLocation id = getID(name); Tag tag = ItemTags.getAllTags().getTag(id); - //return tag == null ? (Named) TagRegistry.item(id) : (Named) tag; - return tag == null ? (Named) TagFactory.ITEM.create(id) : (Named) tag; + //return tag == null ? (TagKey) TagRegistry.item(id) : (TagKey) tag; + return tag == null ? (TagKey) TagFactory.ITEM.create(id) : (TagKey) tag; } - public Tag.Named getBlockTag(String name) { + public TagKey getBlockTag(String name) { ResourceLocation id = getID(name); Tag tag = BlockTags.getAllTags().getTag(id); //return tag == null ? (Named) TagRegistry.block(id) : (Named) tag; - return tag == null ? (Named) TagFactory.BLOCK.create(id) : (Named) tag; + return tag == null ? (TagKey) TagFactory.BLOCK.create(id) : (TagKey) tag; } } diff --git a/src/main/java/ru/bclib/interfaces/ChunkGeneratorAccessor.java b/src/main/java/ru/bclib/interfaces/ChunkGeneratorAccessor.java new file mode 100644 index 00000000..cb20ad10 --- /dev/null +++ b/src/main/java/ru/bclib/interfaces/ChunkGeneratorAccessor.java @@ -0,0 +1,8 @@ +package ru.bclib.interfaces; + +import net.minecraft.core.Registry; +import net.minecraft.world.level.levelgen.structure.StructureSet; + +public interface ChunkGeneratorAccessor { + Registry bclib_getStructureSetsRegistry(); +} diff --git a/src/main/java/ru/bclib/mixin/client/SimpleReloadableResourceManagerMixin.java b/src/main/java/ru/bclib/mixin/client/SimpleReloadableResourceManagerMixin.java index ed209646..594d71f2 100644 --- a/src/main/java/ru/bclib/mixin/client/SimpleReloadableResourceManagerMixin.java +++ b/src/main/java/ru/bclib/mixin/client/SimpleReloadableResourceManagerMixin.java @@ -4,7 +4,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.FallbackResourceManager; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; -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; @@ -18,36 +17,37 @@ import ru.bclib.client.render.EmissiveTextureInfo; import java.io.IOException; import java.util.Map; -@Mixin(SimpleReloadableResourceManager.class) -public class SimpleReloadableResourceManagerMixin { - @Final - @Shadow - private Map namespacedPacks; - - private ResourceLocation bclib_alphaEmissionMaterial = BCLib.makeID("materialmaps/block/alpha_emission.json"); - - @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) - private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable info) throws IOException { - if (!ModIntegrationAPI.hasCanvas()) { - return; - } - if (!resourceLocation.getPath().startsWith("materialmaps")) { - return; - } - if (!resourceLocation.getPath().contains("/block/")) { - return; - } - - String name = resourceLocation.getPath().replace("materialmaps/block/", "").replace(".json", ""); - ResourceLocation blockID = new ResourceLocation(resourceLocation.getNamespace(), name); - - if (!EmissiveTextureInfo.isEmissiveBlock(blockID)) { - return; - } - - ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace()); - if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) { - info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial)); - } - } -} +//TODO: 1.18.2 Disabled to have a compilable Version +//@Mixin(SimpleReloadableResourceManager.class) +//public class SimpleReloadableResourceManagerMixin { +// @Final +// @Shadow +// private Map namespacedPacks; +// +// private ResourceLocation bclib_alphaEmissionMaterial = BCLib.makeID("materialmaps/block/alpha_emission.json"); +// +// @Inject(method = "getResource", at = @At("HEAD"), cancellable = true) +// private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable info) throws IOException { +// if (!ModIntegrationAPI.hasCanvas()) { +// return; +// } +// if (!resourceLocation.getPath().startsWith("materialmaps")) { +// return; +// } +// if (!resourceLocation.getPath().contains("/block/")) { +// return; +// } +// +// String name = resourceLocation.getPath().replace("materialmaps/block/", "").replace(".json", ""); +// ResourceLocation blockID = new ResourceLocation(resourceLocation.getNamespace(), name); +// +// if (!EmissiveTextureInfo.isEmissiveBlock(blockID)) { +// return; +// } +// +// ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace()); +// if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) { +// info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial)); +// } +// } +//} diff --git a/src/main/java/ru/bclib/mixin/common/BiomeGenerationSettingsAccessor.java b/src/main/java/ru/bclib/mixin/common/BiomeGenerationSettingsAccessor.java index fcb6ec6f..92e3d099 100644 --- a/src/main/java/ru/bclib/mixin/common/BiomeGenerationSettingsAccessor.java +++ b/src/main/java/ru/bclib/mixin/common/BiomeGenerationSettingsAccessor.java @@ -24,10 +24,10 @@ public interface BiomeGenerationSettingsAccessor { void bclib_setFeatures(List>> value); @Accessor("featureSet") - Set bclib_getFeatureSet(); + Supplier> bclib_getFeatureSet(); @Accessor("featureSet") - void bclib_setFeatureSet(Set features); + void bclib_setFeatureSet(Supplier> features); @Accessor("carvers") Map>>> bclib_getCarvers(); diff --git a/src/main/java/ru/bclib/mixin/common/ChunkGeneratorMixin.java b/src/main/java/ru/bclib/mixin/common/ChunkGeneratorMixin.java index 9c6058ac..c72d2676 100644 --- a/src/main/java/ru/bclib/mixin/common/ChunkGeneratorMixin.java +++ b/src/main/java/ru/bclib/mixin/common/ChunkGeneratorMixin.java @@ -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 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 bclib_getStructureSetsRegistry(){ + return structureSets; + } } diff --git a/src/main/java/ru/bclib/mixin/common/DiggerItemAccessor.java b/src/main/java/ru/bclib/mixin/common/DiggerItemAccessor.java new file mode 100644 index 00000000..8102ce94 --- /dev/null +++ b/src/main/java/ru/bclib/mixin/common/DiggerItemAccessor.java @@ -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 bclib_getBlockTag(); +} diff --git a/src/main/java/ru/bclib/mixin/common/SimpleReloadableResourceManagerMixin.java b/src/main/java/ru/bclib/mixin/common/SimpleReloadableResourceManagerMixin.java index d2ff94df..3b78fdbc 100644 --- a/src/main/java/ru/bclib/mixin/common/SimpleReloadableResourceManagerMixin.java +++ b/src/main/java/ru/bclib/mixin/common/SimpleReloadableResourceManagerMixin.java @@ -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 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 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 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 info) { +// if (resourceLocation.getNamespace().equals("minecraft")) { +// for (String key: BCLIB_MISSING_RESOURCES) { +// if (resourceLocation.getPath().equals(key)) { +// info.setReturnValue(false); +// return; +// } +// } +// } +// } +//} diff --git a/src/main/java/ru/bclib/mixin/common/StructureSettingsAccessor.java b/src/main/java/ru/bclib/mixin/common/StructureSettingsAccessor.java deleted file mode 100644 index bd3dc67a..00000000 --- a/src/main/java/ru/bclib/mixin/common/StructureSettingsAccessor.java +++ /dev/null @@ -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, ImmutableMultimap, ResourceKey>> bcl_getConfiguredStructures(); - - @Accessor("structureConfig") - Map, StructureFeatureConfiguration> bcl_getStructureConfig(); - - @Accessor("configuredStructures") - @Mutable - void bcl_setConfiguredStructures(ImmutableMap, ImmutableMultimap, ResourceKey>> configuredStructures); - - @Accessor("structureConfig") - @Mutable - void bcl_setStructureConfig(Map, StructureFeatureConfiguration> structureConfig); -} diff --git a/src/main/java/ru/bclib/mixin/common/SurfaceRulesContextAccessor.java b/src/main/java/ru/bclib/mixin/common/SurfaceRulesContextAccessor.java index b1bd7a6b..2e2e93be 100644 --- a/src/main/java/ru/bclib/mixin/common/SurfaceRulesContextAccessor.java +++ b/src/main/java/ru/bclib/mixin/common/SurfaceRulesContextAccessor.java @@ -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 getBiome(); - - @Accessor("biomeKey") - Supplier> getBiomeKey(); + Supplier> getBiome(); @Accessor("chunk") ChunkAccess getChunk(); diff --git a/src/main/resources/bclib.mixins.common.json b/src/main/resources/bclib.mixins.common.json index 98e434cd..7c96df98 100644 --- a/src/main/resources/bclib.mixins.common.json +++ b/src/main/resources/bclib.mixins.common.json @@ -13,7 +13,6 @@ "NoiseGeneratorSettingsMixin", "SurfaceRulesContextAccessor", "shears.TripWireBlockMixin", - "StructureSettingsAccessor", "MobSpawnSettingsAccessor", "shears.BeehiveBlockMixin", "shears.PumpkinBlockMixin", @@ -21,6 +20,7 @@ "ComposterBlockAccessor", "PotionBrewingAccessor", "RecipeManagerAccessor", + "DiggerItemAccessor", "shears.SnowGolemMixin", "EnchantmentMenuMixin", "MinecraftServerMixin",