Gold Armour Tweak

This commit is contained in:
patience 2025-08-31 20:04:59 +01:00
parent 9781a69f1a
commit 006ac3febf
No known key found for this signature in database
4 changed files with 152 additions and 43 deletions

View file

@ -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<Ingredient> 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<Ingredient> 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;
}
}

View file

@ -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
);
}

View file

@ -18,47 +18,47 @@ import java.util.stream.Collectors;
@Mod.EventBusSubscriber(modid = MC_Rebalance.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @Mod.EventBusSubscriber(modid = MC_Rebalance.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class Config 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 /*private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
.comment("Whether to log the dirt block on common setup") .comment("Whether to log the dirt block on common setup")
.define("logDirtBlock", true); .define("logDirtBlock", true);
private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER
.comment("A magic number") .comment("A magic number")
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE); .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
.comment("What you want the introduction message to be for the magic number") .comment("What you want the introduction message to be for the magic number")
.define("magicNumberIntroduction", "The magic number is... "); .define("magicNumberIntroduction", "The magic number is... ");
// a list of strings that are treated as resource locations for items // a list of strings that are treated as resource locations for items
private static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER private static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
.comment("A list of items to log on common setup.") .comment("A list of items to log on common setup.")
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName); .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<Item> 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; @SubscribeEvent
public static int magicNumber; static void onLoad(final ModConfigEvent event)
public static String magicNumberIntroduction; {
public static Set<Item> items; logDirtBlock = LOG_DIRT_BLOCK.get();
magicNumber = MAGIC_NUMBER.get();
magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get();
private static boolean validateItemName(final Object obj) // convert the list of strings into a set of items
{ items = ITEM_STRINGS.get().stream()
return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName)); .map(itemName -> ForgeRegistries.ITEMS.getValue(ResourceLocation.withDefaultNamespace(itemName)))
} .collect(Collectors.toSet());
}*/
@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());
}
} }

View file

@ -5,10 +5,11 @@ import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.world.food.FoodProperties; import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.BlockItem; // import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab; // import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs; // import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item; // 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.Block;
// import net.minecraft.world.level.block.HorizontalDirectionalBlock; // import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.Blocks; 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.PlushBlock;
import xyz.nearmisses.patience.mc_rebalance.AltTiers; import xyz.nearmisses.patience.mc_rebalance.AltTiers;
import xyz.nearmisses.patience.mc_rebalance.AltArmourTiers;
// import net.minecraft.world.item.*; // So I remember this exists // import net.minecraft.world.item.*; // So I remember this exists
@ -66,6 +68,11 @@ public class MC_Rebalance
public static final RegistryObject<Item> golden_shovel = VANILLA_ITEMS.register("golden_shovel",() -> new ShovelItem(AltTiers.Gold, 1.5f, -3.0f, new Item.Properties()) ); public static final RegistryObject<Item> golden_shovel = VANILLA_ITEMS.register("golden_shovel",() -> new ShovelItem(AltTiers.Gold, 1.5f, -3.0f, new Item.Properties()) );
public static final RegistryObject<Item> golden_hoe = VANILLA_ITEMS.register("golden_hoe",() -> new PickaxeItem(AltTiers.Gold, -1, -1.0f, new Item.Properties()) ); public static final RegistryObject<Item> golden_hoe = VANILLA_ITEMS.register("golden_hoe",() -> new PickaxeItem(AltTiers.Gold, -1, -1.0f, new Item.Properties()) );
public static final RegistryObject<Item> golden_helmet = VANILLA_ITEMS.register("golden_helmet",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.HELMET,new Item.Properties()));
public static final RegistryObject<Item> golden_chestplate = VANILLA_ITEMS.register("golden_chestplate",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.CHESTPLATE,new Item.Properties()));
public static final RegistryObject<Item> golden_leggings = VANILLA_ITEMS.register("golden_leggings",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.LEGGINGS,new Item.Properties()));
public static final RegistryObject<Item> golden_boots = VANILLA_ITEMS.register("golden_boots",() -> new ArmorItem(AltArmourTiers.Gold,ArmorItem.Type.BOOTS,new Item.Properties()));
public static final RegistryObject<Item> diamond_pick = VANILLA_ITEMS.register("diamond_pickaxe",() -> new PickaxeItem(AltTiers.Diamond, 1, -2.8f, new Item.Properties()) ); public static final RegistryObject<Item> diamond_pick = VANILLA_ITEMS.register("diamond_pickaxe",() -> new PickaxeItem(AltTiers.Diamond, 1, -2.8f, new Item.Properties()) );
public static final RegistryObject<Item> diamond_sword = VANILLA_ITEMS.register("diamond_sword",() -> new SwordItem(AltTiers.Diamond, 3, -2.4f, new Item.Properties())); public static final RegistryObject<Item> diamond_sword = VANILLA_ITEMS.register("diamond_sword",() -> new SwordItem(AltTiers.Diamond, 3, -2.4f, new Item.Properties()));
public static final RegistryObject<Item> diamond_axe = VANILLA_ITEMS.register("diamond_axe",() -> new AxeItem(AltTiers.Diamond, 7, -3.0f, new Item.Properties()) ); public static final RegistryObject<Item> 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(); IEventBus modEventBus = context.getModEventBus();
// Register the commonSetup method for modloading // 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 // Register the Deferred Register to the mod event bus so blocks get registered
BLOCKS.register(modEventBus); BLOCKS.register(modEventBus);
@ -125,7 +132,7 @@ public class MC_Rebalance
context.registerConfig(ModConfig.Type.COMMON, Config.SPEC); context.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
} }
private void commonSetup(final FMLCommonSetupEvent event) /*private void commonSetup(final FMLCommonSetupEvent event)
{ {
// Some common setup code // Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP"); LOGGER.info("HELLO FROM COMMON SETUP");
@ -135,7 +142,7 @@ public class MC_Rebalance
LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber); LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber);
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString())); Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
} }*/
// Add the example block item to the building blocks tab // Add the example block item to the building blocks tab
private void addCreative(BuildCreativeModeTabContentsEvent event) private void addCreative(BuildCreativeModeTabContentsEvent event)