first working poc

This commit is contained in:
alterNERDtive 2023-06-19 01:17:45 +02:00
parent 5ed9c2bedd
commit 3cb5ab8c7d
Signed by: alterNERDtive
GPG key ID: 547787A4FE6533F1
13 changed files with 537 additions and 7 deletions

View file

@ -0,0 +1,115 @@
package tv.alterNERD.VaultModTweaks;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
import net.minecraftforge.common.ForgeConfigSpec.Builder;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
public class Configuration {
public static final ForgeConfigSpec CONFIG;
public static BooleanValue FORTUNE_ENABLED;
public static IntValue FORTUNE_LEVEL;
public static BooleanValue JEWELER_ENABLED;
public static DoubleValue JEWELER_CHANCE;
public static BooleanValue JEWELS_ENABLED;
public static IntValue JEWELS_SIZE;
public static IntValue JEWELS_MAX;
public static IntValue JEWELS_MIN;
public static BooleanValue BUDDING_ENABLED;
public static IntValue BUDDING_MAX;
public static IntValue BUDDING_MIN;
public static BooleanValue VAULTAR_ENABLED;
public static IntValue VAULTAR_INFUSION_TIME;
public static BooleanValue FAKE_PLAYER_FIX;
public static BooleanValue ROUTER_VAULTAR_FIX;
public static BooleanValue FRAGMENT_WEIGHT_FIX;
public static BooleanValue JUNKMGMT_ENABLED;
public static ConfigValue<Integer> JUNKMGMT_T1;
public static ConfigValue<Integer> JUNKMGMT_T2;
public static ConfigValue<Integer> JUNKMGMT_T3;
public static ConfigValue<Integer> JUNKMGMT_T4;
static {
Builder builder = new Builder();
setupConfig(builder);
CONFIG = builder.build();
}
private static void setupConfig(Builder builder) {
// Fortune changes
builder.push("Fortune");
builder.comment("Replace the maximum Fortune level for the Vault Enchanter and remove the Fortunate Expertise");
FORTUNE_ENABLED = builder.define("enableOverride", true);
builder.comment("Maximum Fortune level");
FORTUNE_LEVEL = builder.defineInRange("maxLevel", 5, 3, 5);
builder.pop();
// Jeweler
builder.push("Jeweler");
builder.comment("Remove the Jeweler Expertise and change the default cutting chance accordingly");
JEWELER_ENABLED = builder.define("disableJeweler", true);
builder.comment("Chance to break the jewel / remove a modifier");
JEWELER_CHANCE = builder.defineInRange("breakChance", 0.25d, 0d, 0.5d);
builder.pop();
// Budding Crystal
builder.push("BuddingCrystal");
builder.comment("Change the Budding Crystal growth times (Sky Vaults only)");
BUDDING_ENABLED = builder.define("enableOverride", true);
builder.comment("Maximum time between growth stages (pack default: 400)");
BUDDING_MAX = builder.defineInRange("maxTime", 300, 300, 500);
builder.comment("Minimum time between growth stages (pack default: 280)");
BUDDING_MIN = builder.defineInRange("minTime", 200, 100, 299);
builder.pop();
// Jewels
builder.push("Jewels");
builder.comment("Change the max size for jewels and the size range for jewel cutting");
JEWELS_ENABLED = builder.define("enableOverride", true);
builder.comment("Maximum Jewel size (pack default: 90) (CURRENTLY NON-FUNCTIONAL)");
JEWELS_SIZE = builder.defineInRange("maxSize", 40, 10, 100);
builder.comment("Maximum size reduction when cutting (pack default: 10)");
JEWELS_MAX = builder.defineInRange("maxCut", 10, 5, 20);
builder.comment("Minimum size reduction when cutting (pack default: 1)");
JEWELS_MIN = builder.defineInRange("minCut", 3, 1, 4);
builder.pop();
// Vault Altar
builder.push("VaultAltar");
builder.comment("Enable Vaultar config overrides");
VAULTAR_ENABLED = builder.define("enableOverride", true);
builder.comment("The time it takes to infuse a crystal after giving a redstone signal (pack default: 5)");
VAULTAR_INFUSION_TIME = builder.defineInRange("infusionTime", 1, 1, 10);
builder.pop();
// Vault Charm / Junk Management
builder.push("JunkManagement");
builder.comment("Override Junk Charm multipliers for the Junk Management slots (pack defaults: 3/18/114/228)");
JUNKMGMT_ENABLED = builder.define("enableOverride", true);
builder.comment("These values will be multiplied by the default junk list size (9)");
JUNKMGMT_T1 = builder.define("tier1Multiplier", 28);
JUNKMGMT_T2 = builder.define("tier2Multiplier", 57);
JUNKMGMT_T3 = builder.define("tier3Multiplier", 114);
JUNKMGMT_T4 = builder.define("tier4Multiplier", 228);
builder.pop();
// Bug fixes
builder.push("Fixes");
builder.comment("Fix fake player research (e.g. Router + Botany Pots interaction, AE2 auto crafting, …) (CURRENTLY NON-FUNCTIONAL)");
FAKE_PLAYER_FIX = builder.define("fakePlayerResearchFix", true);
builder.comment("Fix Routers unable to place Vault Rocks on your Vaultar");
ROUTER_VAULTAR_FIX = builder.define("routerVaultarFix", true);
builder.comment("Fix №5 fragments of all relics having half the weight");
FRAGMENT_WEIGHT_FIX = builder.define("fragmentFix", true);
builder.pop();
}
}

View file

@ -4,25 +4,21 @@ import org.slf4j.Logger;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("the_vault_tweaks") @Mod("the_vault_tweaks")
public class VaultModTweaks public class VaultModTweaks
{ {
// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public VaultModTweaks() public VaultModTweaks()
{ {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Configuration.CONFIG);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
} }
private void setup(final FMLCommonSetupEvent event) private void setup(final FMLCommonSetupEvent event)

View file

@ -0,0 +1,38 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import iskallia.vault.config.Config;
import iskallia.vault.config.CrystalBuddingConfig;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(CrystalBuddingConfig.class)
public abstract class MixinCrystalBuddingConfig extends Config {
@Shadow
private float maxSecondsBetweenGrowthUpdates;
@Shadow
private float minSecondsBetweenGrowthUpdates;
@Override
protected void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
if (Configuration.BUDDING_ENABLED.get()) {
this.maxSecondsBetweenGrowthUpdates = Configuration.BUDDING_MAX.get();
this.minSecondsBetweenGrowthUpdates = Configuration.BUDDING_MIN.get();
}
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,38 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import iskallia.vault.util.EnchantmentEntry;
import net.minecraft.world.item.enchantment.Enchantment;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(EnchantmentEntry.class)
public abstract class MixinEnchantmentEntry
{
@Shadow
private int level;
@Shadow
private Enchantment enchantment;
@Overwrite(remap = false)
public int getLevel() {
if (Configuration.FORTUNE_ENABLED.get()) {
if (this.enchantment.getRegistryName().toString().equals("minecraft:fortune")) {
this.level = Configuration.FORTUNE_LEVEL.get();
}
}
return this.level;
}
@Overwrite(remap = false)
public boolean isValid() {
if (Configuration.FORTUNE_ENABLED.get()) {
if (this.enchantment.getRegistryName().toString().equals("minecraft:fortune") && this.level <= Configuration.FORTUNE_LEVEL.get()) {
return true;
}
}
return this.enchantment != null && this.level > 0 && this.level <= this.enchantment.getMaxLevel();
}
}

View file

@ -0,0 +1,40 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import java.util.HashMap;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import iskallia.vault.config.Config;
import iskallia.vault.config.ExpertisesGUIConfig;
import iskallia.vault.config.entry.SkillStyle;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(ExpertisesGUIConfig.class)
public abstract class MixinExpertisesGuiConfig extends Config {
@Shadow
private HashMap<String, SkillStyle> styles;
@Override
protected void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
if (Configuration.FORTUNE_ENABLED.get()) {
this.styles.remove("Fortunate");
}
if (Configuration.JEWELER_ENABLED.get()) {
this.styles.remove("Jeweler");
}
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,77 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import iskallia.vault.research.ResearchTree;
import iskallia.vault.research.StageManager;
import iskallia.vault.world.data.PlayerResearchesData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
@Mixin(StageManager.class)
public abstract class MixinStageManager {
@Shadow
public static ResearchTree RESEARCH_TREE;
@Redirect(
method = "onItemCrafted",
at = @At(
value = "INVOKE",
target = "getResearchTree(Lnet/minecraft/world/entity/player/Player;)Liskallia/vault/research/ResearchTree;",
remap = false
),
remap = false
)
private static ResearchTree overrideOnItemCrafted(Player player) {
return overrideGetResearchTree(player);
}
@Redirect(
method = "onBlockInteraction",
at = @At(
value = "INVOKE",
target = "getResearchTree(Lnet/minecraft/world/entity/player/Player;)Liskallia/vault/research/ResearchTree;",
remap = false
),
remap = false
)
private static ResearchTree overrideOnBlockInteraction(Player player) {
return overrideGetResearchTree(player);
}
@Redirect(
method = "onItemUse",
at = @At(
value = "INVOKE",
target = "getResearchTree(Lnet/minecraft/world/entity/player/Player;)Liskallia/vault/research/ResearchTree;",
remap = false
),
remap = false
)
private static ResearchTree overrideOnItemUse(Player player) {
return overrideGetResearchTree(player);
}
@Redirect(
method = "onEntityInteraction",
at = @At(
value = "INVOKE",
target = "getResearchTree(Lnet/minecraft/world/entity/player/Player;)Liskallia/vault/research/ResearchTree;",
remap = false
),
remap = false
)
private static ResearchTree overrideOnEntityInteraction(Player player) {
return overrideGetResearchTree(player);
}
private static ResearchTree overrideGetResearchTree(Player player) {
if (player.level.isClientSide) {
return RESEARCH_TREE;
}
return PlayerResearchesData.get((ServerLevel)player.level).getResearches(player);
}
}

View file

@ -0,0 +1,39 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import iskallia.vault.config.Config;
import iskallia.vault.config.UnidentifiedRelicFragmentsConfig;
import iskallia.vault.util.data.WeightedList;
import net.minecraft.resources.ResourceLocation;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(UnidentifiedRelicFragmentsConfig.class)
public abstract class MixinUnidentifiedRelicFragmentsConfig extends Config {
@Shadow
private WeightedList<ResourceLocation> fragments;
@Override
public void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
if (Configuration.FRAGMENT_WEIGHT_FIX.get()) {
for (WeightedList.Entry<ResourceLocation> item : fragments) {
item.weight = 2;
}
}
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,38 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.google.gson.annotations.Expose;
import iskallia.vault.config.Config;
import iskallia.vault.config.VaultAltarConfig;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(VaultAltarConfig.class)
public abstract class MixinVaultAltarConfig extends Config {
@Shadow
@Expose
public int INFUSION_TIME;
@Override
protected void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
if (Configuration.VAULTAR_ENABLED.get()) {
this.INFUSION_TIME = Configuration.VAULTAR_INFUSION_TIME.get();
}
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,41 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import java.util.HashMap;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import iskallia.vault.config.Config;
import iskallia.vault.config.VaultCharmConfig;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(VaultCharmConfig.class)
public abstract class MixinVaultCharmConfig extends Config {
@Shadow
private HashMap<Integer, Integer> tierMultipliers;
@Override
protected void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
if (Configuration.JUNKMGMT_ENABLED.get()) {
tierMultipliers = new HashMap<Integer, Integer>(4);
tierMultipliers.put(1, Configuration.JUNKMGMT_T1.get());
tierMultipliers.put(2, Configuration.JUNKMGMT_T2.get());
tierMultipliers.put(3, Configuration.JUNKMGMT_T3.get());
tierMultipliers.put(4, Configuration.JUNKMGMT_T4.get());
}
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,39 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import iskallia.vault.config.Config;
import iskallia.vault.config.VaultJewelCuttingConfig;
import iskallia.vault.config.VaultJewelCuttingConfig.JewelCuttingRange;
import tv.alterNERD.VaultModTweaks.Configuration;
@Mixin(VaultJewelCuttingConfig.class)
public abstract class MixinVaultJewelCuttingConfig extends Config {
@Shadow
private float jewelCuttingModifierRemovalChance;
@Shadow
private JewelCuttingRange jewelCuttingRange;
@Override
protected void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
if (Configuration.JEWELER_ENABLED.get()) {
this.jewelCuttingModifierRemovalChance = Configuration.JEWELER_CHANCE.get().floatValue();
this.jewelCuttingRange = new JewelCuttingRange(Configuration.JEWELS_MIN.get(), Configuration.JEWELS_MAX.get());
}
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,40 @@
package tv.alterNERD.VaultModTweaks.integration.mixin;
import java.util.ArrayList;
import java.util.Arrays;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.google.gson.annotations.Expose;
import iskallia.vault.config.Config;
import iskallia.vault.config.VaultPortalConfig;
@Mixin(VaultPortalConfig.class)
public abstract class MixinVaultPortalConfig extends Config {
@Shadow
@Expose
public String[] VALID_BLOCKS;
@Override
protected void onLoad(Config oldConfigInstance) {
super.onLoad(oldConfigInstance);
ArrayList<String> list = new ArrayList<String>(Arrays.asList(VALID_BLOCKS));
list.add("modularrouters:template_frame");
VALID_BLOCKS = list.toArray(VALID_BLOCKS);
}
@Shadow
@Override
public String getName() {
throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Shadow
@Override
protected void reset() {
throw new UnsupportedOperationException("Unimplemented method 'reset'");
}
}

View file

@ -0,0 +1,9 @@
{
"block.minecraft.andesite": "Andesite",
"block.minecraft.polished_andesite": "Polished Andesite",
"block.minecraft.andesite_stairs": "Andesite Stairs",
"block.minecraft.polished_andesite_stairs": "Polished Andesite Stairs",
"block.minecraft.andesite_slab": "Andesite Slab",
"block.minecraft.polished_andesite_slab": "Polished Andesite Slab",
"block.minecraft.andesite_wall": "Andesite Wall"
}

View file

@ -0,0 +1,20 @@
{
"required": true,
"package": "tv.alterNERD.VaultModTweaks.integration.mixin",
"compatibilityLevel": "JAVA_17",
"refmap": "mixins.the_vault_tweaks.refmap.json",
"mixins": [
"MixinCrystalBuddingConfig",
"MixinEnchantmentEntry",
"MixinExpertisesGuiConfig",
"MixinStageManager",
"MixinUnidentifiedRelicFragmentsConfig",
"MixinVaultAltarConfig",
"MixinVaultCharmConfig",
"MixinVaultJewelCuttingConfig",
"MixinVaultPortalConfig"
],
"client": [],
"server": [],
"minVersion": "0.8"
}