diff --git a/build.gradle b/build.gradle index 308f0dd..5d7f9a8 100644 --- a/build.gradle +++ b/build.gradle @@ -42,15 +42,10 @@ dependencies { modCompileOnly ('maven.modrinth:levelz:1.4.9+1.20') { exclude(group: "net.fabricmc.fabric-api") } - // // PlayerEx - // modCompileOnly ('maven.modrinth:playerex-directors-cut:4.0.0+1.20.1-alpha.12') { - // exclude(group: "net.fabricmc.fabric-api") - // } - - // RpgLootZ - // modCompileOnly ('maven.modrinth:rpgz:0.5.3') { - // exclude(group: "net.fabricmc.fabric-api") - // } + // PlayerEx + modCompileOnly "maven.modrinth:data-attributes-directors-cut:2.0.0+1.20.1-beta.9-fabric" + modCompileOnly "maven.modrinth:playerex-directors-cut:4.0.0+1.20.1-alpha.13" + modCompileOnly "maven.modrinth:playerex-directors-cut:4.0.0+1.20.1-alpha.13" } processResources { diff --git a/src/main/java/net/rpgdifficulty/config/RpgDifficultyConfig.java b/src/main/java/net/rpgdifficulty/config/RpgDifficultyConfig.java index 8ba7a6f..092668f 100644 --- a/src/main/java/net/rpgdifficulty/config/RpgDifficultyConfig.java +++ b/src/main/java/net/rpgdifficulty/config/RpgDifficultyConfig.java @@ -71,10 +71,10 @@ public class RpgDifficultyConfig implements ConfigData { public float maxLootChance = 0.7F; @Comment("Each loot table item has 0.5 = 50% chance to get dropped") public float chanceForEachItem = 0.5F; - @Comment("Only applies when LevelZ is loaded. 0.0 = disabled") - public double levelZLevelFactor = 0.0D; - @Comment("Only applies when LevelZ is loaded. Get players in radius") - public double levelZPlayerRadius = 100.0D; + @Comment("Only applies when LevelZ/PlayerEx is loaded. 0.0 = disabled") + public double levelFactor = 0.0D; + @Comment("Only applies when LevelZ/PlayerEx is loaded. Get players in radius") + public double playerRadius = 100.0D; @Comment("Hud for testing purpose only") public boolean hudTesting = false; diff --git a/src/main/java/net/rpgdifficulty/mixin/compat/ChangeAttributeMixin.java b/src/main/java/net/rpgdifficulty/mixin/compat/ChangeAttributeMixin.java index 9c7ec51..dfac133 100644 --- a/src/main/java/net/rpgdifficulty/mixin/compat/ChangeAttributeMixin.java +++ b/src/main/java/net/rpgdifficulty/mixin/compat/ChangeAttributeMixin.java @@ -32,7 +32,7 @@ public class ChangeAttributeMixin { @Inject(method = "changeAttributes", at = @At(value = "HEAD"), cancellable = true) private static void changeAttributesMixin(MobEntity mobEntity, World world, CallbackInfo info) { - if (RpgDifficultyMain.CONFIG.levelZLevelFactor > 0.001D && !RpgDifficultyMain.CONFIG.excludedEntity.contains(mobEntity.getType().toString().replace("entity.", "").replace(".", ":"))) { + if (RpgDifficultyMain.CONFIG.levelFactor > 0.001D && !RpgDifficultyMain.CONFIG.excludedEntity.contains(mobEntity.getType().toString().replace("entity.", "").replace(".", ":"))) { if (mobEntity.isBaby() && mobEntity instanceof PassiveEntity) { return; @@ -49,7 +49,7 @@ private static void changeAttributesMixin(MobEntity mobEntity, World world, Call continue; } if (playerEntity.getWorld().getDimension().equals(mobEntity.getWorld().getDimension()) - && Math.sqrt(playerEntity.squaredDistanceTo(x, y, z)) <= RpgDifficultyMain.CONFIG.levelZPlayerRadius) { + && Math.sqrt(playerEntity.squaredDistanceTo(x, y, z)) <= RpgDifficultyMain.CONFIG.playerRadius) { playerCount++; totalPlayerLevel += ((PlayerStatsManagerAccess) playerEntity).getPlayerStatsManager().getOverallLevel(); } @@ -90,9 +90,9 @@ private static void changeAttributesMixin(MobEntity mobEntity, World world, Call double maxFactorProtection = RpgDifficultyMain.CONFIG.maxFactorProtection; // Calculate - mobHealthFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelZLevelFactor; - mobDamageFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelZLevelFactor; - mobProtectionFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelZLevelFactor; + mobHealthFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelFactor; + mobDamageFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelFactor; + mobProtectionFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelFactor; if (mobHealthFactor > maxFactorHealth) { mobHealthFactor = maxFactorHealth; diff --git a/src/main/java/net/rpgdifficulty/mixin/compat/PlayerExCompatMixin.java b/src/main/java/net/rpgdifficulty/mixin/compat/PlayerExCompatMixin.java index a554a87..3e50453 100644 --- a/src/main/java/net/rpgdifficulty/mixin/compat/PlayerExCompatMixin.java +++ b/src/main/java/net/rpgdifficulty/mixin/compat/PlayerExCompatMixin.java @@ -1,11 +1,12 @@ package net.rpgdifficulty.mixin.compat; +import com.bibireden.data_attributes.api.DataAttributesAPI; +import com.bibireden.playerex.api.attribute.PlayerEXAttributes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.levelz.access.PlayerStatsManagerAccess; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.ZombieEntity; @@ -23,17 +24,13 @@ public class PlayerExCompatMixin { @Inject(method = "changeAttributes", at = @At(value = "HEAD"), cancellable = true) private static void changeAttributesMixin(MobEntity mobEntity, World world, CallbackInfo info) { - if (RpgDifficultyMain.CONFIG.levelZLevelFactor > 0.001D && !RpgDifficultyMain.CONFIG.excludedEntity - .contains(mobEntity.getType().toString().replace("entity.", "").replace(".", ":"))) { + if (RpgDifficultyMain.CONFIG.levelFactor > 0.001D && !RpgDifficultyMain.CONFIG.excludedEntity.contains(mobEntity.getType().toString().replace("entity.", "").replace(".", ":"))) { if (mobEntity.isBaby() && mobEntity instanceof PassiveEntity) { return; } - Random random = world.getRandom(); - // val cache = OfflinePlayerCacheAPI.getCache(server) - // val level = cache.getEntry(PlayerEXCachedKeys.Level::class.java, - // ) + Random random = world.getRandom(); double x = mobEntity.getX(); double y = mobEntity.getY(); @@ -46,19 +43,16 @@ private static void changeAttributesMixin(MobEntity mobEntity, World world, Call continue; } if (playerEntity.getWorld().getDimension().equals(mobEntity.getWorld().getDimension()) - && Math.sqrt(playerEntity.squaredDistanceTo(x, y, - z)) <= RpgDifficultyMain.CONFIG.levelZPlayerRadius) { + && Math.sqrt(playerEntity.squaredDistanceTo(x, y, z)) <= RpgDifficultyMain.CONFIG.playerRadius) { playerCount++; - totalPlayerLevel += ((PlayerStatsManagerAccess) playerEntity).getPlayerStatsManager() - .getOverallLevel(); + totalPlayerLevel += DataAttributesAPI.getValue(PlayerEXAttributes.LEVEL, playerEntity).get().intValue(); } } if (playerCount == 0) { PlayerEntity playerEntity = world.getClosestPlayer(x, y, z, -1.0, false); if (playerEntity != null) { playerCount++; - totalPlayerLevel += ((PlayerStatsManagerAccess) playerEntity).getPlayerStatsManager() - .getOverallLevel(); + totalPlayerLevel += DataAttributesAPI.getValue(PlayerEXAttributes.LEVEL, playerEntity).get().intValue(); } } if (playerCount > 0) { @@ -67,11 +61,9 @@ private static void changeAttributesMixin(MobEntity mobEntity, World world, Call double mobDamage = 0.0F; double mobProtection = 0.0F; double mobSpeed = 0.0F; - boolean hasAttackDamageAttribute = mobEntity.getAttributes() - .hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE); + boolean hasAttackDamageAttribute = mobEntity.getAttributes().hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE); boolean hasArmorAttribute = mobEntity.getAttributes().hasAttribute(EntityAttributes.GENERIC_ARMOR); - boolean hasMovementSpeedAttribute = mobEntity.getAttributes() - .hasAttribute(EntityAttributes.GENERIC_MOVEMENT_SPEED); + boolean hasMovementSpeedAttribute = mobEntity.getAttributes().hasAttribute(EntityAttributes.GENERIC_MOVEMENT_SPEED); if (hasAttackDamageAttribute) { mobDamage = mobEntity.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE); } @@ -92,12 +84,9 @@ private static void changeAttributesMixin(MobEntity mobEntity, World world, Call double maxFactorProtection = RpgDifficultyMain.CONFIG.maxFactorProtection; // Calculate - mobHealthFactor += (double) totalPlayerLevel / (double) playerCount - * RpgDifficultyMain.CONFIG.levelZLevelFactor; - mobDamageFactor += (double) totalPlayerLevel / (double) playerCount - * RpgDifficultyMain.CONFIG.levelZLevelFactor; - mobProtectionFactor += (double) totalPlayerLevel / (double) playerCount - * RpgDifficultyMain.CONFIG.levelZLevelFactor; + mobHealthFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelFactor; + mobDamageFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelFactor; + mobProtectionFactor += (double) totalPlayerLevel / (double) playerCount * RpgDifficultyMain.CONFIG.levelFactor; if (mobHealthFactor > maxFactorHealth) { mobHealthFactor = maxFactorHealth; diff --git a/src/main/resources/assets/rpgdifficulty/lang/en_us.json b/src/main/resources/assets/rpgdifficulty/lang/en_us.json index 797cf6b..84473be 100644 --- a/src/main/resources/assets/rpgdifficulty/lang/en_us.json +++ b/src/main/resources/assets/rpgdifficulty/lang/en_us.json @@ -34,8 +34,8 @@ "text.autoconfig.rpgdifficulty.option.moreLootChance": "More Loot Chance", "text.autoconfig.rpgdifficulty.option.maxLootChance": "Max Loot Chance", "text.autoconfig.rpgdifficulty.option.chanceForEachItem": "Chance For Each Item", - "text.autoconfig.rpgdifficulty.option.levelZLevelFactor": "LevelZ Level Factor", - "text.autoconfig.rpgdifficulty.option.levelZPlayerRadius": "LevelZ Player Radius", + "text.autoconfig.rpgdifficulty.option.LevelFactor": "Level Factor", + "text.autoconfig.rpgdifficulty.option.PlayerRadius": "Player Radius", "text.autoconfig.rpgdifficulty.option.allowSpecialZombie": "Allow Special Zombie", "text.autoconfig.rpgdifficulty.option.bigZombieChance": "Big Zombie Chance",