From da176b0e246172ccbc764f87c452c95e1f516621 Mon Sep 17 00:00:00 2001 From: Meredith Espinosa Date: Fri, 26 Jun 2020 16:01:16 -0700 Subject: [PATCH] fix unapplied mixin --- build.gradle | 2 +- modules/cotton-commons/build.gradle | 2 +- .../cottonmc/cotton/commons/CommonTags.java | 26 +++++++++---------- modules/cotton-datapack/build.gradle | 2 +- .../datapack/mixins/MixinDataPackLoad.java | 13 +++++----- .../mixins/ResourcePackManagerAccessor.java | 14 ++++++++++ .../resources/mixins.cotton-datapack.json | 3 ++- 7 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/ResourcePackManagerAccessor.java diff --git a/build.gradle b/build.gradle index 525b28b..ac05923 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ def yarnMappings = "1.16.1+build.9:v2" def loaderVersion = "0.8.8+build.202" archivesBaseName = "cotton" -version = "1.0.4" +version = "1.0.5" group = "io.github.cottonmc.cotton" sourceCompatibility = 1.8 diff --git a/modules/cotton-commons/build.gradle b/modules/cotton-commons/build.gradle index b955424..35d84df 100644 --- a/modules/cotton-commons/build.gradle +++ b/modules/cotton-commons/build.gradle @@ -10,7 +10,7 @@ ext { ]; } -version = "1.0.0-rc.4"; +version = "1.0.4"; apply from: "../module-base.gradle" diff --git a/modules/cotton-commons/src/main/java/io/github/cottonmc/cotton/commons/CommonTags.java b/modules/cotton-commons/src/main/java/io/github/cottonmc/cotton/commons/CommonTags.java index af65fe2..3d4289b 100644 --- a/modules/cotton-commons/src/main/java/io/github/cottonmc/cotton/commons/CommonTags.java +++ b/modules/cotton-commons/src/main/java/io/github/cottonmc/cotton/commons/CommonTags.java @@ -16,19 +16,19 @@ public class CommonTags { //auto-fillable tags for common decorative/functional blocks - public static final Tag GLASS_BLOCKS = registerItemTag("glass_blocks"); - public static final Tag GLASS_PANES = registerItemTag("glass_panes"); - public static final Tag TERRACOTTA = registerItemTag("terracotta"); - public static final Tag PRESSURE_PLATES = registerItemTag("pressure_plates"); + public static final Tag.Identified GLASS_BLOCKS = registerItemTag("glass_blocks"); + public static final Tag.Identified GLASS_PANES = registerItemTag("glass_panes"); + public static final Tag.Identified TERRACOTTA = registerItemTag("terracotta"); + public static final Tag.Identified PRESSURE_PLATES = registerItemTag("pressure_plates"); //tags for common item categories - public static final Tag MUSHROOMS = registerItemTag("mushrooms"); - public static final Tag RAW_MEAT = registerItemTag("raw_meat"); - public static final Tag COOKED_MEAT = registerItemTag("cooked_meat"); - public static final Tag PLANTABLES = registerItemTag("plantables"); + public static final Tag.Identified MUSHROOMS = registerItemTag("mushrooms"); + public static final Tag.Identified RAW_MEAT = registerItemTag("raw_meat"); + public static final Tag.Identified COOKED_MEAT = registerItemTag("cooked_meat"); + public static final Tag.Identified PLANTABLES = registerItemTag("plantables"); //taggs for cotton functions - public static final Tag CAULDRON_FIRE = TagRegistry.block(new Identifier(CottonCommons.MODID, "cauldron_fire")); + public static final Tag.Identified CAULDRON_FIRE = (Tag.Identified)TagRegistry.block(new Identifier(CottonCommons.MODID, "cauldron_fire")); public static void init() { if (CottonCommons.CONFIG.fillCommonTags) { @@ -56,11 +56,11 @@ public static void init() { } } - private static Tag registerItemTag(String id) { - return TagRegistry.item(new Identifier(CottonDatapack.SHARED_NAMESPACE, id)); + private static Tag.Identified registerItemTag(String id) { + return (Tag.Identified)TagRegistry.item(new Identifier(CottonDatapack.SHARED_NAMESPACE, id)); } - private static Tag registerBlockTag(String id) { - return TagRegistry.block(new Identifier(CottonDatapack.SHARED_NAMESPACE, id)); + private static Tag.Identified registerBlockTag(String id) { + return (Tag.Identified)TagRegistry.block(new Identifier(CottonDatapack.SHARED_NAMESPACE, id)); } } diff --git a/modules/cotton-datapack/build.gradle b/modules/cotton-datapack/build.gradle index 3cd3325..eee778c 100644 --- a/modules/cotton-datapack/build.gradle +++ b/modules/cotton-datapack/build.gradle @@ -10,7 +10,7 @@ ext { ]; } -version = "1.0.4"; +version = "1.0.5"; apply from: "../module-base.gradle" dependencies { diff --git a/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/MixinDataPackLoad.java b/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/MixinDataPackLoad.java index c9c4175..d9ffe6c 100644 --- a/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/MixinDataPackLoad.java +++ b/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/MixinDataPackLoad.java @@ -2,6 +2,7 @@ import io.github.cottonmc.cotton.datapack.GlobalResourcePackProvider; import io.github.cottonmc.cotton.datapack.virtual.VirtualResourcePackManager; +import net.minecraft.resource.DataPackSettings; import net.minecraft.resource.ResourcePackManager; import net.minecraft.resource.ResourcePackProfile; import net.minecraft.resource.ResourceType; @@ -13,19 +14,17 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.io.File; @Mixin(MinecraftServer.class) public class MixinDataPackLoad { - @Shadow - @Final - private ResourcePackManager dataPackManager; - @Inject(method = "loadWorldDataPacks", at = @At(value = "HEAD")) - public void addGlobalDataPacks(File file, LevelProperties properties, CallbackInfo info) { - dataPackManager.registerProvider(new GlobalResourcePackProvider()); - dataPackManager.registerProvider(VirtualResourcePackManager.INSTANCE.getCreatorForType(ResourceType.SERVER_DATA)); + @Inject(method = "loadDataPacks", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;setEnabledProfiles(Ljava/util/Collection;)V")) + private static void addGlobalDataPacks(ResourcePackManager resourcePackManager, DataPackSettings dataPackSettings, boolean safeMode, CallbackInfoReturnable info) { + ((ResourcePackManagerAccessor)resourcePackManager).getProviders().add(new GlobalResourcePackProvider()); + ((ResourcePackManagerAccessor)resourcePackManager).getProviders().add(VirtualResourcePackManager.INSTANCE.getCreatorForType(ResourceType.SERVER_DATA)); } } \ No newline at end of file diff --git a/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/ResourcePackManagerAccessor.java b/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/ResourcePackManagerAccessor.java new file mode 100644 index 0000000..fc52082 --- /dev/null +++ b/modules/cotton-datapack/src/main/java/io/github/cottonmc/cotton/datapack/mixins/ResourcePackManagerAccessor.java @@ -0,0 +1,14 @@ +package io.github.cottonmc.cotton.datapack.mixins; + +import net.minecraft.resource.ResourcePackManager; +import net.minecraft.resource.ResourcePackProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Set; + +@Mixin(ResourcePackManager.class) +public interface ResourcePackManagerAccessor { + @Accessor + Set getProviders(); +} diff --git a/modules/cotton-datapack/src/main/resources/mixins.cotton-datapack.json b/modules/cotton-datapack/src/main/resources/mixins.cotton-datapack.json index c3e9fa3..584d69f 100644 --- a/modules/cotton-datapack/src/main/resources/mixins.cotton-datapack.json +++ b/modules/cotton-datapack/src/main/resources/mixins.cotton-datapack.json @@ -5,7 +5,8 @@ "refmap": "mixins.cotton-datapack.refmap.json", "mixins": [ "MixinDataPackLoad", - "MixinRecipeManager" + "MixinRecipeManager", + "ResourcePackManagerAccessor" ], "client": [ "MixinClientBuiltinResourcePackProvider"