2
0
Fork 0

Infinite damage bug 'fixed', back to onLivingHurt, a negative modifier is for some reason giving positive protection still.

frozen
KeyLime17 1 year ago
parent 7bd9ac2b5f
commit f95db236bf

@ -39,35 +39,35 @@ public class CinderEventHandler implements IFuelHandler {
}
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event) {
EntityLivingBase entity = event.entityLiving;;
Entity sourceEntity = event.source.getEntity();
public void onLivingHurt(LivingHurtEvent event) {
EntityLivingBase entity = event.entityLiving;
EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase) event.source.getEntity() : null;
World world = entity.worldObj;
// Negative Arrow Protection Handle
// Negative Arrow Protection Handler
if (event.source.isProjectile() && entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "DEBUG: Original Damage: " + (event.ammount)));
float totalAdditionalDamage = 0.0f;
for (int i = 0; i < 4; i++) {
ItemStack armor = entity.getEquipmentInSlot(i + 1);
if (armor != null) {
LOTREnchantment enchantment = LOTREnchantment.getEnchantmentByName("protectRangedWeak1");
if (LOTREnchantmentHelper.hasEnchant(armor, enchantment)) {
float additionalDamage = 1.6f; //60% more damage
// event.setCanceled(true); //Disabled to see if this was the source of spam, it wasnt
entity.attackEntityFrom(event.source, event.ammount * additionalDamage);
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: damage received, total damage: " + (event.ammount + additionalDamage)));
float level = enchantment.getValueModifier();
if (level > 0) {
totalAdditionalDamage += 1.6f; // 20% more damage per level
}
}
}
}
// Apply the total additional damage to the event amount
if (totalAdditionalDamage > 0) {
event.ammount += totalAdditionalDamage;
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "DEBUG: total damage received: " + event.ammount));
}
}
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
EntityLivingBase entity = event.entityLiving;
EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase) event.source.getEntity() : null;
World world = entity.worldObj;
// Broken Halo Event handler
if (attacker != null && event.source.getSourceOfDamage() == attacker) {

@ -14,11 +14,6 @@ public class LOTREnchantmentWeakProtectionRanged extends LOTREnchantmentProtecti
public LOTREnchantmentWeakProtectionRanged(String s, int level) {
super(s, level);
}
@Override
protected boolean protectsAgainst(DamageSource source) {
// Check if the damage source is a projectile
return source.isProjectile();
}
@Override
public String getDescription(ItemStack itemstack) {
@ -34,18 +29,22 @@ public class LOTREnchantmentWeakProtectionRanged extends LOTREnchantmentProtecti
return false;
}
// Redundant because it doesnt work, instead we will be using CinderEventHandler
@Override
protected int calcIntProtection() {
// Implement the logic to calculate protection level
return -(this.protectLevel);
}
@Override
public boolean isBeneficial() {
// This enchantment is detrimental, so return false
return false;
}
@Override
protected boolean protectsAgainst(DamageSource damageSource) {
return damageSource.isProjectile();
}
@Override
protected int calcIntProtection() {
return 0;
}
}

@ -18,7 +18,7 @@ public class MixinLOTREnchantment {
private static void onStaticInit(CallbackInfo ci) {
// Add your new enchantments here
try {
LOTREnchantment protectRangedWeak1 = new LOTREnchantmentWeakProtectionRanged("protectRangedWeak1", 10).setEnchantWeight(0);
LOTREnchantment protectRangedWeak1 = new LOTREnchantmentWeakProtectionRanged("protectRangedWeak1", 0).setEnchantWeight(0);
LOTREnchantment weak4 = new LOTREnchantmentDamage("weak4", -3.0f).setEnchantWeight(0);
LOTREnchantment.allEnchantments.add(protectRangedWeak1);

Loading…
Cancel
Save