Support for Future DBC Addon

This commit is contained in:
Kam committed 2024-04-06 17:29:46 -04:00
1 parent 38cc396299
commit a57bf10031
6 files changed
+106 -25

No files matched your search

@@ -2,6 +2,7 @@ package noppes.npcs.entity;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import io.netty.buffer.ByteBuf;
import kamkeel.addon.DBCAddon;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.command.ICommandSender;
@@ -232,41 +233,49 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
}
@Override
public boolean attackEntityAsMob(Entity par1Entity){
public boolean attackEntityAsMob(Entity receiver){
float f = stats.getAttackStrength();
if (stats.attackSpeed < 10){
par1Entity.hurtResistantTime = 0;
receiver.hurtResistantTime = 0;
}
if(par1Entity instanceof EntityLivingBase && !isRemote()){
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)par1Entity);
if(receiver instanceof EntityLivingBase && !isRemote()){
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)receiver);
if(EventHooks.onNPCMeleeAttack(this, event))
return false;
f = event.getDamage();
}
boolean var4 = par1Entity.attackEntityFrom(new NpcDamageSource("mob", this), f);
boolean didAttack = false;
if(DBCAddon.instance.canDBCAttack(this, f, receiver)){
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), 1.0f);
if(didAttack)
DBCAddon.instance.doDBCDamage(this, f, receiver);
}
else
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), f);
if (var4){
if (didAttack){
if(getOwner() instanceof EntityPlayer)
NPCEntityHelper.setRecentlyHit((EntityLivingBase)par1Entity);
NPCEntityHelper.setRecentlyHit((EntityLivingBase)receiver);
if (stats.knockback > 0){
par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F));
receiver.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F));
this.motionX *= 0.6D;
this.motionZ *= 0.6D;
}
if(advanced.role == EnumRoleType.Companion){
((RoleCompanion)roleInterface).attackedEntity(par1Entity);
((RoleCompanion)roleInterface).attackedEntity(receiver);
}
}
if (stats.potionType != EnumPotionType.None){
if (stats.potionType != EnumPotionType.Fire)
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
((EntityLivingBase)receiver).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
else
par1Entity.setFire(stats.potionDuration);
receiver.setFire(stats.potionDuration);
}
return var4;
return didAttack;
}
@Override