diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 702b884..2bd7e24 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,33 +1,37 @@ # This workflow will build a Java project with Gradle # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle -name: Java CI with Gradle - -on: - push: - branches: - - latest - pull_request: - branches: - - latest +name: build +on: [push, pull_request] jobs: build: + strategy: + matrix: + java: [ 21, ] - runs-on: ubuntu-latest - + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.17 - uses: actions/setup-java@v1 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate gradle wrapper + uses: gradle/wrapper-validation-action@v2 + + - name: Setup jdk ${{ matrix.java }} + uses: actions/setup-java@v4 with: - java-version: 1.17 + java-version: ${{ matrix.java }} + distribution: 'temurin' + - name: Grant execute permission for gradlew - run: chmod +x gradlew + run: chmod +x ./gradlew + - name: Build with Gradle run: ./gradlew build - - uses: actions/upload-artifact@v2 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 with: - name: AllStackable + name: AllStackable_Java${{ matrix.java }} path: build/libs/AllStackable-*.*-*.*[^sourcedv].jar - diff --git a/.gitignore b/.gitignore index 09cd281..c476faf 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,10 @@ bin/ # fabric run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/build.gradle b/build.gradle index a0fea72..13f8dbb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,15 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_21 -targetCompatibility = JavaVersion.VERSION_21 - -archivesBaseName = project.archives_base_name version = "v${project.mod_version}-${project.minecraft_version}" group = project.maven_group +base { + archivesName = project.archives_base_name +} + repositories { // Add repositories to retrieve artifacts from in here. // You should only use this when depending on other mods because @@ -18,6 +18,18 @@ repositories { // for more information about repositories. } +loom { + splitEnvironmentSourceSets() + + mods { + "allstackable" { + sourceSet sourceSets.main + sourceSet sourceSets.client + } + } + +} + dependencies { // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" @@ -26,11 +38,7 @@ dependencies { // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - - // Uncomment the following line to enable the deprecated Fabric API modules. - // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. - - // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" + } processResources { @@ -42,8 +50,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + it.options.release = 21 } java { @@ -51,18 +58,22 @@ java { // if it is present. // If you remove this line, sources will not be generated. withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} + rename { "${it}_${project.base.archivesName.get()}"} } } // configure the maven publication publishing { publications { - mavenJava(MavenPublication) { + create("mavenJava", MavenPublication) { + artifactId = project.archives_base_name from components.java } } diff --git a/gradle.properties b/gradle.properties index bba8e03..33ff952 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,16 @@ # Done to increase the memory available to gradle. - org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true -#Fabric - minecraft_version=1.20.6 - yarn_mappings=1.20.6+build.1 - loader_version=0.15.11 - fabric_version=0.98.0+1.20.6 +# Fabric +loader_version=0.16.5 +yarn_mappings=1.21+build.9 +minecraft_version=1.21 +fabric_version=0.102.0+1.21 # Mod Properties - mod_version = 2.1.0 - maven_group = online.connlost.allstackable - archives_base_name = AllStackable +mod_version = 2.1.0 +maven_group=online.connlost +archives_base_name=AllStackable + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 81c736b..dab2a01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 31042a6..731b6ec 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/gradlew.bat b/gradlew.bat index 0faad1a..25da30d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -89,4 +89,4 @@ exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega \ No newline at end of file +:omega diff --git a/settings.gradle b/settings.gradle index 56266b4..75c4d72 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,10 @@ pluginManagement { - repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - mavenCentral() - gradlePluginPortal() - } + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } } \ No newline at end of file diff --git a/src/main/java/online/connlost/allstackable/client/AllStackableClientInit.java b/src/client/java/online/connlost/AllStackableClient.java similarity index 50% rename from src/main/java/online/connlost/allstackable/client/AllStackableClientInit.java rename to src/client/java/online/connlost/AllStackableClient.java index f783385..28b3956 100644 --- a/src/main/java/online/connlost/allstackable/client/AllStackableClientInit.java +++ b/src/client/java/online/connlost/AllStackableClient.java @@ -1,37 +1,35 @@ -package online.connlost.allstackable.client; +package online.connlost; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.networking.v1.PacketSender; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.PacketByteBuf; import java.util.ArrayList; import java.util.LinkedHashMap; -import online.connlost.allstackable.AllStackableInit; +import online.connlost.util.ByteArrayPayload; import org.apache.commons.lang3.SerializationUtils; -public class AllStackableClientInit implements ClientModInitializer { - +public class AllStackableClient implements ClientModInitializer { @Override @Environment(EnvType.CLIENT) public void onInitializeClient() { - ClientPlayConnectionEvents.INIT.register((handler, client) ->{ + ClientPlayConnectionEvents.INIT.register((handler, client) -> { ClientPlayNetworking.registerReceiver( - AllStackableInit.SHARE_CONFIG_PACKET_ID, - (client1, handler1, buf, sender1) -> configHandler(handler1, sender1, client1, buf) + ByteArrayPayload.ID, + (packet, context) -> { + configHandler(packet.data()); + } ); }); } - private void configHandler(ClientPlayNetworkHandler handler, PacketSender sender, MinecraftClient client, PacketByteBuf buf){ - ArrayList> configList = SerializationUtils.deserialize(buf.readByteArray()); + // Updated configHandler method to match the new PlayPayloadHandler API + private void configHandler(byte[] configPayload) { + ArrayList> configList = SerializationUtils.deserialize(configPayload); ConfigSync.syncConfig(configList); } } diff --git a/src/client/java/online/connlost/ConfigSync.java b/src/client/java/online/connlost/ConfigSync.java new file mode 100644 index 0000000..93a81e2 --- /dev/null +++ b/src/client/java/online/connlost/ConfigSync.java @@ -0,0 +1,38 @@ +package online.connlost; + +import online.connlost.server.config.ConfigManager; +import online.connlost.util.ItemsHelper; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +public class ConfigSync { + private static final ItemsHelper itemsHelper = ItemsHelper.getItemsHelper(); + + /** + * Items' stacksize is directly modified, no config is held for that in the "client" side. + * In contrast, we do store rules in client side as some mixins in client side classes need it. + * @param configList the config list + */ + public static void syncConfig(ArrayList> configList){ + AllStackable.LOGGER.info("[All Stackable] [Client] Sync config from server side!"); + itemsHelper.setCountByConfig(configList.get(0).entrySet(), false); + ConfigManager.getConfigManager().setRulesMap(configList.get(1)); + AllStackable.LOGGER.info("[All Stackable] [Client] Sync rules:"); + for (Map.Entry rule: configList.get(1).entrySet()){ + String tag = switch (rule.getValue()) { + case 0 -> "false"; + case 1 -> "true"; + default -> rule.getValue().toString(); + }; + AllStackable.LOGGER.info("\t[{}] = {}", rule.getKey(), tag); + } + AllStackable.LOGGER.info("[All Stackable] [Client] Sync finished."); + } + + public static void resetConfig(){ + itemsHelper.resetAll(false); + ConfigManager.getConfigManager().setRulesMap(ConfigManager.getConfigManager().defaultRules(false)); + } +} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinMinecraftClientGame.java b/src/client/java/online/connlost/mixin/MixinMinecraftClient.java similarity index 65% rename from src/main/java/online/connlost/allstackable/mixin/MixinMinecraftClientGame.java rename to src/client/java/online/connlost/mixin/MixinMinecraftClient.java index 60504d1..c0d4b07 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinMinecraftClientGame.java +++ b/src/client/java/online/connlost/mixin/MixinMinecraftClient.java @@ -1,6 +1,6 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.client.ConfigSync; +import online.connlost.ConfigSync; import net.minecraft.client.MinecraftClient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -8,8 +8,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MinecraftClient.class) -public abstract class MixinMinecraftClientGame { - @Inject(method = "disconnect", at=@At("RETURN")) +public abstract class MixinMinecraftClient { + @Inject(method = "disconnect()V", at=@At("RETURN")) private void resetMaxCount(CallbackInfo ci){ ConfigSync.resetConfig(); } diff --git a/src/client/resources/allstackable.client.mixins.json b/src/client/resources/allstackable.client.mixins.json new file mode 100644 index 0000000..885785e --- /dev/null +++ b/src/client/resources/allstackable.client.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "online.connlost.mixin", + "compatibilityLevel": "JAVA_21", + "client": [ + "MixinMinecraftClient" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/src/main/java/online/connlost/AllStackable.java b/src/main/java/online/connlost/AllStackable.java new file mode 100644 index 0000000..1fabbb7 --- /dev/null +++ b/src/main/java/online/connlost/AllStackable.java @@ -0,0 +1,23 @@ +package online.connlost; + +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import online.connlost.server.Server; +import online.connlost.server.command.StackSizeCommand; +import online.connlost.util.ByteArrayPayload; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; + +public class AllStackable implements ModInitializer { + public static final Logger LOGGER = LogManager.getLogger(); + + @Override + public void onInitialize() { + PayloadTypeRegistry.playS2C().register(ByteArrayPayload.ID, ByteArrayPayload.CODEC); + LOGGER.info("[All Stackable] Start loading!"); + StackSizeCommand.register(); + LOGGER.info("[All Stackable] Command registered."); + ServerLifecycleEvents.SERVER_STARTED.register(Server::onServerLoaded); + } +} diff --git a/src/main/java/online/connlost/allstackable/AllStackableInit.java b/src/main/java/online/connlost/allstackable/AllStackableInit.java deleted file mode 100644 index d0a40e5..0000000 --- a/src/main/java/online/connlost/allstackable/AllStackableInit.java +++ /dev/null @@ -1,28 +0,0 @@ -package online.connlost.allstackable; - -import online.connlost.allstackable.server.Server; -import online.connlost.allstackable.server.command.StackSizeCommand; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import net.fabricmc.api.ModInitializer; -import net.minecraft.util.Identifier; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; - -public class AllStackableInit implements ModInitializer { - public static final Identifier SHARE_CONFIG_PACKET_ID = new Identifier("allstackable", "config"); - public static final Logger LOGGER = LogManager.getLogger(); - - - @Override - public void onInitialize() { - LOGGER.info("[All Stackable] Start loading!"); - StackSizeCommand.register(); - LOGGER.info("[All Stackable] Command registered."); - ServerLifecycleEvents.SERVER_STARTED.register(server -> { - Server.onServerLoaded(server); - }); - - } - - -} diff --git a/src/main/java/online/connlost/allstackable/client/ConfigSync.java b/src/main/java/online/connlost/allstackable/client/ConfigSync.java deleted file mode 100644 index 55dd53e..0000000 --- a/src/main/java/online/connlost/allstackable/client/ConfigSync.java +++ /dev/null @@ -1,40 +0,0 @@ -package online.connlost.allstackable.client; - -import online.connlost.allstackable.server.config.ConfigManager; -import online.connlost.allstackable.util.ItemsHelper; -import online.connlost.allstackable.AllStackableInit; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.Map; - -public class ConfigSync { - private static ItemsHelper itemsHelper = ItemsHelper.getItemsHelper(); - - /** - * Items' stacksize is directly modified, no config is held for that in the "client" side. - * In contrast, we do store rules in client side as some mixins in client side classes need it. - * @param configList - */ - public static void syncConfig(ArrayList> configList){ - AllStackableInit.LOGGER.info("[All Stackable] [Client] Sync config from server side!"); - itemsHelper.setCountByConfig(configList.get(0).entrySet(), false); - ConfigManager.getConfigManager().setRulesMap(configList.get(1)); - AllStackableInit.LOGGER.info("[All Stackable] [Client] Sync rules:"); - for (Map.Entry rule: configList.get(1).entrySet()){ - String tag; - switch (rule.getValue()){ - case 0: tag = "false";break; - case 1: tag = "true";break; - default: tag = rule.getValue().toString(); - } - AllStackableInit.LOGGER.info("\t["+rule.getKey()+"] = "+tag); - } - AllStackableInit.LOGGER.info("[All Stackable] [Client] Sync finished."); - } - - public static void resetConfig(){ - itemsHelper.resetAll(false); - ConfigManager.getConfigManager().setRulesMap(ConfigManager.getConfigManager().defaultRules(false)); - } -} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior9.java b/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior9.java deleted file mode 100644 index b162041..0000000 --- a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior9.java +++ /dev/null @@ -1,27 +0,0 @@ -package online.connlost.allstackable.mixin; - -import net.minecraft.block.entity.DispenserBlockEntity; -import net.minecraft.item.ItemStack; -import online.connlost.allstackable.util.IDispenserBlockEntity; -import online.connlost.allstackable.util.ItemsHelper; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$9") -public class MixinDispenserBehavior9 { - - @Redirect( - method = "dispenseSilently", - at = @At( - target = "Lnet/minecraft/block/entity/DispenserBlockEntity;addToFirstFreeSlot(Lnet/minecraft/item/ItemStack;)I", - value = "INVOKE" - )) - public int tryStack(DispenserBlockEntity instance, ItemStack stack) { - int ret = instance.addToFirstFreeSlot(stack); - if(ItemsHelper.isModified(stack) && ret < 0) { - ret = ((IDispenserBlockEntity) instance).tryInsertAndStackItem(stack) ? 1 : -1; - } - return ret; - } -} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinItem.java b/src/main/java/online/connlost/allstackable/mixin/MixinItem.java deleted file mode 100644 index a757299..0000000 --- a/src/main/java/online/connlost/allstackable/mixin/MixinItem.java +++ /dev/null @@ -1,54 +0,0 @@ -package online.connlost.allstackable.mixin; - -import online.connlost.allstackable.util.IItemMaxCount; -import net.minecraft.item.Item; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(Item.class) -public abstract class MixinItem implements IItemMaxCount { - @Final - @Mutable - @Shadow - private int maxCount; - - private int vanillaMaxCount; - - @Override - public void revert() { - this.maxCount = vanillaMaxCount; - } - - - @Override - public void setMaxCount(int i) { - this.maxCount = i; - } - - @Override - public int getVanillaMaxCount() { - return vanillaMaxCount; - } - - @Override - public void setVanillaMaxCount(int vanillaMaxCount) { - this.vanillaMaxCount = vanillaMaxCount; - } - - @Inject(method = "", at = @At("RETURN")) - private void setVanillaMaxCount(Item.Settings settings, CallbackInfo ci) { - setVanillaMaxCount(this.maxCount); - } - - @Redirect(method = "isEnchantable", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxCount()I")) - private int isVanillaEnchantable(Item item) { - return ((IItemMaxCount) item).getVanillaMaxCount(); - } - -} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinMushroomStewItem.java b/src/main/java/online/connlost/allstackable/mixin/MixinMushroomStewItem.java deleted file mode 100644 index 5af8aaf..0000000 --- a/src/main/java/online/connlost/allstackable/mixin/MixinMushroomStewItem.java +++ /dev/null @@ -1,26 +0,0 @@ -package online.connlost.allstackable.mixin; - -import online.connlost.allstackable.util.ItemsHelper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.*; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(StewItem.class) -public class MixinMushroomStewItem { - - @Inject(method = "finishUsing", at = @At(value = "NEW", target = "net/minecraft/item/ItemStack"), cancellable = true) - private void stackableStew(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable cir) { - // >= 1 because it is decreased by 1 before our code execution - if (ItemsHelper.isModified(stack) && stack.getCount() >= 1) { - if (user instanceof PlayerEntity) { - ItemsHelper.insertNewItem((PlayerEntity) user, new ItemStack(Items.BOWL)); - } - cir.setReturnValue(stack); - } - } -} diff --git a/src/main/java/online/connlost/allstackable/util/NetworkHelper.java b/src/main/java/online/connlost/allstackable/util/NetworkHelper.java deleted file mode 100644 index 0c824b4..0000000 --- a/src/main/java/online/connlost/allstackable/util/NetworkHelper.java +++ /dev/null @@ -1,37 +0,0 @@ -package online.connlost.allstackable.util; - -import io.netty.buffer.Unpooled; -import online.connlost.allstackable.AllStackableInit; -import online.connlost.allstackable.server.Server; -import online.connlost.allstackable.server.config.ConfigManager; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.server.network.ServerPlayerEntity; - -import java.util.List; - -import static online.connlost.allstackable.AllStackableInit.LOGGER; - -public class NetworkHelper { - - public static void sentConfigToAll(){ - if (Server.minecraft_server != null){ - List players = Server.minecraft_server.getPlayerManager().getPlayerList(); - for (ServerPlayerEntity player:players){ - sentConfigToPlayer(player); - } - } else { - LOGGER.warn("[All Stackable] Server hasn't been loaded."); - } - } - - public static void sentConfigToPlayer(ServerPlayerEntity player){ - PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer()); - passedData.writeByteArray(ConfigManager.getConfigManager().getSerializedConfig()); - ServerPlayNetworking.send( - player, - AllStackableInit.SHARE_CONFIG_PACKET_ID, - passedData - ); - } -} diff --git a/src/main/java/online/connlost/allstackable/mixin/AccessorFurnaceInventory.java b/src/main/java/online/connlost/mixin/AccessorFurnaceInventory.java similarity index 89% rename from src/main/java/online/connlost/allstackable/mixin/AccessorFurnaceInventory.java rename to src/main/java/online/connlost/mixin/AccessorFurnaceInventory.java index fc82de3..6f26912 100644 --- a/src/main/java/online/connlost/allstackable/mixin/AccessorFurnaceInventory.java +++ b/src/main/java/online/connlost/mixin/AccessorFurnaceInventory.java @@ -1,4 +1,4 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinAbstractFurnaceBlockEntity.java b/src/main/java/online/connlost/mixin/MixinAbstractFurnaceBlockEntity.java similarity index 93% rename from src/main/java/online/connlost/allstackable/mixin/MixinAbstractFurnaceBlockEntity.java rename to src/main/java/online/connlost/mixin/MixinAbstractFurnaceBlockEntity.java index 306d422..7f71a5e 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinAbstractFurnaceBlockEntity.java +++ b/src/main/java/online/connlost/mixin/MixinAbstractFurnaceBlockEntity.java @@ -1,4 +1,4 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; @@ -6,7 +6,7 @@ import net.minecraft.util.ItemScatterer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import org.spongepowered.asm.mixin.Mixin; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinAnvilScreenHandler.java b/src/main/java/online/connlost/mixin/MixinAnvilScreenHandler.java similarity index 92% rename from src/main/java/online/connlost/allstackable/mixin/MixinAnvilScreenHandler.java rename to src/main/java/online/connlost/mixin/MixinAnvilScreenHandler.java index 390f8e4..ef3c660 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinAnvilScreenHandler.java +++ b/src/main/java/online/connlost/mixin/MixinAnvilScreenHandler.java @@ -1,7 +1,7 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.IItemMaxCount; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.IItemMaxCount; +import online.connlost.util.ItemsHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinAxolotlEntity.java b/src/main/java/online/connlost/mixin/MixinAxolotlEntity.java similarity index 93% rename from src/main/java/online/connlost/allstackable/mixin/MixinAxolotlEntity.java rename to src/main/java/online/connlost/mixin/MixinAxolotlEntity.java index fddd3fc..b7b84b2 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinAxolotlEntity.java +++ b/src/main/java/online/connlost/mixin/MixinAxolotlEntity.java @@ -1,11 +1,11 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.entity.passive.AxolotlEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.Hand; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinBucketItem.java b/src/main/java/online/connlost/mixin/MixinBucketItem.java similarity index 90% rename from src/main/java/online/connlost/allstackable/mixin/MixinBucketItem.java rename to src/main/java/online/connlost/mixin/MixinBucketItem.java index a675d69..d0e8f6a 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinBucketItem.java +++ b/src/main/java/online/connlost/mixin/MixinBucketItem.java @@ -1,6 +1,6 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BucketItem; import net.minecraft.item.ItemStack; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinCauldronBlock.java b/src/main/java/online/connlost/mixin/MixinCauldronBlock.java similarity index 67% rename from src/main/java/online/connlost/allstackable/mixin/MixinCauldronBlock.java rename to src/main/java/online/connlost/mixin/MixinCauldronBlock.java index 7000631..d181ebb 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinCauldronBlock.java +++ b/src/main/java/online/connlost/mixin/MixinCauldronBlock.java @@ -1,6 +1,7 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; +import net.minecraft.util.ItemActionResult; import net.minecraft.block.*; import net.minecraft.block.cauldron.CauldronBehavior; import net.minecraft.entity.player.PlayerEntity; @@ -11,6 +12,7 @@ import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -20,19 +22,20 @@ @Mixin(AbstractCauldronBlock.class) public class MixinCauldronBlock { + @Final @Shadow - CauldronBehavior.CauldronBehaviorMap behaviorMap; + protected CauldronBehavior.CauldronBehaviorMap behaviorMap; CauldronBehavior CLEAN_STACKED_SHULKER_BOX = (state, world, pos, player, hand, stack) -> { Block block = Block.getBlockFromItem(stack.getItem()); if (!(block instanceof ShulkerBoxBlock)) { - return ActionResult.PASS; + return ItemActionResult.SUCCESS; } else { if (!world.isClient) { ItemStack itemStack = new ItemStack(Blocks.SHULKER_BOX); - if (stack.hasNbt()) { - itemStack.setNbt(stack.getNbt().copy()); + if (!stack.getComponents().isEmpty()) { + itemStack.applyComponentsFrom(stack.getComponents()); } ItemsHelper.insertNewItem(player, itemStack); stack.decrement(1); @@ -40,12 +43,12 @@ public class MixinCauldronBlock { LeveledCauldronBlock.decrementFluidLevel(state, world, pos); } - return ActionResult.success(world.isClient); + return ItemActionResult.success(world.isClient); } }; - @Inject(method = "onUse", at=@At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"), cancellable = true) - private void cleanStackedShulkerBox(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir){ + @Inject(method = "onUseWithItem", at=@At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"), cancellable = true) + private void cleanStackedShulkerBox(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir){ ItemStack itemStack = player.getStackInHand(hand); if (ItemsHelper.isModified(itemStack) && itemStack.getCount() > 1) { if(behaviorMap.map().get(itemStack.getItem()) == CauldronBehavior.CLEAN_SHULKER_BOX){ diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior20.java b/src/main/java/online/connlost/mixin/MixinDispenserBehavior20.java similarity index 75% rename from src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior20.java rename to src/main/java/online/connlost/mixin/MixinDispenserBehavior20.java index 28212fd..f347042 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior20.java +++ b/src/main/java/online/connlost/mixin/MixinDispenserBehavior20.java @@ -1,11 +1,11 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.block.dispenser.ItemDispenserBehavior; import net.minecraft.block.entity.DispenserBlockEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPointer; -import online.connlost.allstackable.util.IDispenserBlockEntity; +import online.connlost.util.IDispenserBlockEntity; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,12 +13,12 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$20") +@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$15") public class MixinDispenserBehavior20 { @Shadow @Final - private ItemDispenserBehavior fallback; + private ItemDispenserBehavior fallbackBehavior; @Inject( method = "dispenseSilently", @@ -28,9 +28,9 @@ public class MixinDispenserBehavior20 { private void decreaseOne(BlockPointer pointer, ItemStack stack, CallbackInfoReturnable cir) { // dispense empty bottle if dispenser is full // if (((DispenserBlockEntity) pointer.getBlockEntity()).addToFirstFreeSlot(new ItemStack(Items.GLASS_BOTTLE)) < 0) { - if (!((IDispenserBlockEntity)pointer.blockEntity()).tryInsertAndStackItem(new ItemStack(Items.GLASS_BOTTLE))) { - this.fallback.dispense(pointer, new ItemStack(Items.GLASS_BOTTLE)); - } + if (!((IDispenserBlockEntity)pointer.blockEntity()).tryInsertAndStackItem(new ItemStack(Items.GLASS_BOTTLE))) { + this.fallbackBehavior.dispense(pointer, new ItemStack(Items.GLASS_BOTTLE)); + } // } stack.decrement(1); cir.setReturnValue(stack); diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior8.java b/src/main/java/online/connlost/mixin/MixinDispenserBehavior8.java similarity index 79% rename from src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior8.java rename to src/main/java/online/connlost/mixin/MixinDispenserBehavior8.java index 07c5fc6..332c44f 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBehavior8.java +++ b/src/main/java/online/connlost/mixin/MixinDispenserBehavior8.java @@ -1,9 +1,8 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.IDispenserBlockEntity; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.IDispenserBlockEntity; +import online.connlost.util.ItemsHelper; import net.minecraft.block.dispenser.ItemDispenserBehavior; -import net.minecraft.block.entity.DispenserBlockEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPointer; @@ -14,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$8") +@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$15") public class MixinDispenserBehavior8 { @Shadow @Final @@ -39,9 +38,9 @@ public void dispenseOne(BlockPointer pointer, ItemStack stack, CallbackInfoRetur ItemStack newStack = stack.copy(); newStack.decrement(1); // if (((DispenserBlockEntity) pointer.getBlockEntity()).addToFirstFreeSlot(Items.BUCKET.getDefaultStack()) < 0) { - if (!((IDispenserBlockEntity) pointer.blockEntity()).tryInsertAndStackItem(Items.BUCKET.getDefaultStack())) { - this.fallbackBehavior.dispense(pointer, Items.BUCKET.getDefaultStack()); - } + if (!((IDispenserBlockEntity) pointer.blockEntity()).tryInsertAndStackItem(Items.BUCKET.getDefaultStack())) { + this.fallbackBehavior.dispense(pointer, Items.BUCKET.getDefaultStack()); + } // } cir.setReturnValue(newStack); } diff --git a/src/main/java/online/connlost/mixin/MixinDispenserBehavior9.java b/src/main/java/online/connlost/mixin/MixinDispenserBehavior9.java new file mode 100644 index 0000000..7d299da --- /dev/null +++ b/src/main/java/online/connlost/mixin/MixinDispenserBehavior9.java @@ -0,0 +1,32 @@ +package online.connlost.mixin; + +import net.minecraft.item.ItemStack; +import online.connlost.util.IDispenserBlockEntity; +import online.connlost.util.ItemsHelper; +import net.minecraft.util.math.BlockPointer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$9") +public class MixinDispenserBehavior9 { + + @Inject(method = "dispenseSilently", at = @At("HEAD"), cancellable = true) + public void tryStack(BlockPointer pointer, ItemStack stack, CallbackInfoReturnable cir) { + // Add the item to the first free slot and get the remaining stack + ItemStack remainingStack = pointer.blockEntity().addToFirstFreeSlot(stack); + + // Check if the item is modified and if there's any remaining item stack after the operation + if (ItemsHelper.isModified(stack) && !remainingStack.isEmpty()) { + // Attempt custom logic to stack the remaining item + boolean success = ((IDispenserBlockEntity) pointer.blockEntity()).tryInsertAndStackItem(remainingStack); + + // If custom stacking succeeds, cancel further execution and return an empty stack + if (success) { + cir.setReturnValue(ItemStack.EMPTY); + cir.cancel(); + } + } + } +} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBlockEntity.java b/src/main/java/online/connlost/mixin/MixinDispenserBlockEntity.java similarity index 89% rename from src/main/java/online/connlost/allstackable/mixin/MixinDispenserBlockEntity.java rename to src/main/java/online/connlost/mixin/MixinDispenserBlockEntity.java index 62b8c1b..1a86362 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinDispenserBlockEntity.java +++ b/src/main/java/online/connlost/mixin/MixinDispenserBlockEntity.java @@ -1,9 +1,9 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.block.entity.DispenserBlockEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.collection.DefaultedList; -import online.connlost.allstackable.util.IDispenserBlockEntity; +import online.connlost.util.IDispenserBlockEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinHorseScreenHandler.java b/src/main/java/online/connlost/mixin/MixinHorseScreenHandler.java similarity index 90% rename from src/main/java/online/connlost/allstackable/mixin/MixinHorseScreenHandler.java rename to src/main/java/online/connlost/mixin/MixinHorseScreenHandler.java index 2099533..b563ad8 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinHorseScreenHandler.java +++ b/src/main/java/online/connlost/mixin/MixinHorseScreenHandler.java @@ -1,4 +1,4 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.inventory.Inventory; import net.minecraft.screen.slot.Slot; diff --git a/src/main/java/online/connlost/mixin/MixinItem.java b/src/main/java/online/connlost/mixin/MixinItem.java new file mode 100644 index 0000000..ea2c82a --- /dev/null +++ b/src/main/java/online/connlost/mixin/MixinItem.java @@ -0,0 +1,61 @@ +package online.connlost.mixin; + +import net.minecraft.component.ComponentMap; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.item.ItemStack; +import online.connlost.util.IItemMaxCount; +import net.minecraft.item.Item; +import online.connlost.util.ItemsHelper; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Item.class) +public abstract class MixinItem implements IItemMaxCount { + @Mutable + @Final + @Shadow private ComponentMap components; + + @Unique + private int vanillaMaxCount; + + @Override + public void revert() { + setMaxCount(vanillaMaxCount); + } + + @Override + public void setMaxCount(int i) { + ComponentMap.Builder builder = ComponentMap.builder().addAll(this.components); + builder.add(DataComponentTypes.MAX_STACK_SIZE, i); + this.components = builder.build(); + } + + @Override + public int getVanillaMaxCount() { + return vanillaMaxCount; + } + + @Override + public void setVanillaMaxCount(int vanillaMaxCount) { + this.vanillaMaxCount = vanillaMaxCount; + } + + @Inject(method = "", at = @At("RETURN")) + private void setVanillaMaxCount(Item.Settings settings, CallbackInfo ci) { + setVanillaMaxCount((Integer) this.components.getOrDefault(DataComponentTypes.MAX_STACK_SIZE, ItemsHelper.ItemMaxCount)); + } + + @Inject(method = "getMaxCount", at = @At("HEAD"), cancellable = true) + private void injectGetMaxCount(CallbackInfoReturnable cir) { + cir.setReturnValue((Integer) this.components.getOrDefault(DataComponentTypes.MAX_STACK_SIZE, ItemsHelper.ItemMaxCount)); + } + + @Redirect(method = "isEnchantable", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getMaxCount()I")) + private int redirectGetMaxCount(ItemStack instance) { + return ((IItemMaxCount) instance.getItem()).getVanillaMaxCount(); + } +} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinItemStack.java b/src/main/java/online/connlost/mixin/MixinItemStack.java similarity index 61% rename from src/main/java/online/connlost/allstackable/mixin/MixinItemStack.java rename to src/main/java/online/connlost/mixin/MixinItemStack.java index a6d99f2..272caa9 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinItemStack.java +++ b/src/main/java/online/connlost/mixin/MixinItemStack.java @@ -1,8 +1,8 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.util.math.random.Random; -import online.connlost.allstackable.server.config.ConfigManager; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.server.config.ConfigManager; +import online.connlost.util.ItemsHelper; import net.minecraft.block.ShulkerBoxBlock; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; @@ -27,20 +27,20 @@ private void preventItemSBoxStack(CallbackInfoReturnable cir) { } } } - } - @Redirect(method = "damage(ILnet/minecraft/util/math/random/Random;Lnet/minecraft/server/network/ServerPlayerEntity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setDamage(I)V")) - private void splitStackedTools(ItemStack stack, int damage, int amount, Random random, @Nullable ServerPlayerEntity player){ + @Redirect(method = "damage(ILnet/minecraft/server/world/ServerWorld;Lnet/minecraft/server/network/ServerPlayerEntity;Ljava/util/function/Consumer;)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setDamage(I)V")) + private void splitStackedTools(ItemStack instance, int damage) { ItemStack rest = null; - if (stack.getCount()>1 && ItemsHelper.isModified(stack) && player!=null){ - rest = stack.copy(); + if (instance.getCount() > 1 && ItemsHelper.isModified(instance) && instance.getHolder() != null && instance.getHolder().isPlayer()) { + rest = instance.copy(); rest.decrement(1); - stack.setCount(1); + instance.setCount(1); } - stack.setDamage(damage); - if (rest != null){ - ItemsHelper.insertNewItem(player,rest); + instance.setDamage(damage); + if (rest != null) { + ItemsHelper.insertNewItem((ServerPlayerEntity) instance.getHolder(), rest); } } } diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinJukeboxBlockEntity.java b/src/main/java/online/connlost/mixin/MixinJukeboxBlockEntity.java similarity index 89% rename from src/main/java/online/connlost/allstackable/mixin/MixinJukeboxBlockEntity.java rename to src/main/java/online/connlost/mixin/MixinJukeboxBlockEntity.java index 20cfa3d..92e0fef 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinJukeboxBlockEntity.java +++ b/src/main/java/online/connlost/mixin/MixinJukeboxBlockEntity.java @@ -1,6 +1,6 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import net.minecraft.block.entity.JukeboxBlockEntity; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinMilkBucketItem.java b/src/main/java/online/connlost/mixin/MixinMilkBucketItem.java similarity index 88% rename from src/main/java/online/connlost/allstackable/mixin/MixinMilkBucketItem.java rename to src/main/java/online/connlost/mixin/MixinMilkBucketItem.java index 41bfb65..cfb7227 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinMilkBucketItem.java +++ b/src/main/java/online/connlost/mixin/MixinMilkBucketItem.java @@ -1,6 +1,6 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -15,7 +15,7 @@ @Mixin(MilkBucketItem.class) public class MixinMilkBucketItem { - @Inject(method = "finishUsing", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/item/ItemStack;decrement(I)V"), cancellable = true) + @Inject(method = "finishUsing", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/item/ItemStack;decrementUnlessCreative(ILnet/minecraft/entity/LivingEntity;)V"), cancellable = true) private void stackableMilkBucket(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable cir) { if (!stack.isEmpty() && ItemsHelper.isModified(stack) && stack.getCount() > 1) { if (!world.isClient) diff --git a/src/main/java/online/connlost/mixin/MixinMushroomStewItem.java b/src/main/java/online/connlost/mixin/MixinMushroomStewItem.java new file mode 100644 index 0000000..9a742f7 --- /dev/null +++ b/src/main/java/online/connlost/mixin/MixinMushroomStewItem.java @@ -0,0 +1,34 @@ +package online.connlost.mixin; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import online.connlost.util.ItemsHelper; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Items; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Item.class) +public class MixinMushroomStewItem { + + @Inject(method = "finishUsing", at = @At("HEAD"), cancellable = true) + private void stackableStew(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable cir) { + // Check if the item is MUSHROOM_STEW + if (stack.getItem() == Items.MUSHROOM_STEW) { + // Check if the stack is modified and the stack size is greater than or equal to 1 + // >= 1 because it is decreased by 1 before our code execution + if (ItemsHelper.isModified(stack) && stack.getCount() >= 1) { + if (user instanceof PlayerEntity player) { + // Insert a bowl into the player's inventory instead of replacing the stew with a bowl + ItemsHelper.insertNewItem(player, new ItemStack(Items.BOWL)); + } + // Cancel the original logic and return the current stack (to keep the stew stackable) + cir.setReturnValue(stack); + } + } + } +} diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinPlayerManager.java b/src/main/java/online/connlost/mixin/MixinPlayerManager.java similarity index 88% rename from src/main/java/online/connlost/allstackable/mixin/MixinPlayerManager.java rename to src/main/java/online/connlost/mixin/MixinPlayerManager.java index 9fbc83c..9ebe812 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinPlayerManager.java +++ b/src/main/java/online/connlost/mixin/MixinPlayerManager.java @@ -1,7 +1,7 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.server.network.ConnectedClientData; -import online.connlost.allstackable.server.Server; +import online.connlost.server.Server; import net.minecraft.network.ClientConnection; import net.minecraft.server.PlayerManager; import net.minecraft.server.network.ServerPlayerEntity; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinPotionItem.java b/src/main/java/online/connlost/mixin/MixinPotionItem.java similarity index 88% rename from src/main/java/online/connlost/allstackable/mixin/MixinPotionItem.java rename to src/main/java/online/connlost/mixin/MixinPotionItem.java index 62bcd5b..6d5db38 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinPotionItem.java +++ b/src/main/java/online/connlost/mixin/MixinPotionItem.java @@ -1,10 +1,10 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.PotionItem; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinPowderSnowBucketItem.java b/src/main/java/online/connlost/mixin/MixinPowderSnowBucketItem.java similarity index 91% rename from src/main/java/online/connlost/allstackable/mixin/MixinPowderSnowBucketItem.java rename to src/main/java/online/connlost/mixin/MixinPowderSnowBucketItem.java index e48fa0d..3dd2bc7 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinPowderSnowBucketItem.java +++ b/src/main/java/online/connlost/mixin/MixinPowderSnowBucketItem.java @@ -1,6 +1,6 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.util.Hand; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinServerPlayNetworkHandler.java b/src/main/java/online/connlost/mixin/MixinServerPlayNetworkHandler.java similarity index 96% rename from src/main/java/online/connlost/allstackable/mixin/MixinServerPlayNetworkHandler.java rename to src/main/java/online/connlost/mixin/MixinServerPlayNetworkHandler.java index c6ac090..e695b42 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinServerPlayNetworkHandler.java +++ b/src/main/java/online/connlost/mixin/MixinServerPlayNetworkHandler.java @@ -1,7 +1,7 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; import net.minecraft.server.filter.FilteredMessage; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import net.minecraft.item.ItemStack; import net.minecraft.server.filter.TextStream; import net.minecraft.server.network.ServerPlayNetworkHandler; diff --git a/src/main/java/online/connlost/allstackable/mixin/MixinSuspiciousStewItem.java b/src/main/java/online/connlost/mixin/MixinSuspiciousStewItem.java similarity index 82% rename from src/main/java/online/connlost/allstackable/mixin/MixinSuspiciousStewItem.java rename to src/main/java/online/connlost/mixin/MixinSuspiciousStewItem.java index 38747ad..e179386 100644 --- a/src/main/java/online/connlost/allstackable/mixin/MixinSuspiciousStewItem.java +++ b/src/main/java/online/connlost/mixin/MixinSuspiciousStewItem.java @@ -1,6 +1,6 @@ -package online.connlost.allstackable.mixin; +package online.connlost.mixin; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.util.ItemsHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -15,7 +15,7 @@ @Mixin(SuspiciousStewItem.class) public class MixinSuspiciousStewItem { - @Inject(method = "finishUsing", at = @At(value = "NEW", target = "net/minecraft/item/ItemStack"), cancellable = true) + @Inject(method = "finishUsing", at = @At(value = "HEAD"), cancellable = true) private void stackableStew(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable cir) { // >= 1 because it is decreased by 1 before our code execution if (ItemsHelper.isModified(stack) && stack.getCount() >= 1) { @@ -26,3 +26,4 @@ private void stackableStew(ItemStack stack, World world, LivingEntity user, Call } } } + diff --git a/src/main/java/online/connlost/allstackable/server/Server.java b/src/main/java/online/connlost/server/Server.java similarity index 65% rename from src/main/java/online/connlost/allstackable/server/Server.java rename to src/main/java/online/connlost/server/Server.java index 8462b67..bbdd3ec 100644 --- a/src/main/java/online/connlost/allstackable/server/Server.java +++ b/src/main/java/online/connlost/server/Server.java @@ -1,11 +1,11 @@ -package online.connlost.allstackable.server; +package online.connlost.server; -import online.connlost.allstackable.server.config.ConfigManager; -import online.connlost.allstackable.util.NetworkHelper; +import online.connlost.server.config.ConfigManager; +import online.connlost.util.NetworkHelper; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.WorldSavePath; -import online.connlost.allstackable.AllStackableInit; +import online.connlost.AllStackable; public class Server { @@ -16,11 +16,11 @@ public static void onServerLoaded(MinecraftServer ms){ minecraft_server = ms; config_manager.passConfigFile(minecraft_server.getSavePath(WorldSavePath.ROOT).resolve("allstackable-config.json").toFile()); config_manager.setupConfig(); - AllStackableInit.LOGGER.info("[All Stackable] Loaded!"); + AllStackable.LOGGER.info("[All Stackable] Loaded!"); } public static void onPlayerJoin(ServerPlayerEntity player){ - NetworkHelper.sentConfigToPlayer(player); + NetworkHelper.sentConfigToPlayer(player, ConfigManager.getConfigManager().getSerializedConfig()); } } diff --git a/src/main/java/online/connlost/allstackable/server/command/StackSizeCommand.java b/src/main/java/online/connlost/server/command/StackSizeCommand.java similarity index 95% rename from src/main/java/online/connlost/allstackable/server/command/StackSizeCommand.java rename to src/main/java/online/connlost/server/command/StackSizeCommand.java index 13246a1..248fa53 100644 --- a/src/main/java/online/connlost/allstackable/server/command/StackSizeCommand.java +++ b/src/main/java/online/connlost/server/command/StackSizeCommand.java @@ -1,11 +1,11 @@ -package online.connlost.allstackable.server.command; +package online.connlost.server.command; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.text.Text; -import online.connlost.allstackable.server.config.ConfigManager; -import online.connlost.allstackable.util.ItemsHelper; +import online.connlost.server.config.ConfigManager; +import online.connlost.util.ItemsHelper; import static net.minecraft.server.command.CommandManager.literal; import static net.minecraft.server.command.CommandManager.argument; @@ -195,7 +195,7 @@ public static void register() { ) .then(literal("set") .then(argument("item", ItemStackArgumentType.itemStack(registryAccess)) - .then(argument("count", IntegerArgumentType.integer(1, 64)) + .then(argument("count", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) .executes(ctx -> setItem( ctx.getSource(), ItemStackArgumentType.getItemStackArgument(ctx, "item").getItem(), @@ -203,7 +203,7 @@ public static void register() { ) .then(literal("hand") .then(argument("targets", EntityArgumentType.player()) - .then(argument("count", IntegerArgumentType.integer(1, 64)) + .then(argument("count", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) .executes(ctx -> setItemOnHand( ctx.getSource(), EntityArgumentType.getPlayer(ctx, "targets"), @@ -211,8 +211,8 @@ public static void register() { ) ) .then(literal("vanilla") - .then(argument("vanillaSize", IntegerArgumentType.integer(1, 64)) - .then(argument("customSize", IntegerArgumentType.integer(1, 64)) + .then(argument("vanillaSize", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) + .then(argument("customSize", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) .executes(ctx -> setMatched( ctx.getSource(), "vanilla", @@ -223,8 +223,8 @@ public static void register() { ) ) .then(literal("modified") - .then(argument("previousSize", IntegerArgumentType.integer(1, 64)) - .then(argument("newSize", IntegerArgumentType.integer(1, 64)) + .then(argument("previousSize", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) + .then(argument("newSize", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) .executes(ctx -> setMatched( ctx.getSource(), "modified", @@ -235,8 +235,8 @@ public static void register() { ) ) .then(literal("all") - .then(argument("previousSize", IntegerArgumentType.integer(1, 64)) - .then(argument("newSize", IntegerArgumentType.integer(1, 64)) + .then(argument("previousSize", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) + .then(argument("newSize", IntegerArgumentType.integer(1, ItemsHelper.ItemMaxCount)) .executes(ctx -> setMatched( ctx.getSource(), "all", diff --git a/src/main/java/online/connlost/allstackable/server/config/ConfigManager.java b/src/main/java/online/connlost/server/config/ConfigManager.java similarity index 83% rename from src/main/java/online/connlost/allstackable/server/config/ConfigManager.java rename to src/main/java/online/connlost/server/config/ConfigManager.java index 48d6746..411c5b6 100644 --- a/src/main/java/online/connlost/allstackable/server/config/ConfigManager.java +++ b/src/main/java/online/connlost/server/config/ConfigManager.java @@ -1,4 +1,4 @@ -package online.connlost.allstackable.server.config; +package online.connlost.server.config; import java.io.*; import java.util.ArrayList; @@ -7,10 +7,10 @@ import com.google.common.reflect.TypeToken; import com.google.gson.Gson; -import online.connlost.allstackable.util.ItemsHelper; -import online.connlost.allstackable.util.NetworkHelper; +import online.connlost.util.ItemsHelper; +import online.connlost.util.NetworkHelper; import net.fabricmc.loader.api.FabricLoader; -import online.connlost.allstackable.AllStackableInit; +import online.connlost.AllStackable; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.SerializationUtils; @@ -62,7 +62,7 @@ public int getRuleSetting(String str) { if (configList.get(1).containsKey(str)) { return configList.get(1).get(str); } else { - AllStackableInit.LOGGER.error("[All Stackable] No such rule key"); + AllStackable.LOGGER.error("[All Stackable] No such rule key"); return -1; } } @@ -96,7 +96,7 @@ public void setupConfig() { loadConfig(); itemsHelper.setCountByConfig(this.configList.get(0).entrySet(), true); NetworkHelper.sentConfigToAll(); - AllStackableInit.LOGGER.info("[All Stackable] Config Loaded"); + AllStackable.LOGGER.info("[All Stackable] Config Loaded"); } public boolean restoreBackup() { @@ -107,17 +107,17 @@ public boolean restoreBackup() { }.getType()); if (tmp == null || tmp.size() != 2) { bk.delete(); - AllStackableInit.LOGGER.error("[All Stackable] Corrupted backup detected, removed."); + AllStackable.LOGGER.error("[All Stackable] Corrupted backup detected, removed."); return false; } configList = tmp; } catch (IOException e) { - AllStackableInit.LOGGER.error("[All Stackable] Failed to parse backup file"); + AllStackable.LOGGER.error("[All Stackable] Failed to parse backup file"); throw new RuntimeException("Could not parse backup file", e); } this.writeConfig(this.configFile, this.configList); this.setupConfig(); - AllStackableInit.LOGGER.info("[All Stackable] Backup config restored!"); + AllStackable.LOGGER.info("[All Stackable] Backup config restored!"); return true; } else { return false; @@ -132,12 +132,12 @@ public ArrayList> loadConfig() { }.getType()); if (configList == null || configList.size() != 2) { this.configFile.delete(); - AllStackableInit.LOGGER.error("[All Stackable] Corrupted config detected, reset."); + AllStackable.LOGGER.error("[All Stackable] Corrupted config detected, reset."); return loadConfig(); } configList.set(1, makeRulesUpdated(configList.get(1), false)); } catch (IOException e) { - AllStackableInit.LOGGER.error("[All Stackable] Failed to parse config"); + AllStackable.LOGGER.error("[All Stackable] Failed to parse config"); throw new RuntimeException("Could not parse config", e); } } else { @@ -146,20 +146,20 @@ public ArrayList> loadConfig() { String oldPath = path.substring(0, path.length() - "allstackable-config.json".length()) + "all_stackable.json"; File oldFile = new File(oldPath); if (oldFile.exists()) { - AllStackableInit.LOGGER.info("[All Stackable] Find config file for older version of AllStackable, converting!"); + AllStackable.LOGGER.info("[All Stackable] Find config file for older version of AllStackable, converting!"); this.initConfigList(); try (FileReader reader = new FileReader(oldFile)) { LinkedHashMap tmp = gson.fromJson(reader, new TypeToken>() { }.getType()); if (tmp == null) { oldFile.delete(); - AllStackableInit.LOGGER.error("[All Stackable] Corrupted old config detected, removed."); + AllStackable.LOGGER.error("[All Stackable] Corrupted old config detected, removed."); return loadConfig(); } configList.set(0, tmp); oldFile.delete(); } catch (IOException e) { - AllStackableInit.LOGGER.error("[All Stackable] Failed to parse old config"); + AllStackable.LOGGER.error("[All Stackable] Failed to parse old config"); throw new RuntimeException("Could not parse config", e); } } else { @@ -180,11 +180,11 @@ private void writeConfig(File configFile, ArrayList()); this.globalConfigList.add(this.defaultRules(true)); this.writeConfig(this.globalConfigFile, this.globalConfigList); - AllStackableInit.LOGGER.info("[All Stackable] New global config created, disabled by default."); + AllStackable.LOGGER.info("[All Stackable] New global config created, disabled by default."); } } @@ -303,7 +303,7 @@ private LinkedHashMap makeRulesUpdated(LinkedHashMap ID = new CustomPayload.Id<>(Identifier.of("allstackable", "config")); + public static final PacketCodec CODEC = PacketCodec.tuple( + PacketCodecs.BYTE_ARRAY, ByteArrayPayload::data, + ByteArrayPayload::new + ); + + @Override + public CustomPayload.Id getId() { + return ID; + } +} diff --git a/src/main/java/online/connlost/allstackable/util/IDispenserBlockEntity.java b/src/main/java/online/connlost/util/IDispenserBlockEntity.java similarity index 76% rename from src/main/java/online/connlost/allstackable/util/IDispenserBlockEntity.java rename to src/main/java/online/connlost/util/IDispenserBlockEntity.java index 7643122..60de738 100644 --- a/src/main/java/online/connlost/allstackable/util/IDispenserBlockEntity.java +++ b/src/main/java/online/connlost/util/IDispenserBlockEntity.java @@ -1,4 +1,4 @@ -package online.connlost.allstackable.util; +package online.connlost.util; import net.minecraft.item.ItemStack; diff --git a/src/main/java/online/connlost/allstackable/util/IItemMaxCount.java b/src/main/java/online/connlost/util/IItemMaxCount.java similarity index 79% rename from src/main/java/online/connlost/allstackable/util/IItemMaxCount.java rename to src/main/java/online/connlost/util/IItemMaxCount.java index 8a58f9b..7f8e980 100644 --- a/src/main/java/online/connlost/allstackable/util/IItemMaxCount.java +++ b/src/main/java/online/connlost/util/IItemMaxCount.java @@ -1,4 +1,4 @@ -package online.connlost.allstackable.util; +package online.connlost.util; public interface IItemMaxCount { void setMaxCount(int i); diff --git a/src/main/java/online/connlost/allstackable/util/ItemsHelper.java b/src/main/java/online/connlost/util/ItemsHelper.java similarity index 90% rename from src/main/java/online/connlost/allstackable/util/ItemsHelper.java rename to src/main/java/online/connlost/util/ItemsHelper.java index 7cf6ada..00030a7 100644 --- a/src/main/java/online/connlost/allstackable/util/ItemsHelper.java +++ b/src/main/java/online/connlost/util/ItemsHelper.java @@ -1,22 +1,22 @@ -package online.connlost.allstackable.util; +package online.connlost.util; +import net.minecraft.component.ComponentMap; +import net.minecraft.component.DataComponentTypes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; -import static online.connlost.allstackable.AllStackableInit.LOGGER; +import java.util.*; + +import static online.connlost.AllStackable.LOGGER; public class ItemsHelper { + public static final int ItemMaxCount = 99; private static ItemsHelper itemsHelper; private ItemsHelper() { @@ -45,8 +45,8 @@ public void resetItem(Item item) { public void setCountByConfig(Set> configSet, boolean serverSide) { resetAll(serverSide); for (Map.Entry entry : configSet) { - Item item = Registries.ITEM.get(new Identifier(entry.getKey())); - int size = Integer.min(entry.getValue(), 64); + Item item = Registries.ITEM.get(Identifier.of(entry.getKey())); + int size = Integer.min(entry.getValue(), ItemsHelper.ItemMaxCount); if (serverSide) LOGGER.info("[All Stackable] Set " + entry.getKey() + " to " + size); else @@ -153,12 +153,12 @@ private Set, Item>> getItemSet() { public static final int TAG_LONGARRAY = 12; public static boolean shulkerBoxHasItems(ItemStack stack) { - NbtCompound tag = stack.getNbt(); + ComponentMap tag = stack.getComponents(); - if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) + if (tag == null || !tag.contains(DataComponentTypes.BLOCK_ENTITY_DATA)) return false; - NbtCompound bet = tag.getCompound("BlockEntityTag"); + NbtCompound bet = Objects.requireNonNull(tag.get(DataComponentTypes.BLOCK_ENTITY_DATA)).copyNbt(); return bet.contains("Items", TAG_LIST) && !bet.getList("Items", TAG_COMPOUND).isEmpty(); } diff --git a/src/main/java/online/connlost/util/NetworkHelper.java b/src/main/java/online/connlost/util/NetworkHelper.java new file mode 100644 index 0000000..53da3bf --- /dev/null +++ b/src/main/java/online/connlost/util/NetworkHelper.java @@ -0,0 +1,29 @@ +package online.connlost.util; + +import online.connlost.server.Server; +import online.connlost.server.config.ConfigManager; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.server.network.ServerPlayerEntity; + +import java.util.List; + +import static online.connlost.AllStackable.LOGGER; + +public class NetworkHelper { + + public static void sentConfigToAll(){ + if (Server.minecraft_server != null){ + List players = Server.minecraft_server.getPlayerManager().getPlayerList(); + for (ServerPlayerEntity player:players){ + sentConfigToPlayer(player, ConfigManager.getConfigManager().getSerializedConfig()); + } + } else { + LOGGER.warn("[All Stackable] Server hasn't been loaded."); + } + } + + public static void sentConfigToPlayer(ServerPlayerEntity player, byte[] data) { + ByteArrayPayload payload = new ByteArrayPayload(data); + ServerPlayNetworking.send(player, payload); + } +} diff --git a/src/main/resources/allstackable.mixins.json b/src/main/resources/allstackable.mixins.json index 3cdc4c1..4bd6b0e 100644 --- a/src/main/resources/allstackable.mixins.json +++ b/src/main/resources/allstackable.mixins.json @@ -1,34 +1,28 @@ { - "required": true, - "minVersion": "0.7", - "package": "online.connlost.allstackable.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "MixinItem", - "MixinPlayerManager", - "MixinMushroomStewItem", - "MixinSuspiciousStewItem", - "MixinBucketItem", - "MixinMilkBucketItem", - "MixinItemStack", - "MixinPowderSnowBucketItem", - "MixinCauldronBlock", - "MixinAxolotlEntity", - "MixinAbstractFurnaceBlockEntity", - "MixinAnvilScreenHandler", - "MixinDispenserBehavior8", - "MixinDispenserBehavior9", - "MixinHorseScreenHandler", - "MixinServerPlayNetworkHandler", - "MixinJukeboxBlockEntity", - "AccessorFurnaceInventory", - "MixinPotionItem", - "MixinDispenserBlockEntity" - ], - "client": [ - "MixinMinecraftClientGame" - ], - "injectors": { - "defaultRequire": 1 - } -} + "required": true, + "package": "online.connlost.mixin", + "compatibilityLevel": "JAVA_21", + "mixins": [ + "MixinItem", + "MixinPlayerManager", + "MixinSuspiciousStewItem", + "MixinBucketItem", + "MixinItemStack", + "MixinPowderSnowBucketItem", + "MixinCauldronBlock", + "MixinAxolotlEntity", + "MixinAbstractFurnaceBlockEntity", + "MixinAnvilScreenHandler", + "MixinDispenserBehavior8", + "MixinDispenserBehavior9", + "MixinHorseScreenHandler", + "MixinServerPlayNetworkHandler", + "MixinJukeboxBlockEntity", + "AccessorFurnaceInventory", + "MixinPotionItem", + "MixinDispenserBlockEntity" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c50a700..fb1a719 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,40 +1,41 @@ { - "schemaVersion": 1, - "id": "allstackable", - "version": "${version}", - - "name": "AllStackable", - "description": "A highly customizable Fabric Mod that makes items stackable and allows you to change the stack size of them.", - "authors": [ - "Conn_Lost" - ], - "contact": { - "homepage": "https://www.curseforge.com/minecraft/mc-mods/all-stackable/", - "sources": "https://github.com/KrisCris/AllStackable" - }, - - "license": "GPL-3.0", - "icon": "assets/allstackable/icon.png", - - "environment": "*", - "entrypoints": { - "main": [ - "online.connlost.allstackable.AllStackableInit" - ], - "client": [ - "online.connlost.allstackable.client.AllStackableClientInit" - ] - }, - "mixins": [ - "allstackable.mixins.json" - ], - - "depends": { - "fabricloader": ">=0.14", - "fabric": "*", - "minecraft": ">=1.20" - }, - "suggests": { - "flamingo": "*" - } -} + "schemaVersion": 1, + "id": "allstackable", + "version": "${version}", + "name": "AllStackable", + "description": "A highly customizable Fabric Mod that makes items stackable and allows you to change the stack size of them.", + "authors": [ + "connlost" + ], + "contact": { + "homepage": "https://www.curseforge.com/minecraft/mc-mods/all-stackable/", + "sources": "https://github.com/KrisCris/AllStackable" + }, + "license": "GPL-3.0", + "icon": "assets/allstackable/icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "online.connlost.AllStackable" + ], + "client": [ + "online.connlost.AllStackableClient" + ] + }, + "mixins": [ + "allstackable.mixins.json", + { + "config": "allstackable.client.mixins.json", + "environment": "client" + } + ], + "depends": { + "fabricloader": ">=0.15.11", + "minecraft": "~1.21", + "java": ">=21", + "fabric-api": "*" + }, + "suggests": { + "another-mod": "*" + } +} \ No newline at end of file