From 006ac3febf131f6865e455b3811dea936e48e9bc Mon Sep 17 00:00:00 2001 From: patience Date: Sun, 31 Aug 2025 20:04:59 +0100 Subject: [PATCH] Gold Armour Tweak --- .../mc_rebalance/AltArmourTier.java | 73 +++++++++++++++++++ .../mc_rebalance/AltArmourTiers.java | 29 ++++++++ .../com/nearmisses/mc_rebalance/Config.java | 72 +++++++++--------- .../nearmisses/mc_rebalance/MC_Rebalance.java | 21 ++++-- 4 files changed, 152 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/nearmisses/mc_rebalance/AltArmourTier.java create mode 100644 src/main/java/com/nearmisses/mc_rebalance/AltArmourTiers.java diff --git a/src/main/java/com/nearmisses/mc_rebalance/AltArmourTier.java b/src/main/java/com/nearmisses/mc_rebalance/AltArmourTier.java new file mode 100644 index 0000000..98bef11 --- /dev/null +++ b/src/main/java/com/nearmisses/mc_rebalance/AltArmourTier.java @@ -0,0 +1,73 @@ +package xyz.nearmisses.patience.mc_rebalance; + +import xyz.nearmisses.patience.mc_rebalance.MC_Rebalance; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.crafting.Ingredient; + +import java.util.function.Supplier; + +public class AltArmourTier implements ArmorMaterial { + private final int[] durabilityForType; + private final int[] defenseForType; + private final int enchantability; + private final SoundEvent equipSound; + private final Supplier repairMaterial; + private final String name; + private final float toughness; + private final float knockbackResistance; + private final String namespace; + + public AltArmourTier(int[] durabilityForType, int[] defenseForType, int enchantability, SoundEvent equipSound, Supplier repairMaterial, String name, float toughness, float knockbackResistance, String namespace) { + this.durabilityForType = durabilityForType; + this.defenseForType = defenseForType; + this.enchantability = enchantability; + this.equipSound = equipSound; + this.repairMaterial = repairMaterial; + this.name = name; + this.toughness = toughness; + this.knockbackResistance = knockbackResistance; + this.namespace = namespace; + } + + @Override + public int getDurabilityForType(ArmorItem.Type type) { + return this.durabilityForType[type.ordinal()]; + } + + @Override + public int getDefenseForType(ArmorItem.Type type) { + return this.defenseForType[type.ordinal()]; + } + + @Override + public int getEnchantmentValue() { + return this.enchantability; + } + + @Override + public SoundEvent getEquipSound() { + return this.equipSound; + } + + @Override + public Ingredient getRepairIngredient() { + return this.repairMaterial.get(); + } + + @Override + public String getName() { + return this.namespace + ":" + this.name; + } + + @Override + public float getToughness() { + return this.toughness; + } + + @Override + public float getKnockbackResistance() { + return this.knockbackResistance; + } +} diff --git a/src/main/java/com/nearmisses/mc_rebalance/AltArmourTiers.java b/src/main/java/com/nearmisses/mc_rebalance/AltArmourTiers.java new file mode 100644 index 0000000..4efe725 --- /dev/null +++ b/src/main/java/com/nearmisses/mc_rebalance/AltArmourTiers.java @@ -0,0 +1,29 @@ +package xyz.nearmisses.patience.mc_rebalance; + +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.common.ForgeTier; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.core.Holder; + +import net.minecraft.world.item.Items; +import net.minecraft.tags.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; + +import xyz.nearmisses.patience.mc_rebalance.MC_Rebalance; +import xyz.nearmisses.patience.mc_rebalance.AltArmourTier; + +public class AltArmourTiers { + public static final AltArmourTier Gold = new AltArmourTier( + new int[]{264,410,360,340}, // Armour durabilities + new int[]{3,8,6,3}, // Armour defence + 22, // Enchantability + SoundEvents.ARMOR_EQUIP_GOLD, // Equip sound + () -> Ingredient.of(Items.GOLD_INGOT), // Repair material + "gold", // Name + 0.0f, // Toughness + 0.0f, // Knockback resistance + "minecraft" // Namespace + ); +} diff --git a/src/main/java/com/nearmisses/mc_rebalance/Config.java b/src/main/java/com/nearmisses/mc_rebalance/Config.java index 0d55f95..ccda63a 100644 --- a/src/main/java/com/nearmisses/mc_rebalance/Config.java +++ b/src/main/java/com/nearmisses/mc_rebalance/Config.java @@ -18,47 +18,47 @@ import java.util.stream.Collectors; @Mod.EventBusSubscriber(modid = MC_Rebalance.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class Config { - private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); + private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); - private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER - .comment("Whether to log the dirt block on common setup") - .define("logDirtBlock", true); + /*private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER + .comment("Whether to log the dirt block on common setup") + .define("logDirtBlock", true); - private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER - .comment("A magic number") - .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE); + private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER + .comment("A magic number") + .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE); - public static final ForgeConfigSpec.ConfigValue MAGIC_NUMBER_INTRODUCTION = BUILDER - .comment("What you want the introduction message to be for the magic number") - .define("magicNumberIntroduction", "The magic number is... "); + public static final ForgeConfigSpec.ConfigValue MAGIC_NUMBER_INTRODUCTION = BUILDER + .comment("What you want the introduction message to be for the magic number") + .define("magicNumberIntroduction", "The magic number is... "); - // a list of strings that are treated as resource locations for items - private static final ForgeConfigSpec.ConfigValue> ITEM_STRINGS = BUILDER - .comment("A list of items to log on common setup.") - .defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName); + // a list of strings that are treated as resource locations for items + private static final ForgeConfigSpec.ConfigValue> ITEM_STRINGS = BUILDER + .comment("A list of items to log on common setup.") + .defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName); + */ + static final ForgeConfigSpec SPEC = BUILDER.build(); + /* + public static boolean logDirtBlock; + public static int magicNumber; + public static String magicNumberIntroduction; + public static Set items; - static final ForgeConfigSpec SPEC = BUILDER.build(); + private static boolean validateItemName(final Object obj) + { + return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(ResourceLocation.withDefaultNamespace(itemName)\/*new ResourceLocation(itemName)*\/); + } - public static boolean logDirtBlock; - public static int magicNumber; - public static String magicNumberIntroduction; - public static Set items; + @SubscribeEvent + static void onLoad(final ModConfigEvent event) + { + logDirtBlock = LOG_DIRT_BLOCK.get(); + magicNumber = MAGIC_NUMBER.get(); + magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get(); - private static boolean validateItemName(final Object obj) - { - return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName)); - } - - @SubscribeEvent - static void onLoad(final ModConfigEvent event) - { - logDirtBlock = LOG_DIRT_BLOCK.get(); - magicNumber = MAGIC_NUMBER.get(); - magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get(); - - // convert the list of strings into a set of items - items = ITEM_STRINGS.get().stream() - .map(itemName -> ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName))) - .collect(Collectors.toSet()); - } + // convert the list of strings into a set of items + items = ITEM_STRINGS.get().stream() + .map(itemName -> ForgeRegistries.ITEMS.getValue(ResourceLocation.withDefaultNamespace(itemName))) + .collect(Collectors.toSet()); + }*/ } diff --git a/src/main/java/com/nearmisses/mc_rebalance/MC_Rebalance.java b/src/main/java/com/nearmisses/mc_rebalance/MC_Rebalance.java index cac6da6..78ff90b 100644 --- a/src/main/java/com/nearmisses/mc_rebalance/MC_Rebalance.java +++ b/src/main/java/com/nearmisses/mc_rebalance/MC_Rebalance.java @@ -5,10 +5,11 @@ import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; import net.minecraft.core.registries.Registries; import net.minecraft.world.food.FoodProperties; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.CreativeModeTabs; -import net.minecraft.world.item.Item; +// import net.minecraft.world.item.BlockItem; +// import net.minecraft.world.item.CreativeModeTab; +// import net.minecraft.world.item.CreativeModeTabs; +// import net.minecraft.world.item.Item; +// import net.minecraft.world.item.ArmorItem; import net.minecraft.world.level.block.Block; // import net.minecraft.world.level.block.HorizontalDirectionalBlock; import net.minecraft.world.level.block.Blocks; @@ -37,6 +38,7 @@ import net.minecraft.world.item.*; import xyz.nearmisses.patience.mc_rebalance.PlushBlock; import xyz.nearmisses.patience.mc_rebalance.AltTiers; +import xyz.nearmisses.patience.mc_rebalance.AltArmourTiers; // import net.minecraft.world.item.*; // So I remember this exists @@ -66,6 +68,11 @@ public class MC_Rebalance public static final RegistryObject golden_shovel = VANILLA_ITEMS.register("golden_shovel",() -> new ShovelItem(AltTiers.Gold, 1.5f, -3.0f, new Item.Properties()) ); public static final RegistryObject golden_hoe = VANILLA_ITEMS.register("golden_hoe",() -> new PickaxeItem(AltTiers.Gold, -1, -1.0f, new Item.Properties()) ); + public static final RegistryObject golden_helmet = VANILLA_ITEMS.register("golden_helmet",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.HELMET,new Item.Properties())); + public static final RegistryObject golden_chestplate = VANILLA_ITEMS.register("golden_chestplate",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.CHESTPLATE,new Item.Properties())); + public static final RegistryObject golden_leggings = VANILLA_ITEMS.register("golden_leggings",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.LEGGINGS,new Item.Properties())); + public static final RegistryObject golden_boots = VANILLA_ITEMS.register("golden_boots",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.BOOTS,new Item.Properties())); + public static final RegistryObject diamond_pick = VANILLA_ITEMS.register("diamond_pickaxe",() -> new PickaxeItem(AltTiers.Diamond, 1, -2.8f, new Item.Properties()) ); public static final RegistryObject diamond_sword = VANILLA_ITEMS.register("diamond_sword",() -> new SwordItem(AltTiers.Diamond, 3, -2.4f, new Item.Properties())); public static final RegistryObject diamond_axe = VANILLA_ITEMS.register("diamond_axe",() -> new AxeItem(AltTiers.Diamond, 7, -3.0f, new Item.Properties()) ); @@ -103,7 +110,7 @@ public class MC_Rebalance IEventBus modEventBus = context.getModEventBus(); // Register the commonSetup method for modloading - modEventBus.addListener(this::commonSetup); + //modEventBus.addListener(this::commonSetup); // Register the Deferred Register to the mod event bus so blocks get registered BLOCKS.register(modEventBus); @@ -125,7 +132,7 @@ public class MC_Rebalance context.registerConfig(ModConfig.Type.COMMON, Config.SPEC); } - private void commonSetup(final FMLCommonSetupEvent event) + /*private void commonSetup(final FMLCommonSetupEvent event) { // Some common setup code LOGGER.info("HELLO FROM COMMON SETUP"); @@ -135,7 +142,7 @@ public class MC_Rebalance LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber); Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString())); - } + }*/ // Add the example block item to the building blocks tab private void addCreative(BuildCreativeModeTabContentsEvent event)