From 2afceb2962776210c1aa231f18b62cece5831d99 Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Sat, 21 May 2022 03:17:28 +1000 Subject: [PATCH 01/15] Allow Built in Resource Packs to have custom names (#1827) * TooltipComponent API (#1695) * TooltipComponent API * Add warning * Fix handling of orphaned registry entries (#1759) * Fix handling of orphaned registry entries * Fix handling of orphaned registry entries in RegistrySyncManager * Transfer API: bugfixes and improvements (#1762) * Fix SingleVariantItemStorage extraction bug * Inventory wrappers: reuse the original stack more aggressively * Add some filtered overloads to StorageUtil methods * Override PlayerInventoryStorage#insert to call #offer * Add small comment regarding predicates * Bump version * Fix refamp generation for gametest API. Fixes #1722 * Bump version. * Add two more sleep events (#1755) * Add event for setting bed occupation state * Add wake up pos event and update tests * Bump version Just in case. I have a bad feeling that this could become a patch version otherwise. * Add code tags for true/false/null in EntitySleepEvents jd * Add Dynamic annotations for lambda body mixins * Update class javadoc to contain the new events * Bump version * Fix Registry.GAME_EVENT not being synced. * Updated mappings to yarn 1.17.1+build.63 (#1786) * Updated mappings to yarn 1.17.1+build.63 * Forgot some bits. * Forgot to reeable * Make biome & dimension api stable. And change usage around @Deprecated (#1783) * Make biome & dimension api stable (for 1.17). Remove the usage of @Deprecated for other experimental modules. The @Deprecated should be used for experimental/volatile APIs that are highly likely to change. * Apply suggestions from code review Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * ItemGroup API: Remove return and call super so all others ItemStack's get appended (#1617) * Remove return and call super so all others ItemStack's get appended * Add method to FabricItemGroupBuilder to pass ItemGroup with appendItems and change stacksForDisplay to a BiConsumer * Update ItemGroupBuilder javadoc and add example to testmod * Remove leftover aw * Update fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/api/client/itemgroup/FabricItemGroupBuilder.java Co-authored-by: liach <7806504+liach@users.noreply.github.com> * Update fabric-item-groups-v0/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com> * Remove used import in ItemGroupTest * Clean up * Fix damn checkstyle * Change version to 0.3.0 Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com> * Bump version * Add tag-based mining level API, fix and deprecate FabricBlockSettings.breakByTool (#1629) * Mining Level API, part 1 * Fix incorrect netherite mining level in MiningLevelManager docs * Add some format checks in dynamic mining level tag checking * Add mining level API test mod * Grammar * Add cursed basic support for the tool attribute api * Fix tool attribute JD * Add proper compat for tool attribute api Also fixes the remaining bugs in it! * Update license headers * stuff * better comments * more test mod work * more * Fix test mod * i'm done with this module * Address some code review things * Use Reference2IntMap (basically IdentityHashMap for int values) * Prefix mixin handlers with fabric$ * Add missing license header * Update fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java * Resolve liach's comment * Update to use TagFactory * Add event phases (#1669) * Proof of concept * Simplify and document * Allow events to be registered with default phases * Use modified Kosaraju for the toposort, and add test for cyclic dependency graphs * Separate phase-related functionality in an EventPhase class * Revert "Separate phase-related functionality in an EventPhase class" This reverts commit e433f348f4d3d056e6c5ccf1802d11103e3fe961. * Ensure that the phase order is deterministic * Add pretty graphs * Add a test, fix a bug, only do one sort for every constraint registration * Environmental renderers (#1727) * Environmental Renderers * Remove defunt hideClouds and hideWeather * Pushed missing License * Push checkstyle fixes * remove unused * Unwrapped the test mod sky rendering. * Added a first attempt at javadoc. * Forgot a blank line * Moved Environment references out of class * Moved Lamda functions for fog override, thick fog usage and fog color adjustment to their own interfaces and gave them proper javadoc. * Made FabricSkyProperties private * PURGE THE H...I mean FabricSkyPropertyBuilder and FabricSkyProperties. - Reverted unintentional mixin changes - Fix various typo errors that were pointed out. - Added missing javadocs and added the ability to override. * Forgot some pluggin in some overrides. * Added missing javadoc suggestion * Changed api a bit so that it fires a exception if renderer not being overridden and one already exists. * Split Implemtnation and Interface * Forgot a license * Added WorldRenderContext to Renderers * Added logging * Added missing javadocs and removed the override option. * Removed INSTANCE * Environmental Renderers * Remove defunt hideClouds and hideWeather * Pushed missing License * Push checkstyle fixes * remove unused * Unwrapped the test mod sky rendering. * Added a first attempt at javadoc. * Forgot a blank line * Moved Environment references out of class * Moved Lamda functions for fog override, thick fog usage and fog color adjustment to their own interfaces and gave them proper javadoc. * Made FabricSkyProperties private * PURGE THE H...I mean FabricSkyPropertyBuilder and FabricSkyProperties. - Reverted unintentional mixin changes - Fix various typo errors that were pointed out. - Added missing javadocs and added the ability to override. * Forgot some pluggin in some overrides. * Added missing javadoc suggestion * Changed api a bit so that it fires a exception if renderer not being overridden and one already exists. * Split Implemtnation and Interface * Forgot a license * Added WorldRenderContext to Renderers * Added logging * Added missing javadocs and removed the override option. * Removed INSTANCE * Fixed Issues * Fixed formatting issue. * completed Juuxl's suggestions and removed null check on adding skyproperties. Changed SkyProperties registering to take an Identifier. Registration turns out to be only adding new options to the "effects" entry of dimension type jsonjson. * Forgot to reenable this. * Just did suggested tweaks * Changed SkyProperties to DimensionEffects * Pushed suggestions of Haykam and apple502j * Added missing changes from sky properties to dimension effects. * Corrected me being inconsistent. * Forgot to remove import. * Impliments https://github.com/FabricMC/fabric/pull/1727#discussion_r734988305 https://github.com/FabricMC/fabric/pull/1727#discussion_r734988265 * Implements https://github.com/FabricMC/fabric/pull/1727#discussion_r730429748 * Last minute tweak. Runnable that controls fog runs right before dimension spefific rendering is done. Based on more subtle issues discovered while working api with twilight forest. Co-authored-by: AlphaMode * Another wave of transfer API improvements (#1801) * Another wave of transfer API improvements * Cleaner implementation of FilteringStorage#...Of * Undo colored name for water and lava variants * Custom fluid renderers and enhanced vanilla fluid renderer customization (#1687) * Implement custom fluid rendering * Move custom renderers in FluidRenderer mixin and add overlay sprite support to FluidRenderHandlers * Add vanilla-like fluid renderer. Maybe very unnecessary, might remove. * Optimize imports * Allow custom fluid renderers to call the default renderer. Re-add DEFAULT. * Add interface to implement by blocks that enforces overlay texture on fluids * Some comments * Simplify API and remove DefaultLikeFluidRenderer * Make simple renderer overlay texture nullable Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com> * Expand test mod * Checkstyle and licenses * Easy shortcut for custom colored vanilla water fluids * Easy way to register a renderer for two (still+flowing) fluids * Update fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/api/client/render/fluid/v1/FluidRenderHandlerRegistry.java Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * Update fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/fluid/MixinFluidRenderer.java Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com> Co-authored-by: modmuss50 Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * Bump versions All of the version need to be bumped due to fabric-api-base being updated, this highlights the need for a better solution. * Target the void world in the DimensionalRenderingTest It's a bit too obnoxious for the overworld. * Fix shears being the ultimate mining tool (#1809) * Add detail about default value to MiningLevelManager jd * Fix shears being the ultimate mining tool In more technical terms, fix an invalid comparison in TaggedToolsModdedBlocksToolHandler. The code was supposed to check if the tool's mining level was at least the block's minimum mining level. Instead, the check succeeded whenever the block required a tool (min level >= 0). * WIP fixing tool attribute api bugs * Fix mostly everything * Simplify to (== 0) with explanation * A less breaking workaround for https://github.com/FabricMC/fabric/issues/1806 (#1811) * A less breaking workaround for https://github.com/FabricMC/fabric/issues/1806 * Checkstyle * Bump version * Update Loom and Loader. Cleanup/improve buildscript. (#1802) Co-authored-by: shartte * Fix missing some chunk unloads events leading to a possible memory leak. (#1820) * Fix crash when loading resources from a UNC (windows) network share. See: https://bugs.openjdk.java.net/browse/JDK-8178726 * Update ResourceManagerHelper.java * Update ResourceManagerHelperImpl.java * Update ResourceManagerHelperImpl.java * attempt to get rid of trailing whitespace * works * Update the test mod * Split TestPack to check if unnamed packs still load and display correctly * update javadoc * bump testmod version * Update fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/ResourceManagerHelper.java Co-authored-by: LambdAurora * Use modid in description * Add lang Co-Authored-By: LambdAurora * Update fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * Fix optional server resource loading * small changes and adhere to checkstyle * Remove ResourcePackProfileAccessor from mixin json * bump pack_format Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com> Co-authored-by: BasiqueEvangelist Co-authored-by: modmuss50 Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> Co-authored-by: Waterpicker Co-authored-by: AlphaMode Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: Shadew <11669132+FoxShadew@users.noreply.github.com> Co-authored-by: shartte Co-authored-by: LambdAurora Co-authored-by: LambdAurora Co-authored-by: deirn --- .../api/resource/ResourceManagerHelper.java | 21 ++++++++++++++ .../loader/BuiltinModResourcePackSource.java} | 24 ++++++++++------ .../loader/ResourceManagerHelperImpl.java | 27 +++++++++++++++--- .../resource/loader/MinecraftServerMixin.java | 6 ++-- .../fabric-resource-loader-v0/lang/en_us.json | 5 ++-- .../fabric-resource-loader-v0/lang/fr_ca.json | 3 ++ .../fabric-resource-loader-v0/lang/fr_fr.json | 3 ++ .../fabric-resource-loader-v0.mixins.json | 1 - .../loader/BuiltinResourcePackTestMod.java | 4 +++ .../resources/resourcepacks/test/pack.mcmeta | 2 +- .../data/minecraft/tags/blocks/climbable.json | 0 .../resources/resourcepacks/test2/pack.mcmeta | 6 ++++ .../resources/resourcepacks/test2/pack.png | Bin 0 -> 1579 bytes 13 files changed, 82 insertions(+), 20 deletions(-) rename fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/{mixin/resource/loader/ResourcePackProfileAccessor.java => impl/resource/loader/BuiltinModResourcePackSource.java} (55%) create mode 100644 fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_ca.json create mode 100644 fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_fr.json rename fabric-resource-loader-v0/src/testmod/resources/resourcepacks/{test => test2}/data/minecraft/tags/blocks/climbable.json (100%) create mode 100644 fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.mcmeta create mode 100644 fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.png diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/ResourceManagerHelper.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/ResourceManagerHelper.java index b74589da49..016aebb662 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/ResourceManagerHelper.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/ResourceManagerHelper.java @@ -75,6 +75,27 @@ static boolean registerBuiltinResourcePack(Identifier id, ModContainer container return ResourceManagerHelperImpl.registerBuiltinResourcePack(id, "resourcepacks/" + id.getPath(), container, activationType); } + /** + * Registers a built-in resource pack. + * + *

A built-in resource pack is an extra resource pack provided by your mod which is not always active, it's similar to the "Programmer Art" resource pack. + * + *

Why and when to use it? A built-in resource pack should be used to provide extra assets/data that should be optional with your mod but still directly provided by it. + * For example it could provide textures of your mod in another resolution, or could allow to provide different styles of your assets. + * + *

The path in which the resource pack is located is in the mod JAR file under the {@code "resourcepacks/"} directory. {@code id path} being the path specified + * in the identifier of this built-in resource pack. + * + * @param id the identifier of the resource pack + * @param container the mod container + * @param displayName the display name of the resource pack, should include mod name for clarity + * @param activationType the activation type of the resource pack + * @return {@code true} if successfully registered the resource pack, else {@code false} + */ + static boolean registerBuiltinResourcePack(Identifier id, ModContainer container, String displayName, ResourcePackActivationType activationType) { + return ResourceManagerHelperImpl.registerBuiltinResourcePack(id, "resourcepacks/" + id.getPath(), container, displayName, activationType); + } + /** * Registers a built-in resource pack. * diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileAccessor.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java similarity index 55% rename from fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileAccessor.java rename to fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java index 0c3bbf4b08..42fcf77f81 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileAccessor.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java @@ -14,16 +14,22 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.resource.loader; +package net.fabricmc.fabric.impl.resource.loader; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.resource.ResourcePackProfile; import net.minecraft.resource.ResourcePackSource; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.Formatting; + +public class BuiltinModResourcePackSource implements ResourcePackSource { + private final String modId; + + public BuiltinModResourcePackSource(String modId) { + this.modId = modId; + } -@Mixin(ResourcePackProfile.class) -public interface ResourcePackProfileAccessor { - @Accessor("source") - ResourcePackSource getResourcePackSource(); + @Override + public Text decorate(Text packName) { + return new TranslatableText("pack.nameAndSource", packName, new TranslatableText("pack.source.builtinMod", modId)).formatted(Formatting.GRAY); + } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java index 373c9266af..ad71ee975e 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import net.minecraft.resource.ResourcePackProfile; -import net.minecraft.resource.ResourcePackSource; import net.minecraft.resource.ResourceReloader; import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; @@ -61,13 +60,17 @@ public static ResourceManagerHelperImpl get(ResourceType type) { * @param id the identifier of the resource pack * @param subPath the sub path in the mod resources * @param container the mod container + * @param displayName the display name of the resource pack * @param activationType the activation type of the resource pack * @return {@code true} if successfully registered the resource pack, else {@code false} + * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, String, ResourcePackActivationType) * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, ResourcePackActivationType) * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, String, ModContainer, boolean) */ - public static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, ResourcePackActivationType activationType) { - String name = id.getNamespace() + "/" + id.getPath(); + public static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, String displayName, ResourcePackActivationType activationType) { + String separator = container.getRootPath().getFileSystem().getSeparator(); + subPath = subPath.replace("/", separator); + String name = displayName; ModNioResourcePack resourcePack = ModNioResourcePack.create(name, container, subPath, ResourceType.CLIENT_RESOURCES, activationType); ModNioResourcePack dataPack = ModNioResourcePack.create(name, container, subPath, ResourceType.SERVER_DATA, activationType); if (resourcePack == null && dataPack == null) return false; @@ -83,6 +86,22 @@ public static boolean registerBuiltinResourcePack(Identifier id, String subPath, return true; } + /** + * Registers a built-in resource pack. Internal implementation. + * + * @param id the identifier of the resource pack + * @param subPath the sub path in the mod resources + * @param container the mod container + * @param activationType the activation type of the resource pack + * @return {@code true} if successfully registered the resource pack, else {@code false} + * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, ResourcePackActivationType) + * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, String, ResourcePackActivationType) + * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, String, ModContainer, boolean) + */ + public static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, ResourcePackActivationType activationType) { + return registerBuiltinResourcePack(id, subPath, container, id.getNamespace() + "/" + id.getPath(), activationType); + } + public static void registerBuiltinResourcePacks(ResourceType resourceType, Consumer consumer, ResourcePackProfile.Factory factory) { // Loop through each registered built-in resource packs and add them if valid. for (Pair entry : builtinResourcePacks) { @@ -93,7 +112,7 @@ public static void registerBuiltinResourcePacks(ResourceType resourceType, Consu // Make the resource pack profile for built-in pack, should never be always enabled. ResourcePackProfile profile = ResourcePackProfile.of(entry.getLeft(), pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED, - entry::getRight, factory, ResourcePackProfile.InsertionPosition.TOP, ResourcePackSource.PACK_SOURCE_BUILTIN); + entry::getRight, factory, ResourcePackProfile.InsertionPosition.TOP, new BuiltinModResourcePackSource(pack.getFabricModMetadata().getId())); if (profile != null) { consumer.accept(profile); } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MinecraftServerMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MinecraftServerMixin.java index 4643408951..fc079bf436 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MinecraftServerMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MinecraftServerMixin.java @@ -25,9 +25,9 @@ import net.minecraft.resource.ResourcePack; import net.minecraft.resource.ResourcePackManager; import net.minecraft.resource.ResourcePackProfile; -import net.minecraft.resource.ResourcePackSource; import net.minecraft.server.MinecraftServer; +import net.fabricmc.fabric.impl.resource.loader.BuiltinModResourcePackSource; import net.fabricmc.fabric.impl.resource.loader.ModNioResourcePack; @Mixin(MinecraftServer.class) @@ -43,10 +43,10 @@ private static boolean onCheckDisabled(List list, Object o, ResourcePack ResourcePackProfile profile = resourcePackManager.getProfile(profileName); - if (((ResourcePackProfileAccessor) profile).getResourcePackSource() == ResourcePackSource.PACK_SOURCE_BUILTIN && !profileName.equals("vanilla")) { + if (profile.getSource() instanceof BuiltinModResourcePackSource) { ResourcePack pack = profile.createResourcePack(); // Prevents automatic load for built-in data packs provided by mods. - return pack instanceof ModNioResourcePack && !((ModNioResourcePack) pack).getActivationType().isEnabledByDefault(); + return pack instanceof ModNioResourcePack modPack && !modPack.getActivationType().isEnabledByDefault(); } return false; diff --git a/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/en_us.json b/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/en_us.json index 3965e20c7a..2d624999e4 100644 --- a/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/en_us.json +++ b/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/en_us.json @@ -1,3 +1,4 @@ { - "pack.source.fabricmod": "Fabric mod" -} \ No newline at end of file + "pack.source.fabricmod": "Fabric mod", + "pack.source.builtinMod": "built-in: %s" +} diff --git a/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_ca.json b/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_ca.json new file mode 100644 index 0000000000..fa9cf19566 --- /dev/null +++ b/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_ca.json @@ -0,0 +1,3 @@ +{ + "pack.source.builtinMod": "intégré: %s" +} diff --git a/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_fr.json b/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_fr.json new file mode 100644 index 0000000000..fa9cf19566 --- /dev/null +++ b/fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/fr_fr.json @@ -0,0 +1,3 @@ +{ + "pack.source.builtinMod": "intégré: %s" +} diff --git a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json index 77222b8483..feff262750 100644 --- a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json +++ b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json @@ -13,7 +13,6 @@ "ReloadableResourceManagerImplMixin", "ResourcePackManagerMixin", "ResourcePackManagerAccessor", - "ResourcePackProfileAccessor", "SimpleResourceReloadMixin" ], "client": [ diff --git a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/BuiltinResourcePackTestMod.java b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/BuiltinResourcePackTestMod.java index 42758e7d83..40481fc6ef 100644 --- a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/BuiltinResourcePackTestMod.java +++ b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/BuiltinResourcePackTestMod.java @@ -36,6 +36,10 @@ public void onInitialize() { // Should always be present as it's **this** mod. FabricLoader.getInstance().getModContainer(MODID) .map(container -> ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(MODID, "test"), + container, "Fabric Resource Loader Test Pack", ResourcePackActivationType.NORMAL)) + .filter(success -> !success).ifPresent(success -> LOGGER.warn("Could not register built-in resource pack with custom name.")); + FabricLoader.getInstance().getModContainer(MODID) + .map(container -> ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(MODID, "test2"), container, ResourcePackActivationType.NORMAL)) .filter(success -> !success).ifPresent(success -> LOGGER.warn("Could not register built-in resource pack.")); } diff --git a/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/pack.mcmeta b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/pack.mcmeta index ce1669837b..0c7c189d3e 100644 --- a/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/pack.mcmeta +++ b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 7, + "pack_format": 8, "description": "Fabric Resource Loader Test Builtin Pack." } } diff --git a/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/data/minecraft/tags/blocks/climbable.json b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/data/minecraft/tags/blocks/climbable.json similarity index 100% rename from fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/data/minecraft/tags/blocks/climbable.json rename to fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/data/minecraft/tags/blocks/climbable.json diff --git a/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.mcmeta b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.mcmeta new file mode 100644 index 0000000000..6d1f6996f9 --- /dev/null +++ b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "pack_format": 9, + "description": "Fabric Resource Loader Test Builtin Pack." + } +} diff --git a/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.png b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test2/pack.png new file mode 100644 index 0000000000000000000000000000000000000000..2931efbf610873c0084debb8690902b0103d27fe GIT binary patch literal 1579 zcmbVMTWB0r7@iGm)TAXsYw<=rnU=;v=W=GRbL=!tc4Brl6GO7t2vVJ$IlDV#XU;e? z+r2ymsZdMQqAyaFLLUo;RumtE8Z@?uf_*4nP^4;o6fOFoSkN+o1$K?f2nE9_*b5G-l)AV)k5Qhb^- zU{V4ZnTKgnmXdpcB*Kg!W(1hvM2N&RO30x1u~eI9meGQGe@_?PDQq%q1CiV$8~M7 z?MQ_mOdqCh^a65Sv|ntwSXjV5se1;VK1|Kr8G7TQoQL&*ctt{L{fClG}xPK5k^yK3%T69N6J=>3jBqc zDNvZsrJ-yOXI^^mWf1cmY^XST)CVzIGjvEPENowmy}ax zvJ8_(Cf#+H-dBlH53`_u-~6BVAMz|(g?jCVdBWNZ(+A}(pFV7>S3QgPiQcMaflkIC z-3Ti|VT~{au*vq0ts9O&m$p&Gl=L6+q6_m$IcVq}o~+Pl{g>1esQp4%wp~|*zk1n` zZ7T6Toc4`y88s}riCP|ZXrJ?FLz@^KTcyqLjey zu95Yz%F&S{<0~f)Iomek?+hQ%MhCu%T^zsg>C_L`1`Br`xNY&))k9yTQb$JC>)w_f zpU(^tu^Q)y%W~lVz`jz;_ jF?g&s@Y=Qe&c#kW|JbvqK0Y=Rw)4XDoVqsk_>;c_`@;F@ literal 0 HcmV?d00001 From 032c981de840126634f69c6799d32b08c502e98f Mon Sep 17 00:00:00 2001 From: Luligabi1 <33578169+Luligabi1@users.noreply.github.com> Date: Fri, 20 May 2022 14:17:36 -0300 Subject: [PATCH 02/15] Fix #1947, #1873: FabricBlockSettings#copy does not copy all settings, the sequel (#2119) * Fix FabricMC#1947, FabricMC#1873 * Ordered import to follow checkstyle * Removed broken 1.18 code on 1.18.2 branch * Added note specyfing that FabricBlockSettings copies settings Block.Settings doesn't. --- .../builder/v1/block/FabricBlockSettings.java | 10 +++++++++ .../AbstractBlockSettingsAccessor.java | 22 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java index 0a48998a8a..0e6e54ea3c 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java @@ -35,6 +35,9 @@ * Fabric's version of Block.Settings. Adds additional methods and hooks * not found in the original class. * + *

Make note that this behaves slightly different from the + * vanilla counterpart, copying some settings that vanilla does not. + * *

To use it, simply replace Block.Settings.of() with * FabricBlockSettings.of(). */ @@ -60,10 +63,17 @@ protected FabricBlockSettings(AbstractBlock.Settings settings) { this.sounds(otherAccessor.getSoundGroup()); this.slipperiness(otherAccessor.getSlipperiness()); this.velocityMultiplier(otherAccessor.getVelocityMultiplier()); + this.jumpVelocityMultiplier(otherAccessor.getJumpVelocityMultiplier()); thisAccessor.setDynamicBounds(otherAccessor.getDynamicBounds()); thisAccessor.setOpaque(otherAccessor.getOpaque()); thisAccessor.setIsAir(otherAccessor.getIsAir()); thisAccessor.setToolRequired(otherAccessor.isToolRequired()); + this.allowsSpawning(otherAccessor.getAllowsSpawningPredicate()); + this.solidBlock(otherAccessor.getSolidBlockPredicate()); + this.suffocates(otherAccessor.getSuffocationPredicate()); + this.blockVision(otherAccessor.getBlockVisionPredicate()); + this.postProcess(otherAccessor.getPostProcessPredicate()); + this.emissiveLighting(otherAccessor.getEmissiveLightingPredicate()); } public static FabricBlockSettings of(Material material) { diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java index 4d91bc1df3..7986579ff2 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java @@ -28,6 +28,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.MapColor; import net.minecraft.block.Material; +import net.minecraft.entity.EntityType; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; @@ -64,6 +65,9 @@ public interface AbstractBlockSettingsAccessor { @Accessor float getVelocityMultiplier(); + @Accessor + float getJumpVelocityMultiplier(); + @Accessor boolean getDynamicBounds(); @@ -76,6 +80,24 @@ public interface AbstractBlockSettingsAccessor { @Accessor boolean isToolRequired(); + @Accessor + AbstractBlock.TypedContextPredicate> getAllowsSpawningPredicate(); + + @Accessor + AbstractBlock.ContextPredicate getSolidBlockPredicate(); + + @Accessor + AbstractBlock.ContextPredicate getSuffocationPredicate(); + + @Accessor + AbstractBlock.ContextPredicate getBlockVisionPredicate(); + + @Accessor + AbstractBlock.ContextPredicate getPostProcessPredicate(); + + @Accessor + AbstractBlock.ContextPredicate getEmissiveLightingPredicate(); + /* SETTERS */ @Accessor void setMaterial(Material material); From a6b09478187e05c5a3fcc8a189e84fbde674dcd7 Mon Sep 17 00:00:00 2001 From: altrisi Date: Fri, 20 May 2022 19:17:41 +0200 Subject: [PATCH 03/15] Make `crash-report-info` print mods in a tree form (#2157) * Make `crash-report-info` print mods in a tree form * Bump required loader version * Add mods to a list and sort instead of using a TreeSet * Remove the `:` between id and version and change style in loop --- .../crash/report/info/MixinCrashReport.java | 34 +++++++++++++------ .../src/main/resources/fabric.mod.json | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java b/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java index 981bcd1b3f..f75ae9a30e 100644 --- a/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java +++ b/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java @@ -16,8 +16,8 @@ package net.fabricmc.fabric.mixin.crash.report.info; -import java.util.Map; -import java.util.TreeMap; +import java.util.ArrayList; +import java.util.Comparator; import java.util.function.Supplier; import org.spongepowered.asm.mixin.Mixin; @@ -39,22 +39,36 @@ public abstract class MixinCrashReport { @Inject(at = @At("RETURN"), method = "") private void fillSystemDetails(CallbackInfo info) { addSection("Fabric Mods", () -> { - Map mods = new TreeMap<>(); + ArrayList topLevelMods = new ArrayList<>(); for (ModContainer container : FabricLoader.getInstance().getAllMods()) { - mods.put(container.getMetadata().getId(), container.getMetadata().getName() + " " + container.getMetadata().getVersion().getFriendlyString()); + if (container.getContainingMod().isEmpty()) { + topLevelMods.add(container); + } } StringBuilder modString = new StringBuilder(); - for (String id : mods.keySet()) { - modString.append("\n\t\t"); - modString.append(id); - modString.append(": "); - modString.append(mods.get(id)); - } + appendMods(modString, 2, topLevelMods); return modString.toString(); }); } + + private static void appendMods(StringBuilder modString, int depth, ArrayList mods) { + mods.sort(Comparator.comparing(mod -> mod.getMetadata().getId())); + + for (ModContainer mod : mods) { + modString.append('\n'); + modString.append("\t".repeat(depth)); + modString.append(mod.getMetadata().getId()); + modString.append(' '); + modString.append(mod.getMetadata().getVersion().getFriendlyString()); + + if (!mod.getContainedMods().isEmpty()) { + ArrayList childMods = new ArrayList<>(mod.getContainedMods()); + appendMods(modString, depth + 1, childMods); + } + } + } } diff --git a/fabric-crash-report-info-v1/src/main/resources/fabric.mod.json b/fabric-crash-report-info-v1/src/main/resources/fabric.mod.json index 2d6add2870..e63510a6dd 100644 --- a/fabric-crash-report-info-v1/src/main/resources/fabric.mod.json +++ b/fabric-crash-report-info-v1/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ "FabricMC" ], "depends": { - "fabricloader": ">=0.4.0" + "fabricloader": ">=0.13.0" }, "description": "Adds Fabric-related debug info to crash reports.", "mixins": [ From 85719ab7b755fbe8144ead1c6d6b783eb7369507 Mon Sep 17 00:00:00 2001 From: frqnny <45723631+frqnny@users.noreply.github.com> Date: Fri, 20 May 2022 13:17:48 -0400 Subject: [PATCH 04/15] Add ModifyItemAttributeModifiersCallback (#2175) * Add ItemAttributeModifiersCallback * fix checkstyle errors * fix checkstyle errors v2 * Edit javadoc per Technician's review * Update fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/ItemAttributeModifiersCallback.java Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * Change functional interface name per Juuz's review * Change name to ModifyItemAttributeModifiers per Juuz and Technician's request * Forgot to add callback to the name * Return mutable map * Remove unused import Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> --- .../ModifyItemAttributeModifiersCallback.java | 59 +++++++++++++++++++ .../fabric/mixin/item/ItemStackMixin.java | 8 ++- ...ifyItemAttributeModifiersCallbackTest.java | 38 ++++++++++++ .../src/testmod/resources/fabric.mod.json | 3 +- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/ModifyItemAttributeModifiersCallback.java create mode 100644 fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ModifyItemAttributeModifiersCallbackTest.java diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/ModifyItemAttributeModifiersCallback.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/ModifyItemAttributeModifiersCallback.java new file mode 100644 index 0000000000..2c0a2475f9 --- /dev/null +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/ModifyItemAttributeModifiersCallback.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, 2017, 2018, 2019 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.fabric.api.item.v1; + +import com.google.common.collect.Multimap; + +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.attribute.EntityAttribute; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.item.ItemStack; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +/** + * Stack-aware attribute modifier callback for foreign items. + * Instead of using Mixin to change attribute modifiers in items not in your mod, + * you can use this event instead, either checking the Item itself or using a tag. + * This event provides you with a guaranteed mutable map you can put attribute modifiers in. + * Do not use for your own Item classes; see {@link FabricItem#getAttributeModifiers} instead. + * For example, the following code modifies a Diamond Helmet to give you five extra hearts when wearing. + * + *

+ * {@code
+ * ModifyItemAttributeModifiersCallback.EVENT.register((stack, slot, attributeModifiers) -> {
+ * 	if (stack.isOf(Items.DIAMOND_HELMET) && slot.getEntitySlotId() == HEAD_SLOT_ID) {
+ * 		attributeModifiers.put(EntityAttributes.GENERIC_MAX_HEALTH, MODIFIER);
+ * 	}
+ * });
+ * }
+ * 
+ */ +@FunctionalInterface +public interface ModifyItemAttributeModifiersCallback { + void modifyAttributeModifiers(ItemStack stack, EquipmentSlot slot, Multimap attributeModifiers); + + Event EVENT = EventFactory.createArrayBacked( + ModifyItemAttributeModifiersCallback.class, + callbacks -> (stack, slot, attributeModifiers) -> { + for (ModifyItemAttributeModifiersCallback callback : callbacks) { + callback.modifyAttributeModifiers(stack, slot, attributeModifiers); + } + } + ); +} diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java index e0b559dc42..5702364658 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java @@ -18,6 +18,7 @@ import java.util.function.Consumer; +import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -37,6 +38,7 @@ import net.minecraft.item.ItemStack; import net.fabricmc.fabric.api.item.v1.CustomDamageHandler; +import net.fabricmc.fabric.api.item.v1.ModifyItemAttributeModifiersCallback; import net.fabricmc.fabric.impl.item.ItemExtensions; @Mixin(ItemStack.class) @@ -80,7 +82,11 @@ private void clearDamager(int amount, T entity, Consume ) ) public Multimap hookGetAttributeModifiers(Item item, EquipmentSlot slot) { - return item.getAttributeModifiers((ItemStack) (Object) this, slot); + ItemStack stack = (ItemStack) (Object) this; + //we need to ensure it is modifiable for the callback + Multimap attributeModifiers = HashMultimap.create(item.getAttributeModifiers(stack, slot)); + ModifyItemAttributeModifiersCallback.EVENT.invoker().modifyAttributeModifiers(stack, slot, attributeModifiers); + return attributeModifiers; } @Redirect( diff --git a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ModifyItemAttributeModifiersCallbackTest.java b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ModifyItemAttributeModifiersCallbackTest.java new file mode 100644 index 0000000000..72e54d9cd6 --- /dev/null +++ b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ModifyItemAttributeModifiersCallbackTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, 2017, 2018, 2019 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.fabric.test.item; + +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.item.Items; + +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.item.v1.ModifyItemAttributeModifiersCallback; + +public class ModifyItemAttributeModifiersCallbackTest implements ModInitializer { + public static final int HEAD_SLOT_ID = 3; + public static final EntityAttributeModifier MODIFIER = new EntityAttributeModifier("generic_max_health_modifier", 5.0, EntityAttributeModifier.Operation.ADDITION); + + @Override + public void onInitialize() { + ModifyItemAttributeModifiersCallback.EVENT.register((stack, slot, attributeModifiers) -> { + if (stack.isOf(Items.DIAMOND_HELMET) && slot.getEntitySlotId() == HEAD_SLOT_ID) { + attributeModifiers.put(EntityAttributes.GENERIC_MAX_HEALTH, MODIFIER); + } + }); + } +} diff --git a/fabric-item-api-v1/src/testmod/resources/fabric.mod.json b/fabric-item-api-v1/src/testmod/resources/fabric.mod.json index ec34716a14..2750b292a0 100644 --- a/fabric-item-api-v1/src/testmod/resources/fabric.mod.json +++ b/fabric-item-api-v1/src/testmod/resources/fabric.mod.json @@ -12,7 +12,8 @@ "main": [ "net.fabricmc.fabric.test.item.CustomDamageTest", "net.fabricmc.fabric.test.item.FabricItemSettingsTests", - "net.fabricmc.fabric.test.item.ItemUpdateAnimationTest" + "net.fabricmc.fabric.test.item.ItemUpdateAnimationTest", + "net.fabricmc.fabric.test.item.ModifyItemAttributeModifiersCallbackTest" ], "client": [ "net.fabricmc.fabric.test.item.client.TooltipTests" From f4563ac81e4821b79f25bf245194a1a7a4bd2a7f Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+Technici4n@users.noreply.github.com> Date: Fri, 20 May 2022 19:17:54 +0200 Subject: [PATCH 05/15] Fix #2164: Transfer API performance issues (#2189) * Fix #2164: Transfer API performance issue * Cache ItemStack in ItemVariantImpl * Fix checkstyle * Fix #2201 * Update comment in getCachedStack() --- .../v1/item/base/SingleStackStorage.java | 10 ++++---- .../v1/storage/base/SingleVariantStorage.java | 8 +++--- .../fabric/impl/transfer/TransferApiImpl.java | 5 ---- .../transfer/item/InventorySlotWrapper.java | 25 +++++++++++++------ .../impl/transfer/item/ItemVariantImpl.java | 16 ++++++++++++ .../item/SidedInventorySlotWrapper.java | 4 +-- .../transfer/item/SpecialLogicInventory.java | 6 ++++- .../AbstractFurnaceBlockEntityMixin.java | 11 ++++++-- .../LootableContainerBlockEntityMixin.java | 20 ++++++++++++--- .../mixin/transfer/SimpleInventoryMixin.java | 20 ++++++++++++--- .../test/transfer/unittests/ItemTests.java | 12 +++++++++ gradle.properties | 2 +- 12 files changed, 105 insertions(+), 34 deletions(-) diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/item/base/SingleStackStorage.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/item/base/SingleStackStorage.java index 33abfc3374..203cc9b62c 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/item/base/SingleStackStorage.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/item/base/SingleStackStorage.java @@ -85,7 +85,7 @@ protected int getCapacity(ItemVariant itemVariant) { @Override public boolean isResourceBlank() { - return getResource().isBlank(); + return getStack().isEmpty(); } @Override @@ -123,9 +123,9 @@ public long insert(ItemVariant insertedVariant, long maxAmount, TransactionConte } setStack(currentStack); - } - return insertedAmount; + return insertedAmount; + } } return 0; @@ -145,9 +145,9 @@ public long extract(ItemVariant variant, long maxAmount, TransactionContext tran currentStack = getStack(); currentStack.decrement(extracted); setStack(currentStack); - } - return extracted; + return extracted; + } } return 0; diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/SingleVariantStorage.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/SingleVariantStorage.java index 9c1ccc7447..6dc36355b1 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/SingleVariantStorage.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/base/SingleVariantStorage.java @@ -81,9 +81,9 @@ public long insert(T insertedVariant, long maxAmount, TransactionContext transac } else { amount += insertedAmount; } - } - return insertedAmount; + return insertedAmount; + } } return 0; @@ -103,9 +103,9 @@ public long extract(T extractedVariant, long maxAmount, TransactionContext trans if (amount == 0) { variant = getBlankVariant(); } - } - return extractedAmount; + return extractedAmount; + } } return 0; diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java index 84ad7cabf1..eb99f199bb 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java @@ -62,9 +62,4 @@ public long getVersion() { return 0; } }; - - /** - * Not null when writing to an inventory in a transaction, null otherwise. - */ - public static final ThreadLocal SUPPRESS_SPECIAL_LOGIC = new ThreadLocal<>(); } diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/InventorySlotWrapper.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/InventorySlotWrapper.java index f4087fc31a..744ea1146e 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/InventorySlotWrapper.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/InventorySlotWrapper.java @@ -21,7 +21,6 @@ import net.fabricmc.fabric.api.transfer.v1.item.base.SingleStackStorage; import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant; import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; -import net.fabricmc.fabric.impl.transfer.TransferApiImpl; /** * A wrapper around a single slot of an inventory. @@ -35,11 +34,13 @@ class InventorySlotWrapper extends SingleStackStorage { */ private final InventoryStorageImpl storage; final int slot; + private final SpecialLogicInventory specialInv; private ItemStack lastReleasedSnapshot = null; InventorySlotWrapper(InventoryStorageImpl storage, int slot) { this.storage = storage; this.slot = slot; + this.specialInv = storage.inventory instanceof SpecialLogicInventory specialInv ? specialInv : null; } @Override @@ -49,18 +50,26 @@ protected ItemStack getStack() { @Override protected void setStack(ItemStack stack) { - TransferApiImpl.SUPPRESS_SPECIAL_LOGIC.set(Boolean.TRUE); - - try { + if (specialInv == null) { storage.inventory.setStack(slot, stack); - } finally { - TransferApiImpl.SUPPRESS_SPECIAL_LOGIC.remove(); + } else { + specialInv.fabric_setSuppress(true); + + try { + storage.inventory.setStack(slot, stack); + } finally { + specialInv.fabric_setSuppress(false); + } } } @Override - protected boolean canInsert(ItemVariant itemVariant) { - return storage.inventory.isValid(slot, itemVariant.toStack()); + public long insert(ItemVariant insertedVariant, long maxAmount, TransactionContext transaction) { + if (!storage.inventory.isValid(slot, ((ItemVariantImpl) insertedVariant).getCachedStack())) { + return 0; + } else { + return super.insert(insertedVariant, maxAmount, transaction); + } } @Override diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ItemVariantImpl.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ItemVariantImpl.java index df8ddcb8d2..7f48168ed6 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ItemVariantImpl.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ItemVariantImpl.java @@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.PacketByteBuf; @@ -48,6 +49,10 @@ public static ItemVariant of(Item item, @Nullable NbtCompound tag) { private final Item item; private final @Nullable NbtCompound nbt; private final int hashCode; + /** + * Lazily computed, equivalent to calling toStack(1). MAKE SURE IT IS NEVER MODIFIED! + */ + private volatile @Nullable ItemStack cachedStack = null; public ItemVariantImpl(Item item, NbtCompound nbt) { this.item = item; @@ -135,4 +140,15 @@ public boolean equals(Object o) { public int hashCode() { return hashCode; } + + public ItemStack getCachedStack() { + ItemStack ret = cachedStack; + + if (ret == null) { + // multiple stacks could be created at the same time by different threads, but that is not an issue + cachedStack = ret = toStack(); + } + + return ret; + } } diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SidedInventorySlotWrapper.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SidedInventorySlotWrapper.java index 58b4d9568e..c58c8090ca 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SidedInventorySlotWrapper.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SidedInventorySlotWrapper.java @@ -40,7 +40,7 @@ class SidedInventorySlotWrapper implements SingleSlotStorage { @Override public long insert(ItemVariant resource, long maxAmount, TransactionContext transaction) { - if (!sidedInventory.canInsert(slotWrapper.slot, resource.toStack(), direction)) { + if (!sidedInventory.canInsert(slotWrapper.slot, ((ItemVariantImpl) resource).getCachedStack(), direction)) { return 0; } else { return slotWrapper.insert(resource, maxAmount, transaction); @@ -49,7 +49,7 @@ public long insert(ItemVariant resource, long maxAmount, TransactionContext tran @Override public long extract(ItemVariant resource, long maxAmount, TransactionContext transaction) { - if (!sidedInventory.canExtract(slotWrapper.slot, resource.toStack(), direction)) { + if (!sidedInventory.canExtract(slotWrapper.slot, ((ItemVariantImpl) resource).getCachedStack(), direction)) { return 0; } else { return slotWrapper.extract(resource, maxAmount, transaction); diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SpecialLogicInventory.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SpecialLogicInventory.java index f62a662a33..f86218f2c6 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SpecialLogicInventory.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/SpecialLogicInventory.java @@ -22,9 +22,13 @@ /** * Internal class that allows inventory instances to defer special logic until {@link InventorySlotWrapper#onFinalCommit()} is called. - * Special logic should be suppressed when {@link net.fabricmc.fabric.impl.transfer.TransferApiImpl#SUPPRESS_SPECIAL_LOGIC} is true. */ @ApiStatus.Internal public interface SpecialLogicInventory { + /** + * Decide whether special logic should now be suppressed. If true, must remain suppressed until the next call. + */ + void fabric_setSuppress(boolean suppress); + void fabric_onFinalCommit(int slot, ItemStack oldStack, ItemStack newStack); } diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/AbstractFurnaceBlockEntityMixin.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/AbstractFurnaceBlockEntityMixin.java index f9f8203767..5000cd135d 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/AbstractFurnaceBlockEntityMixin.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/AbstractFurnaceBlockEntityMixin.java @@ -19,6 +19,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -35,7 +36,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.fabricmc.fabric.impl.transfer.TransferApiImpl; import net.fabricmc.fabric.impl.transfer.item.SpecialLogicInventory; /** @@ -52,6 +52,8 @@ public abstract class AbstractFurnaceBlockEntityMixin extends LockableContainerB @Final @Shadow private RecipeType recipeType; + @Unique + private boolean fabric_suppressSpecialLogic = false; protected AbstractFurnaceBlockEntityMixin(BlockEntityType blockEntityType, BlockPos blockPos, BlockState blockState) { super(blockEntityType, blockPos, blockState); @@ -60,12 +62,17 @@ protected AbstractFurnaceBlockEntityMixin(BlockEntityType blockEntityType, Bl @Inject(at = @At("HEAD"), method = "setStack", cancellable = true) public void setStackSuppressUpdate(int slot, ItemStack stack, CallbackInfo ci) { - if (TransferApiImpl.SUPPRESS_SPECIAL_LOGIC.get() != null) { + if (fabric_suppressSpecialLogic) { inventory.set(slot, stack); ci.cancel(); } } + @Override + public void fabric_setSuppress(boolean suppress) { + fabric_suppressSpecialLogic = suppress; + } + @Override public void fabric_onFinalCommit(int slot, ItemStack oldStack, ItemStack newStack) { if (slot == 0) { diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/LootableContainerBlockEntityMixin.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/LootableContainerBlockEntityMixin.java index b7eb98365a..0e5e2cb1fc 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/LootableContainerBlockEntityMixin.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/LootableContainerBlockEntityMixin.java @@ -17,25 +17,39 @@ package net.fabricmc.fabric.mixin.transfer; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import net.minecraft.block.entity.LootableContainerBlockEntity; +import net.minecraft.item.ItemStack; -import net.fabricmc.fabric.impl.transfer.TransferApiImpl; +import net.fabricmc.fabric.impl.transfer.item.SpecialLogicInventory; /** * Defer markDirty until the outer transaction close callback when setStack is called from an inventory wrapper. */ @Mixin(LootableContainerBlockEntity.class) -public class LootableContainerBlockEntityMixin { +public class LootableContainerBlockEntityMixin implements SpecialLogicInventory { + @Unique + private boolean fabric_suppressSpecialLogic = false; + @Redirect( at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/LootableContainerBlockEntity;markDirty()V"), method = "setStack(ILnet/minecraft/item/ItemStack;)V" ) public void fabric_redirectMarkDirty(LootableContainerBlockEntity self) { - if (TransferApiImpl.SUPPRESS_SPECIAL_LOGIC.get() == null) { + if (!fabric_suppressSpecialLogic) { self.markDirty(); } } + + @Override + public void fabric_setSuppress(boolean suppress) { + fabric_suppressSpecialLogic = suppress; + } + + @Override + public void fabric_onFinalCommit(int slot, ItemStack oldStack, ItemStack newStack) { + } } diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/SimpleInventoryMixin.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/SimpleInventoryMixin.java index 17e7988566..831f15c8df 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/SimpleInventoryMixin.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer/SimpleInventoryMixin.java @@ -17,25 +17,39 @@ package net.fabricmc.fabric.mixin.transfer; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import net.minecraft.inventory.SimpleInventory; +import net.minecraft.item.ItemStack; -import net.fabricmc.fabric.impl.transfer.TransferApiImpl; +import net.fabricmc.fabric.impl.transfer.item.SpecialLogicInventory; /** * Defer markDirty until the outer transaction close callback when setStack is called from an inventory wrapper. */ @Mixin(SimpleInventory.class) -public class SimpleInventoryMixin { +public class SimpleInventoryMixin implements SpecialLogicInventory { + @Unique + private boolean fabric_suppressSpecialLogic = false; + @Redirect( at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/SimpleInventory;markDirty()V"), method = "setStack(ILnet/minecraft/item/ItemStack;)V" ) public void fabric_redirectMarkDirty(SimpleInventory self) { - if (TransferApiImpl.SUPPRESS_SPECIAL_LOGIC.get() == null) { + if (!fabric_suppressSpecialLogic) { self.markDirty(); } } + + @Override + public void fabric_setSuppress(boolean suppress) { + fabric_suppressSpecialLogic = suppress; + } + + @Override + public void fabric_onFinalCommit(int slot, ItemStack oldStack, ItemStack newStack) { + } } diff --git a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/ItemTests.java b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/ItemTests.java index d72d945904..0d398856ed 100644 --- a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/ItemTests.java +++ b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/ItemTests.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.test.transfer.unittests; +import static net.fabricmc.fabric.test.transfer.unittests.TestUtil.assertEquals; + import java.util.stream.IntStream; import org.jetbrains.annotations.Nullable; @@ -127,6 +129,16 @@ private static void testInventoryWrappers() { if (!testInventory.getStack(1).isOf(Items.BUCKET) || testInventory.getStack(1).getCount() != 1) throw new AssertionError("Slot 1 should have been a bucket."); checkComparatorOutput(testInventory, null); + + // Check that we return sensible results if amount stored > capacity + ItemStack oversizedStack = new ItemStack(Items.DIAMOND_PICKAXE, 2); + SimpleInventory simpleInventory = new SimpleInventory(oversizedStack); + InventoryStorage wrapper = InventoryStorage.of(simpleInventory, null); + + try (Transaction transaction = Transaction.openOuter()) { + assertEquals(0L, wrapper.insert(ItemVariant.of(oversizedStack), 10, transaction)); + transaction.commit(); + } } private static boolean stackEquals(ItemStack stack, Item item, int count) { diff --git a/gradle.properties b/gradle.properties index 0a53b18c10..830bc437ae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,6 +49,6 @@ fabric-resource-loader-v0-version=0.4.18 fabric-screen-api-v1-version=1.0.10 fabric-screen-handler-api-v1-version=1.2.0 fabric-textures-v0-version=1.0.12 -fabric-transfer-api-v1-version=1.6.0 +fabric-transfer-api-v1-version=1.6.42+technici4n-PR-2189 fabric-transitive-access-wideners-v1-version=1.0.0 fabric-convention-tags-v1-version=1.0.1 From b1dd84b88f9863c7753000b9b93b498e4541ff08 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Fri, 20 May 2022 19:08:13 +0100 Subject: [PATCH 06/15] Bump version --- gradle.properties | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gradle.properties b/gradle.properties index 830bc437ae..e8142687da 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx2560M -version=0.51.1 +version=0.53.0 minecraft_version=1.18.2 yarn_version=+build.1 loader_version=0.13.2 @@ -15,26 +15,26 @@ fabric-blockrenderlayer-v1-version=1.1.12 fabric-command-api-v1-version=1.1.9 fabric-commands-v0-version=0.2.8 fabric-containers-v0-version=0.1.21 -fabric-content-registries-v0-version=3.0.3 -fabric-crash-report-info-v1-version=0.1.11 +fabric-content-registries-v0-version=3.0.4 +fabric-crash-report-info-v1-version=0.2.0 fabric-data-generation-api-v1-version=2.0.9 fabric-dimensions-v1-version=2.1.17 fabric-entity-events-v1-version=1.4.8 fabric-events-interaction-v0-version=0.4.19 -fabric-events-lifecycle-v0-version=0.2.14 +fabric-events-lifecycle-v0-version=0.2.15 fabric-game-rule-api-v1-version=1.0.13 -fabric-gametest-api-v1-version=1.0.16 -fabric-item-api-v1-version=1.4.0 -fabric-item-groups-v0-version=0.3.11 +fabric-gametest-api-v1-version=1.0.17 +fabric-item-api-v1-version=1.5.0 +fabric-item-groups-v0-version=0.3.12 fabric-key-binding-api-v1-version=1.0.12 fabric-keybindings-v0-version=0.2.10 fabric-lifecycle-events-v1-version=2.0.3 fabric-loot-tables-v1-version=1.0.11 -fabric-mining-level-api-v1-version=2.1.0 +fabric-mining-level-api-v1-version=2.1.1 fabric-models-v0-version=0.3.6 fabric-networking-api-v1-version=1.0.21 fabric-networking-v0-version=0.3.8 -fabric-object-builder-api-v1-version=2.1.0 +fabric-object-builder-api-v1-version=2.1.1 fabric-particles-v1-version=0.2.12 fabric-registry-sync-v0-version=0.9.8 fabric-renderer-api-v1-version=0.4.13 @@ -45,10 +45,10 @@ fabric-rendering-fluids-v1-version=2.0.2 fabric-rendering-v0-version=1.1.13 fabric-rendering-v1-version=1.10.7 fabric-resource-conditions-api-v1-version=2.0.3 -fabric-resource-loader-v0-version=0.4.18 +fabric-resource-loader-v0-version=0.5.0 fabric-screen-api-v1-version=1.0.10 fabric-screen-handler-api-v1-version=1.2.0 fabric-textures-v0-version=1.0.12 -fabric-transfer-api-v1-version=1.6.42+technici4n-PR-2189 +fabric-transfer-api-v1-version=1.6.1 fabric-transitive-access-wideners-v1-version=1.0.0 fabric-convention-tags-v1-version=1.0.1 From 01a4d43dcd16d97b76a947e3e5ea7b162e7ed59d Mon Sep 17 00:00:00 2001 From: qouteall Date: Mon, 23 May 2022 21:49:51 +0800 Subject: [PATCH 07/15] Fix the issue of uninstalling a dimension mod or datapack (#2078) * Fix the vanilla bug of uninstalling dimensions. * fix license * fix style * Rename LevelStorageMixin and some minor changes. --- .../dimension/LevelStorageBugfixMixin.java | 83 +++++++++++++++++++ .../fabric-dimensions-v1.mixins.json | 5 +- 2 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/LevelStorageBugfixMixin.java diff --git a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/LevelStorageBugfixMixin.java b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/LevelStorageBugfixMixin.java new file mode 100644 index 0000000000..48e7f4f4c3 --- /dev/null +++ b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/LevelStorageBugfixMixin.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016, 2017, 2018, 2019 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.fabric.mixin.dimension; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.mojang.datafixers.DataFixer; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.Dynamic; +import com.mojang.serialization.Lifecycle; + +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.world.gen.GeneratorOptions; +import net.minecraft.world.level.storage.LevelStorage; + +/** + * After removing a dimension mod or a dimension datapack, Minecraft may fail to enter + * the world, because it fails to deserialize the chunk generator of the custom dimensions in file {@code level.dat} + * This mixin will remove the custom dimensions from the nbt tag, so the deserializer and DFU cannot see custom + * dimensions and won't cause errors. + * The custom dimensions will be re-added later. + * + *

This Mixin changes a vanilla behavior that is deemed as a bug (MC-197860). In vanilla, the custom dimension + * is not removed after uninstalling the dimension datapack. + * This makes custom dimensions non-removable. Most players don't want this behavior. + * With this Mixin, custom dimensions will be removed when its datapack is removed. + */ +@Mixin(LevelStorage.class) +public class LevelStorageBugfixMixin { + @SuppressWarnings("unchecked") + @Inject(method = "readGeneratorProperties", at = @At("HEAD")) + private static void onReadGeneratorProperties( + Dynamic nbt, DataFixer dataFixer, int version, + CallbackInfoReturnable> cir + ) { + NbtElement nbtTag = ((Dynamic) nbt).getValue(); + + NbtCompound worldGenSettings = ((NbtCompound) nbtTag).getCompound("WorldGenSettings"); + + removeNonVanillaDimensionsFromWorldGenSettingsTag(worldGenSettings); + } + + /** + * Removes all non-vanilla dimensions from the tag. The custom dimensions will be re-added later from the datapacks. + */ + @Unique + private static void removeNonVanillaDimensionsFromWorldGenSettingsTag(NbtCompound worldGenSettings) { + String[] vanillaDimensionIds = + new String[]{"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"}; + + NbtCompound dimensions = worldGenSettings.getCompound("dimensions"); + + if (dimensions.getSize() > vanillaDimensionIds.length) { + NbtCompound newDimensions = new NbtCompound(); + + for (String dimId : vanillaDimensionIds) { + if (dimensions.contains(dimId)) { + newDimensions.put(dimId, dimensions.getCompound(dimId)); + } + } + + worldGenSettings.put("dimensions", newDimensions); + } + } +} diff --git a/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json b/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json index 6cea0c36fa..ffccedb7c7 100644 --- a/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json +++ b/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json @@ -4,8 +4,9 @@ "compatibilityLevel": "JAVA_16", "mixins": [ "EntityMixin", - "ServerPlayerEntityMixin", - "ServerBugfixMixin" + "LevelStorageBugfixMixin", + "ServerBugfixMixin", + "ServerPlayerEntityMixin" ], "injectors": { "defaultRequire": 1 From ee261a3e140b70d9a2d70c0aba1c40f330bd0e8b Mon Sep 17 00:00:00 2001 From: altrisi Date: Mon, 23 May 2022 15:49:56 +0200 Subject: [PATCH 08/15] Restore printing the mod name in crash reports (#2235) (cherry picked from commit bd0a0d4a7beb3eb40d28063da86f212880afc6da) --- .../fabric/mixin/crash/report/info/MixinCrashReport.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java b/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java index f75ae9a30e..3b801fcfc6 100644 --- a/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java +++ b/fabric-crash-report-info-v1/src/main/java/net/fabricmc/fabric/mixin/crash/report/info/MixinCrashReport.java @@ -62,6 +62,8 @@ private static void appendMods(StringBuilder modString, int depth, ArrayList Date: Mon, 23 May 2022 14:57:29 +0100 Subject: [PATCH 09/15] Bump version --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index e8142687da..7f7b9222ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx2560M -version=0.53.0 +version=0.53.3 minecraft_version=1.18.2 yarn_version=+build.1 loader_version=0.13.2 @@ -16,9 +16,9 @@ fabric-command-api-v1-version=1.1.9 fabric-commands-v0-version=0.2.8 fabric-containers-v0-version=0.1.21 fabric-content-registries-v0-version=3.0.4 -fabric-crash-report-info-v1-version=0.2.0 +fabric-crash-report-info-v1-version=0.2.1 fabric-data-generation-api-v1-version=2.0.9 -fabric-dimensions-v1-version=2.1.17 +fabric-dimensions-v1-version=2.1.18 fabric-entity-events-v1-version=1.4.8 fabric-events-interaction-v0-version=0.4.19 fabric-events-lifecycle-v0-version=0.2.15 From 23d88c80992ccf86240c379504f991dd566a3f6f Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+Technici4n@users.noreply.github.com> Date: Tue, 24 May 2022 16:05:44 +0200 Subject: [PATCH 10/15] Fix #2206: Client chunk cache grows unbounded (#2248) * Fix missing some chunk unloads events leading to a possible memory leak. (#1820) * Update fix for 1.18.2. Fixes #2206 Co-authored-by: modmuss50 --- .../event/lifecycle/client/ClientChunkManagerMixin.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientChunkManagerMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientChunkManagerMixin.java index e7dd9c0c62..eb1def7641 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientChunkManagerMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientChunkManagerMixin.java @@ -33,6 +33,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.network.PacketByteBuf; import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.util.math.ChunkPos; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -50,6 +51,13 @@ private void onChunkLoad(int x, int z, PacketByteBuf packetByteBuf, NbtCompound ClientChunkEvents.CHUNK_LOAD.invoker().onChunkLoad(this.world, info.getReturnValue()); } + @Inject(method = "loadChunkFromPacket", at = @At(value = "NEW", target = "net/minecraft/world/chunk/WorldChunk", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) + private void onChunkUnload(int x, int z, PacketByteBuf buf, NbtCompound tag, Consumer consumer, CallbackInfoReturnable info, int index, WorldChunk worldChunk, ChunkPos chunkPos) { + if (worldChunk != null) { + ClientChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload(this.world, worldChunk); + } + } + @Inject(method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap;compareAndSet(ILnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/WorldChunk;)Lnet/minecraft/world/chunk/WorldChunk;", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION) private void onChunkUnload(int chunkX, int chunkZ, CallbackInfo ci, int i, WorldChunk chunk) { ClientChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload(this.world, chunk); From d8d7804af09576b6c93a617f155eb11c65a91697 Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+Technici4n@users.noreply.github.com> Date: Tue, 24 May 2022 16:08:00 +0200 Subject: [PATCH 11/15] Fix #2152: End server world tick too early and conditional (#2251) --- .../mixin/event/lifecycle/ServerWorldMixin.java | 5 +++++ .../fabric/mixin/event/lifecycle/WorldMixin.java | 12 ------------ .../event/lifecycle/client/ClientWorldMixin.java | 14 ++++++-------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java index 39b1b2796c..cefad93fc6 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java @@ -35,4 +35,9 @@ public abstract class ServerWorldMixin { private void startWorldTick(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { ServerTickEvents.START_WORLD_TICK.invoker().onStartTick((ServerWorld) (Object) this); } + + @Inject(method = "tick", at = @At("TAIL")) + private void endWorldTick(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { + ServerTickEvents.END_WORLD_TICK.invoker().onEndTick((ServerWorld) (Object) this); + } } diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java index 3ff421f97d..cc0bc634c0 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java @@ -22,16 +22,11 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.server.world.ServerWorld; import net.minecraft.util.profiler.Profiler; import net.minecraft.world.World; import net.minecraft.world.chunk.WorldChunk; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.impl.event.lifecycle.LoadedChunksCache; @Mixin(World.class) @@ -45,13 +40,6 @@ public abstract class WorldMixin implements LoadedChunksCache { @Unique private final Set loadedChunks = new HashSet<>(); - @Inject(at = @At("RETURN"), method = "tickBlockEntities") - protected void tickWorldAfterBlockEntities(CallbackInfo ci) { - if (!this.isClient()) { - ServerTickEvents.END_WORLD_TICK.invoker().onEndTick((ServerWorld) (Object) this); - } - } - @Override public Set fabric_getLoadedChunks() { return this.loadedChunks; diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java index c9fa082472..8b68ce851c 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java @@ -26,19 +26,17 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.mixin.event.lifecycle.WorldMixin; @Environment(EnvType.CLIENT) @Mixin(ClientWorld.class) -public abstract class ClientWorldMixin extends WorldMixin { - // We override our injection on the clientworld so only the client world's tick invocations will run - @Override - protected void tickWorldAfterBlockEntities(CallbackInfo ci) { - ClientTickEvents.END_WORLD_TICK.invoker().onEndTick((ClientWorld) (Object) this); - } - +public abstract class ClientWorldMixin { @Inject(method = "tickEntities", at = @At("HEAD")) private void startWorldTick(CallbackInfo ci) { ClientTickEvents.START_WORLD_TICK.invoker().onStartTick((ClientWorld) (Object) this); } + + @Inject(method = "tickEntities", at = @At("TAIL")) + protected void endWorldTick(CallbackInfo ci) { + ClientTickEvents.END_WORLD_TICK.invoker().onEndTick((ClientWorld) (Object) this); + } } From ffb2c71e5552991ad8157cb34bff5cffe5fa1bc8 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 24 May 2022 15:10:52 +0100 Subject: [PATCH 12/15] Handle teleporting within the same dimension better. (#2249) (cherry picked from commit 72da3b3d5e7c5baf0a57699fc3ae48bc9592299a) --- .../dimension/FabricDimensionInternals.java | 16 ++++++ .../test/dimension/FabricDimensionTest.java | 52 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/impl/dimension/FabricDimensionInternals.java b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/impl/dimension/FabricDimensionInternals.java index df1b9b3e63..02eedb6403 100644 --- a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/impl/dimension/FabricDimensionInternals.java +++ b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/impl/dimension/FabricDimensionInternals.java @@ -19,6 +19,7 @@ import com.google.common.base.Preconditions; import net.minecraft.entity.Entity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.TeleportTarget; @@ -48,6 +49,21 @@ public static E changeDimension(E teleported, ServerWorld dim try { currentTarget = target; + + // Fast path for teleporting within the same dimension. + if (teleported.getWorld() == dimension) { + if (teleported instanceof ServerPlayerEntity serverPlayerEntity) { + serverPlayerEntity.networkHandler.requestTeleport(target.position.x, target.position.y, target.position.z, target.yaw, teleported.getPitch()); + } else { + teleported.refreshPositionAndAngles(target.position.x, target.position.y, target.position.z, target.yaw, teleported.getPitch()); + } + + teleported.setVelocity(target.velocity); + teleported.setHeadYaw(target.yaw); + + return teleported; + } + return (E) teleported.moveToWorld(dimension); } finally { currentTarget = null; diff --git a/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java b/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java index 6cd3389180..5e58e3b171 100644 --- a/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java +++ b/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java @@ -102,6 +102,14 @@ public void onInitialize() { CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(literal("fabric_dimension_test").executes(FabricDimensionTest.this::swapTargeted)) ); + + // Used to test https://github.com/FabricMC/fabric/issues/2239 + CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(literal("fabric_dimension_test_desync") + .executes(FabricDimensionTest.this::testDesync))); + + // Used to test https://github.com/FabricMC/fabric/issues/2238 + CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(literal("fabric_dimension_test_entity") + .executes(FabricDimensionTest.this::testEntityTeleport))); } private int swapTargeted(CommandContext context) throws CommandSyntaxException { @@ -128,6 +136,50 @@ private int swapTargeted(CommandContext context) throws Com return 1; } + private int testDesync(CommandContext context) throws CommandSyntaxException { + ServerPlayerEntity player = context.getSource().getPlayer(); + + if (player == null) { + context.getSource().sendFeedback(new LiteralText("You must be a player to execute this command."), false); + return 1; + } + + if (!context.getSource().getServer().isDedicated()) { + context.getSource().sendFeedback(new LiteralText("This command can only be executed on dedicated servers."), false); + return 1; + } + + TeleportTarget target = new TeleportTarget(player.getPos().add(5, 0, 0), player.getVelocity(), player.getYaw(), player.getPitch()); + FabricDimensions.teleport(player, (ServerWorld) player.world, target); + + return 1; + } + + private int testEntityTeleport(CommandContext context) throws CommandSyntaxException { + ServerPlayerEntity player = context.getSource().getPlayer(); + + if (player == null) { + context.getSource().sendFeedback(new LiteralText("You must be a player to execute this command."), false); + return 1; + } + + Entity entity = player.world + .getOtherEntities(player, player.getBoundingBox().expand(100, 100, 100)) + .stream() + .findFirst() + .orElse(null); + + if (entity == null) { + context.getSource().sendFeedback(new LiteralText("No entities found."), false); + return 1; + } + + TeleportTarget target = new TeleportTarget(player.getPos(), player.getVelocity(), player.getYaw(), player.getPitch()); + FabricDimensions.teleport(entity, (ServerWorld) entity.world, target); + + return 1; + } + private ServerWorld getModWorld(CommandContext context) { return getWorld(context, WORLD_KEY); } From 2c7b4abb73a8f9a82f8749834d4452ce6dbb68c7 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 24 May 2022 15:19:38 +0100 Subject: [PATCH 13/15] Bump version --- gradle.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7f7b9222ca..fe26237df0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx2560M -version=0.53.3 +version=0.53.4 minecraft_version=1.18.2 yarn_version=+build.1 loader_version=0.13.2 @@ -9,26 +9,26 @@ prerelease=false # Do not manually update, use the bumpversions task: fabric-api-base-version=0.4.4 -fabric-api-lookup-api-v1-version=1.6.0 +fabric-api-lookup-api-v1-version=1.6.1 fabric-biome-api-v1-version=8.0.4 fabric-blockrenderlayer-v1-version=1.1.12 fabric-command-api-v1-version=1.1.9 fabric-commands-v0-version=0.2.8 fabric-containers-v0-version=0.1.21 -fabric-content-registries-v0-version=3.0.4 +fabric-content-registries-v0-version=3.0.5 fabric-crash-report-info-v1-version=0.2.1 fabric-data-generation-api-v1-version=2.0.9 -fabric-dimensions-v1-version=2.1.18 +fabric-dimensions-v1-version=2.1.19 fabric-entity-events-v1-version=1.4.8 fabric-events-interaction-v0-version=0.4.19 -fabric-events-lifecycle-v0-version=0.2.15 +fabric-events-lifecycle-v0-version=0.2.16 fabric-game-rule-api-v1-version=1.0.13 fabric-gametest-api-v1-version=1.0.17 fabric-item-api-v1-version=1.5.0 fabric-item-groups-v0-version=0.3.12 fabric-key-binding-api-v1-version=1.0.12 fabric-keybindings-v0-version=0.2.10 -fabric-lifecycle-events-v1-version=2.0.3 +fabric-lifecycle-events-v1-version=2.0.4 fabric-loot-tables-v1-version=1.0.11 fabric-mining-level-api-v1-version=2.1.1 fabric-models-v0-version=0.3.6 @@ -49,6 +49,6 @@ fabric-resource-loader-v0-version=0.5.0 fabric-screen-api-v1-version=1.0.10 fabric-screen-handler-api-v1-version=1.2.0 fabric-textures-v0-version=1.0.12 -fabric-transfer-api-v1-version=1.6.1 +fabric-transfer-api-v1-version=1.6.2 fabric-transitive-access-wideners-v1-version=1.0.0 fabric-convention-tags-v1-version=1.0.1 From 356d0d087d9410e730082fd9f5be2c218d6e7805 Mon Sep 17 00:00:00 2001 From: "Emma C. Pointer-Null" Date: Mon, 30 May 2022 14:19:29 -0400 Subject: [PATCH 14/15] Update fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java Co-authored-by: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> --- .../mixin/object/builder/AbstractBlockSettingsAccessor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java index a7765700aa..c73b9a9acb 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java @@ -80,6 +80,7 @@ public interface AbstractBlockSettingsAccessor { @Accessor float getJumpVelocityMultiplier(); + @Deprecated @Accessor boolean getDynamicBounds(); From 0be6c90f1f2beecc770cae23b72f512213c1a277 Mon Sep 17 00:00:00 2001 From: Emma Cypress Pointer-Null Date: Mon, 30 May 2022 14:22:01 -0400 Subject: [PATCH 15/15] Deprecate the accessors --- .../mixin/object/builder/AbstractBlockSettingsAccessor.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java index a7765700aa..2709bb24cf 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java @@ -95,21 +95,27 @@ public interface AbstractBlockSettingsAccessor { @Accessor boolean isToolRequired(); + @Deprecated @Accessor AbstractBlock.TypedContextPredicate> getAllowsSpawningPredicate(); + @Deprecated @Accessor AbstractBlock.ContextPredicate getSolidBlockPredicate(); + @Deprecated @Accessor AbstractBlock.ContextPredicate getSuffocationPredicate(); + @Deprecated @Accessor AbstractBlock.ContextPredicate getBlockVisionPredicate(); + @Deprecated @Accessor AbstractBlock.ContextPredicate getPostProcessPredicate(); + @Deprecated @Accessor AbstractBlock.ContextPredicate getEmissiveLightingPredicate();