From 9c047a88f032a28f4ca6cc575e00cc58de071aff Mon Sep 17 00:00:00 2001 From: Zsolt Molnar Date: Sat, 16 Jul 2022 22:43:31 +0200 Subject: [PATCH] Improved default config --- gradle.properties | 2 +- .../java/net/powerscale/config/Default.java | 117 ++++++++++++------ .../net/powerscale/logic/ItemScaling.java | 5 +- .../net/powerscale/mixin/ItemStackMixin.java | 4 +- 4 files changed, 83 insertions(+), 45 deletions(-) diff --git a/gradle.properties b/gradle.properties index 896b31c..6c249fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.18.2 yarn_mappings=1.18.2+build.3 loader_version=0.14.8 # Mod Properties -mod_version=1.0-SNAPSHOT +mod_version=1.0.0 maven_group=net archives_base_name=powerscale # Dependencies diff --git a/src/main/java/net/powerscale/config/Default.java b/src/main/java/net/powerscale/config/Default.java index de0c913..42ad0ad 100644 --- a/src/main/java/net/powerscale/config/Default.java +++ b/src/main/java/net/powerscale/config/Default.java @@ -7,44 +7,56 @@ private static Config createDefaultConfig() { // Surface var overworld = new Config.Dimension(); overworld.world_matches.dimension_regex = "minecraft:overworld"; -// overworld.rewards.weapons = new Config.ItemModifier[]{ -// createItemModifier(new Config.AttributeModifier[]{ -// createDamageMultiplier(1.5F), -// createProjectileMultiplier(1.5F) -// }), -// }; -// overworld.rewards.armor = new Config.ItemModifier[]{ -// createItemModifier(new Config.AttributeModifier[]{ -// createArmorMultiplier(1.5F) -// }), -// }; -// overworld.entities = new Config.EntityModifier[] { -// createEntityModifier("zombi|creeper|skeleton", new Config.AttributeModifier[]{ -// createHealthMultiplier(2F), -// createArmorBonus(2F), -// createDamageMultiplier(2) -// }) -// }; -// var desert = new Config.Zone(); -// desert.zone_matches.biome_regex = "desert"; -// desert.rewards.weapons = new Config.ItemModifier[]{ -// createItemModifier(new Config.AttributeModifier[]{ -// createDamageMultiplier(1.5F), -// createProjectileMultiplier(1.5F) -// }), -// }; -// desert.rewards.armor = new Config.ItemModifier[]{ -// createItemModifier(new Config.AttributeModifier[]{ -// createMaxHealthBonus(2) -// }), -// }; -// desert.entities = new Config.EntityModifier[] { -// createEntityModifier("zombi|creeper|skeleton", new Config.AttributeModifier[]{ -// createArmorMultiplier(2F), -// createMaxHealthBonus(10F) -// }) -// }; -// overworld.zones = new Config.Zone[] { desert }; + + var cold_biomes = new Config.Zone(); + cold_biomes.zone_matches.biome_regex = "frozen|snowy|ice"; + cold_biomes.rewards.weapons = new Config.ItemModifier[] { + createItemModifier( + "minecraft:bow", + null, + new Config.AttributeModifier[]{ + createProjectileMultiplier(1.3F, 0) + } + ), + }; + cold_biomes.entities = new Config.EntityModifier[] { + createEntityModifier( + "stray|skeleton", + new Config.AttributeModifier[]{ + createHealthMultiplier(1.25F, 0.25F), + createArmorBonus(4) + }, + null) + }; + + var desert = new Config.Zone(); + desert.zone_matches.biome_regex = "desert"; + desert.rewards.weapons = new Config.ItemModifier[]{ + createItemModifier( + null, + "chests/desert_pyramid", + new Config.AttributeModifier[]{ + createDamageMultiplier(1.3F, 0), + } + ), + }; + desert.entities = new Config.EntityModifier[] { + createEntityModifier( + "skeleton", + new Config.AttributeModifier[]{ + createHealthMultiplier(1.75F, 0.25F), + createArmorBonus(4) + }, + null), + createEntityModifier( + "husk", + new Config.AttributeModifier[]{ + createDamageMultiplier(1.5F,0), + createHealthMultiplier(2F, 0.5F) + }, + null) + }; + overworld.zones = new Config.Zone[] { cold_biomes, desert }; // Nether var nether = new Config.Dimension(); @@ -113,14 +125,41 @@ private static Config createDefaultConfig() { null) }; + var anyDimension = new Config.Dimension(); + var epics = createItemModifier( + new Config.AttributeModifier[]{ + createDamageMultiplier(1.2F,0), + createProjectileMultiplier(1.2F, 0) + } + ); + epics.item_matches.rarity_regex = "epic"; + var rares = createItemModifier( + new Config.AttributeModifier[]{ + createDamageMultiplier(1.1F,0), + createProjectileMultiplier(1.1F, 0) + } + ); + rares.item_matches.rarity_regex = "rare"; + anyDimension.rewards.weapons = new Config.ItemModifier[] { rares, epics }; + var config = new Config(); - config.dimensions = new Config.Dimension[] { overworld, nether, end }; + config.dimensions = new Config.Dimension[] { overworld, nether, end, anyDimension }; return config; } private static Config.ItemModifier createItemModifier(Config.AttributeModifier[] attributeModifiers) { + return createItemModifier(null, null, attributeModifiers); + } + + private static Config.ItemModifier createItemModifier(String itemIdRegex, String lootTableRegex, Config.AttributeModifier[] attributeModifiers) { var itemModifier = new Config.ItemModifier(); itemModifier.item_matches = new Config.ItemModifier.Filters(); + if (itemIdRegex != null) { + itemModifier.item_matches.item_id_regex = itemIdRegex; + } + if (lootTableRegex != null) { + itemModifier.item_matches.loot_table_regex = lootTableRegex; + } itemModifier.attributes = attributeModifiers; return itemModifier; } diff --git a/src/main/java/net/powerscale/logic/ItemScaling.java b/src/main/java/net/powerscale/logic/ItemScaling.java index e0b2196..78cd371 100644 --- a/src/main/java/net/powerscale/logic/ItemScaling.java +++ b/src/main/java/net/powerscale/logic/ItemScaling.java @@ -177,7 +177,6 @@ private static void copyItemAttributesToNBT(ItemStack itemStack) { private static EntityAttributeModifier createEntityAttributeModifier(EntityAttribute attribute, String name, double value, EntityAttributeModifier.Operation operation) { var hardCodedUUID= hardCodedUUID(attribute); if (hardCodedUUID != null) { - System.out.println("Using hardcoded modifier UUID: " + hardCodedUUID + " for:" + name + " value:" + value); return new EntityAttributeModifier(hardCodedUUID, name, value, operation); } else { return new EntityAttributeModifier(name, value, operation); @@ -209,7 +208,7 @@ public ItemAccessor(Settings settings) { super(settings); } - public static final UUID hardCodedAttackDamageModifier() { return ATTACK_DAMAGE_MODIFIER_ID; }; - public static final UUID hardCodedAttackSpeedModifier() { return ATTACK_SPEED_MODIFIER_ID; }; + public static UUID hardCodedAttackDamageModifier() { return ATTACK_DAMAGE_MODIFIER_ID; }; + public static UUID hardCodedAttackSpeedModifier() { return ATTACK_SPEED_MODIFIER_ID; }; } } diff --git a/src/main/java/net/powerscale/mixin/ItemStackMixin.java b/src/main/java/net/powerscale/mixin/ItemStackMixin.java index 2e55302..d7e9efd 100644 --- a/src/main/java/net/powerscale/mixin/ItemStackMixin.java +++ b/src/main/java/net/powerscale/mixin/ItemStackMixin.java @@ -16,10 +16,10 @@ public class ItemStackMixin { // UUIDs those were deserialized from NBT @Redirect(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/EntityAttributeModifier;getId()Ljava/util/UUID;")) public UUID fixId(EntityAttributeModifier instance) { - if (instance.getId().toString().matches(ItemScaling.ItemAccessor.hardCodedAttackDamageModifier().toString())) { + if (instance.getId().equals(ItemScaling.ItemAccessor.hardCodedAttackDamageModifier())) { return ItemScaling.ItemAccessor.hardCodedAttackDamageModifier(); } - if (instance.getId().toString().matches(ItemScaling.ItemAccessor.hardCodedAttackSpeedModifier().toString())) { + if (instance.getId().equals(ItemScaling.ItemAccessor.hardCodedAttackSpeedModifier())) { return ItemScaling.ItemAccessor.hardCodedAttackSpeedModifier(); } return instance.getId();