Skip to content

Commit

Permalink
downgrade 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Globox1997 committed Aug 8, 2024
1 parent 2cbc973 commit 32fc07d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 43 deletions.
13 changes: 4 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
// <USERNAME/UUID (of player)>)
Random random = world.getRandom();

double x = mobEntity.getX();
double y = mobEntity.getY();
Expand All @@ -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) {
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/rpgdifficulty/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 32fc07d

Please sign in to comment.