@ -1,10 +1,14 @@
package com.zivilon.cinder_loe.mixins.overrides ;
import com.zivilon.cinder_loe.util.Utilities ;
import com.zivilon.cinder_loe.CinderLoE_Config ;
import lotr.common.entity.npc.LOTREntityNPC ;
import lotr.common.entity.npc.LOTRHiredNPCInfo ;
import net.minecraft.entity.Entity ;
import net.minecraft.entity.EntityLivingBase ;
import net.minecraft.entity.SharedMonsterAttributes ;
import net.minecraft.entity.ai.attributes.AttributeModifier ;
import net.minecraft.entity.ai.attributes.IAttribute ;
import net.minecraft.entity.ai.attributes.IAttributeInstance ;
import net.minecraft.entity.ai.attributes.RangedAttribute ;
@ -24,17 +28,26 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique ;
import java.util.UUID ;
import java.lang.reflect.Method ;
@Mixin ( LOTRHiredNPCInfo . class )
public class MixinLOTRHiredNPCInfo {
public abstract class MixinLOTRHiredNPCInfo {
private static UUID LEVEL_HEALTH_UUID = UUID . fromString ( "11111111-0000-0000-0000-000000000000" ) ;
private static UUID LEVEL_DAMAGE_UUID = UUID . fromString ( "22222222-0000-0000-0000-000000000000" ) ;
private static UUID LEVEL_MOVEMENT_UUID = UUID . fromString ( "33333333-0000-0000-0000-000000000000" ) ;
private static double HEALTH_PER_UPGRADE = 1.0D ;
private static double DAMAGE_PER_UPGRADE = 0.25D ;
private static double SPEED_PER_UPGRADE = 0.0025D ;
@Shadow
private LOTREntityNPC theEntity ;
@Shadow
private UUID hiringPlayerUUID ;
@Shadow
public int xpLevel = 1 ;
@Unique
public int levelUpCounter = 0 ;
@ Shadow
p rivate boolean canMove ;
/ * *
* @author
@ -57,9 +70,9 @@ public class MixinLOTRHiredNPCInfo {
public void rotateLevelUpStat ( ) {
EntityLivingBase entity = ( EntityLivingBase ) this . theEntity ;
LOTREntityNPC entity = this . theEntity ;
switch ( levelUpCounter ) {
switch ( entity. hiredNPCInfo . xpLevel % 3 ) {
case 0 :
// +1 HP
this . addLevelUpHealthGain ( entity ) ;
@ -72,12 +85,7 @@ public class MixinLOTRHiredNPCInfo {
// +0.005 movement Speed
this . increaseMovementGain ( entity ) ;
break ;
case 3 :
// +0.1 knockback resistance
this . increaseKnockbackGain ( entity ) ;
break ;
}
levelUpCounter = ( levelUpCounter + 1 ) % 4 ;
}
/ * *
@ -85,30 +93,24 @@ public class MixinLOTRHiredNPCInfo {
* @reason
* /
@Overwrite ( remap = false )
public void addLevelUpHealthGain ( EntityLivingBase gainingEntity ) {
float healthBoost = 1.0f ;
IAttributeInstance attrHealth = gainingEntity . getEntityAttribute ( SharedMonsterAttributes . maxHealth ) ;
attrHealth . setBaseValue ( attrHealth . getBaseValue ( ) + ( double ) healthBoost ) ;
gainingEntity . heal ( healthBoost ) ;
public void addLevelUpHealthGain ( EntityLivingBase entity ) {
IAttributeInstance attr = entity . getEntityAttribute ( SharedMonsterAttributes . maxHealth ) ;
Utilities . increment_modifier ( attr , LEVEL_HEALTH_UUID , "levelup_health" , HEALTH_PER_UPGRADE , 0 ) ;
entity . heal ( 1.0f ) ;
}
public void increaseDamageGain ( EntityLivingBase gainingEntity ) {
float damageBoost = 0.25f ;
IAttributeInstance attribute = gainingEntity . getEntityAttribute ( LOTREntityNPC . npcAttackDamageExtra ) ;
attribute . setBaseValue ( attribute . getBaseValue ( ) + ( double ) damageBoost ) ;
public void increaseDamageGain ( EntityLivingBase entity ) {
IAttributeInstance attr = entity . getEntityAttribute ( LOTREntityNPC . npcAttackDamageExtra ) ;
Utilities . increment_modifier ( attr , LEVEL_DAMAGE_UUID , "levelup_damage" , DAMAGE_PER_UPGRADE , 0 ) ;
}
public void increaseMovementGain ( EntityLivingBase gainingEntity ) {
float movementBoost = 0.0025f ;
IAttributeInstance attribute = gainingEntity . getEntityAttribute ( SharedMonsterAttributes . movementSpeed ) ;
attribute . setBaseValue ( attribute . getBaseValue ( ) + ( double ) movementBoost ) ;
public void increaseMovementGain ( EntityLivingBase entity ) {
IAttributeInstance attr = entity . getEntityAttribute ( SharedMonsterAttributes . movementSpeed ) ;
Utilities . increment_modifier ( attr , LEVEL_MOVEMENT_UUID , "levelup_speed" , SPEED_PER_UPGRADE , 0 ) ;
}
public void increaseKnockbackGain ( EntityLivingBase gainingEntity ) {
float kbResBoost = 0.1f ;
IAttributeInstance attribute = gainingEntity . getEntityAttribute ( SharedMonsterAttributes . knockbackResistance ) ;
attribute . setBaseValue ( attribute . getBaseValue ( ) + ( double ) kbResBoost ) ;
}
/ * *
* @author
@ -151,4 +153,25 @@ public class MixinLOTRHiredNPCInfo {
world . spawnEntityInWorld ( ( Entity ) firework ) ;
}
@Shadow
public void sendClientPacket ( boolean shouldOpenGui ) { }
@Overwrite ( remap = false )
public void ready ( ) {
this . canMove = true ;
if ( CinderLoE_Config . unit_conversion_enabled ) convert_stats ( ) ;
sendClientPacket ( false ) ;
}
public void convert_stats ( ) {
LOTREntityNPC entity = this . theEntity ;
Utilities . reset_attributes ( entity ) ;
int level = entity . hiredNPCInfo . xpLevel ;
int health_upgrades = ( int ) Math . ceil ( level / 3 ) ;
int damage_upgrades = ( int ) Math . ceil ( ( level - health_upgrades ) / 2 ) ;
int speed_upgrades = level - health_upgrades - damage_upgrades ;
Utilities . set_modifier ( entity . getEntityAttribute ( SharedMonsterAttributes . maxHealth ) , LEVEL_HEALTH_UUID , "levelup_health" , HEALTH_PER_UPGRADE * health_upgrades , 0 ) ;
Utilities . set_modifier ( entity . getEntityAttribute ( LOTREntityNPC . npcAttackDamageExtra ) , LEVEL_DAMAGE_UUID , "levelup_damage" , DAMAGE_PER_UPGRADE * damage_upgrades , 0 ) ;
Utilities . set_modifier ( entity . getEntityAttribute ( SharedMonsterAttributes . movementSpeed ) , LEVEL_MOVEMENT_UUID , "levelup_speed" , SPEED_PER_UPGRADE * speed_upgrades , 0 ) ;
}
}