From 262bc2d26c6a709f2b5f06d12c42ab3832180e44 Mon Sep 17 00:00:00 2001 From: Su5eD Date: Thu, 18 Jul 2024 11:12:39 +0200 Subject: [PATCH] Fight mod internal usage https://github.com/TerraformersMC/Terraform/blob/0d569ebf8e6c78c79ccdb8b8f28c081089764aef/terraform-biome-remapper-api-v1/src/main/java/com/terraformersmc/terraform/biomeremapper/impl/mixin/MixinLevelStorageSession.java#L41 --- .../client/CreativeInventoryScreenMixin.java | 30 +++++++++++---- .../registry/sync/RegistryMapSerializer.java | 37 +++++++++++++++++++ ffapi.gradle.properties | 2 +- 3 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistryMapSerializer.java diff --git a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java index ed45a5866..165954850 100644 --- a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java @@ -27,6 +27,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 java.util.List; import java.util.Objects; @@ -36,11 +37,14 @@ public abstract class CreativeInventoryScreenMixin pages; - @Shadow - private CreativeTabsScreenPage currentPage; + @Shadow(aliases = "currentPage") + private CreativeTabsScreenPage currentSelectedPage; @Shadow private static CreativeModeTab selectedTab; + @Unique // Kept for mod internal usage + private static int currentPage; + @Shadow abstract void setCurrentPage(CreativeTabsScreenPage currentPage); @@ -63,7 +67,7 @@ public boolean switchToPage(int page) { @Override public boolean switchToNextPage() { if (hasAdditionalPages()) { - this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentPage) + 1)); + this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentSelectedPage) + 1)); return true; } return false; @@ -71,8 +75,8 @@ public boolean switchToNextPage() { @Override public boolean switchToPreviousPage() { - if (this.pages.indexOf(this.currentPage) > 0) { - this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentPage) - 1)); + if (this.pages.indexOf(this.currentSelectedPage) > 0) { + this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentSelectedPage) - 1)); return true; } return false; @@ -80,7 +84,7 @@ public boolean switchToPreviousPage() { @Override public int getCurrentPage() { - return this.pages.indexOf(this.currentPage); + return this.pages.indexOf(this.currentSelectedPage); } @Override @@ -102,7 +106,7 @@ public int getPage(CreativeModeTab itemGroup) { @Override public boolean hasAdditionalPages() { - return this.pages.indexOf(this.currentPage) < this.pages.size() - 1; + return this.pages.indexOf(this.currentSelectedPage) < this.pages.size() - 1; } @Override @@ -118,7 +122,7 @@ public boolean setSelectedItemGroup(CreativeModeTab itemGroup) { return false; } - if (pages.indexOf(currentPage) != getPage(itemGroup)) { + if (pages.indexOf(currentSelectedPage) != getPage(itemGroup)) { if (!switchToPage(getPage(itemGroup))) { return false; } @@ -127,4 +131,14 @@ public boolean setSelectedItemGroup(CreativeModeTab itemGroup) { selectTab(itemGroup); return true; } + + @Unique + @Deprecated // Kept for mod internals + private boolean isGroupVisible(CreativeModeTab tab) { + return tab.shouldDisplay() && getCurrentPage() == getPage(tab); + } + + @Unique + @Deprecated // Kept for mod internals + private void updateSelection() {} } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistryMapSerializer.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistryMapSerializer.java new file mode 100644 index 000000000..402d90a5a --- /dev/null +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistryMapSerializer.java @@ -0,0 +1,37 @@ +/* + * 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.impl.registry.sync; + +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; + +import java.util.HashMap; +import java.util.Map; + +@Deprecated // Only for fighting internal usage by mods +public class RegistryMapSerializer { + public static final int VERSION = 1; + + public static Map> fromNbt(CompoundTag nbt) { + return new HashMap<>(); + } + + public static CompoundTag toNbt(Map> map) { + return new CompoundTag(); + } +} diff --git a/ffapi.gradle.properties b/ffapi.gradle.properties index 545e44da7..470e07b86 100644 --- a/ffapi.gradle.properties +++ b/ffapi.gradle.properties @@ -1,7 +1,7 @@ loom.platform=neoforge fabric.loom.dontRemap=true -implementationVersion=2.0.2 +implementationVersion=2.0.3 versionMc=1.21 versionForge=21.0.57-beta