Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the max potion stack size configurable #1

Open
wants to merge 1 commit into
base: 1.19.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ minecraft {
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.19.2'
mappings channel: 'official', version: "${mc_version}"

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

Expand Down Expand Up @@ -129,7 +129,7 @@ dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.2-43.2.4'
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"

// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=2.0
mod_version=3.0
mod_vendor=furreddraco
mod_id=stacking_potions

mc_version=1.19.2
mc_version=1.19.2
forge_version=43.2.21
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.furreddraco.stacking_potions;

import com.furreddraco.stacking_potions.config.StackingPotionsCommonConfig;
import com.mojang.logging.LogUtils;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.PotionItem;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
Expand All @@ -14,17 +17,19 @@
import java.lang.reflect.Field;

@Mod("stacking_potions")
public class stackingPotions
public class StackingPotions
{
private static final Logger LOGGER = LogUtils.getLogger();

public stackingPotions()
public StackingPotions()
{
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

modEventBus.addListener(this::commonSetup);

MinecraftForge.EVENT_BUS.register(this);

ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, StackingPotionsCommonConfig.SPEC, "stacking_potions.toml");
}

private void commonSetup(final FMLCommonSetupEvent event)
Expand All @@ -35,10 +40,10 @@ private void commonSetup(final FMLCommonSetupEvent event)
try {
Field stackSizeField = Item.class.getDeclaredField("f_41370_");
stackSizeField.setAccessible(true);
stackSizeField.set(item, 64);
LOGGER.info("stacking_potions: stack size for potion " + item.getDescriptionId() + "changed to 64");
stackSizeField.set(item, StackingPotionsCommonConfig.POTION_STACKING_LIMIT.get());
LOGGER.info("stacking_potions: stack size for potion " + item.getDescriptionId() + "changed to " + StackingPotionsCommonConfig.POTION_STACKING_LIMIT.get());
} catch (Exception ex) {
LOGGER.error("stacking_potions: " + ex.toString());
LOGGER.error("stacking_potions: " + ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.furreddraco.stacking_potions.config;

import net.minecraftforge.common.ForgeConfigSpec;

public class StackingPotionsCommonConfig {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;


public static final ForgeConfigSpec.ConfigValue<Integer> POTION_STACKING_LIMIT;


static {
BUILDER.push("Config for Stacking Potions");

POTION_STACKING_LIMIT = BUILDER.comment("The new potion stacking limit. Default is 64.")
.defineInRange("Potion Stacking Limit", 64, 1, 64);

BUILDER.pop();
SPEC = BUILDER.build();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ authors="Furred Draco" #optional

# The description text for the mod (multi line!) (#mandatory)
description='''
This mod allows potions to stack together
This mod allows potions to stack together to a configurable stack size.
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.stacking_potions]] #optional
Expand Down