Skip to content

Commit

Permalink
Improved default config
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsoltMolnarrr committed Jul 16, 2022
1 parent 7680108 commit 9c047a8
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 45 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
117 changes: 78 additions & 39 deletions src/main/java/net/powerscale/config/Default.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/powerscale/logic/ItemScaling.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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; };
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/powerscale/mixin/ItemStackMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9c047a8

Please sign in to comment.