-
Notifications
You must be signed in to change notification settings - Fork 48
Implemented compatibility to players #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
|
|
||
| import net.minecraft.entity.EntityLivingBase; | ||
| import net.minecraft.nbt.NBTTagCompound; | ||
| import noppes.npcs.DataAbilities; | ||
| import noppes.npcs.api.ability.IAbilityHolder; | ||
| import noppes.npcs.entity.EntityNPCInterface; | ||
|
|
||
| /** | ||
|
|
@@ -13,11 +15,11 @@ public interface Condition { | |
| /** | ||
| * Check if this condition is met. | ||
| * | ||
| * @param npc The NPC that would use the ability | ||
| * @param holder The entity that would use the ability | ||
| * @param target The current target (may be null for self-targeting abilities) | ||
| * @return true if the condition is satisfied | ||
| */ | ||
| boolean check(EntityNPCInterface npc, EntityLivingBase target); | ||
| boolean check(IAbilityHolder holder, EntityLivingBase target); | ||
|
|
||
| /** | ||
| * Get the condition type ID for serialization. | ||
|
|
@@ -87,8 +89,8 @@ public ConditionHPAbove(float threshold) { | |
| } | ||
|
|
||
| @Override | ||
| public boolean check(EntityNPCInterface npc, EntityLivingBase target) { | ||
| return npc.getHealth() / npc.getMaxHealth() > threshold; | ||
| public boolean check(IAbilityHolder entity, EntityLivingBase target) { | ||
| return ((EntityLivingBase) entity).getHealth() / ((EntityLivingBase) entity).getMaxHealth() > threshold; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -121,8 +123,8 @@ public ConditionHPBelow(float threshold) { | |
| } | ||
|
|
||
| @Override | ||
| public boolean check(EntityNPCInterface npc, EntityLivingBase target) { | ||
| return npc.getHealth() / npc.getMaxHealth() < threshold; | ||
| public boolean check(IAbilityHolder entity, EntityLivingBase target) { | ||
| return ((EntityLivingBase) entity).getHealth() / ((EntityLivingBase) entity).getMaxHealth() < threshold; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wtfffffffffffff why method logic is doubled ???? final EntityLivingBase living = (EntityLivingBase) entity;
return (living.getHealth() / living.getMaxHealth()) < threshold; |
||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -155,7 +157,7 @@ public ConditionTargetHPAbove(float threshold) { | |
| } | ||
|
|
||
| @Override | ||
| public boolean check(EntityNPCInterface npc, EntityLivingBase target) { | ||
| public boolean check(IAbilityHolder entity, EntityLivingBase target) { | ||
| if (target == null) return false; | ||
| return target.getHealth() / target.getMaxHealth() > threshold; | ||
| } | ||
|
|
@@ -190,7 +192,7 @@ public ConditionTargetHPBelow(float threshold) { | |
| } | ||
|
|
||
| @Override | ||
| public boolean check(EntityNPCInterface npc, EntityLivingBase target) { | ||
| public boolean check(IAbilityHolder entity, EntityLivingBase target) { | ||
| if (target == null) return false; | ||
| return target.getHealth() / target.getMaxHealth() < threshold; | ||
| } | ||
|
|
@@ -228,10 +230,10 @@ public ConditionHitCount(int requiredHits, int withinTicks) { | |
| } | ||
|
|
||
| @Override | ||
| public boolean check(EntityNPCInterface npc, EntityLivingBase target) { | ||
| public boolean check(IAbilityHolder entity, EntityLivingBase target) { | ||
| // Check NPC's recent hit count from DataAbilities | ||
| if (npc.abilities != null) { | ||
| return npc.abilities.getRecentHitCount(withinTicks) >= requiredHits; | ||
| if (entity.getAbilityData() != null) { | ||
| return entity.getAbilityData().getRecentHitCount(withinTicks) >= requiredHits; | ||
|
Comment on lines
234
to
+236
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wtf and getter is doubled! |
||
| } | ||
| return false; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import cpw.mods.fml.relauncher.SideOnly; | ||
|
|
||
| import kamkeel.npcs.controllers.data.ability.Ability; | ||
| import noppes.npcs.api.ability.IAbilityHolder; | ||
| import noppes.npcs.client.gui.util.IAbilityConfigCallback; | ||
| import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; | ||
| import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityBeam; | ||
|
|
@@ -79,7 +80,7 @@ public TargetingMode[] getAllowedTargetingModes() { | |
| } | ||
|
|
||
| @Override | ||
| public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) { | ||
| public void onExecute(IAbilityHolder holder, EntityLivingBase target, World world) { | ||
| // Initialize beam | ||
| currentSweepAngle = -sweepAngle / 2; | ||
| sweepingRight = true; | ||
|
|
@@ -88,9 +89,10 @@ public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World wor | |
| } | ||
|
|
||
| @Override | ||
| public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { | ||
| public void onActiveTick(IAbilityHolder holder, EntityLivingBase target, World world, int tick) { | ||
| if (world.isRemote) return; | ||
|
|
||
| EntityLivingBase entity = (EntityLivingBase) holder; | ||
| hitThisTick.clear(); | ||
| ticksSinceDamage++; | ||
|
|
||
|
|
@@ -117,22 +119,22 @@ public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World | |
| } | ||
|
|
||
| // Calculate beam direction | ||
| float baseYaw = npc.rotationYaw; | ||
| float baseYaw = entity.rotationYaw; | ||
|
|
||
| // If lock on target, point at target | ||
| if (lockOnTarget && target != null) { | ||
| double dx = target.posX - npc.posX; | ||
| double dz = target.posZ - npc.posZ; | ||
| double dx = target.posX - entity.posX; | ||
| double dz = target.posZ - entity.posZ; | ||
| baseYaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); | ||
| } | ||
|
|
||
| float beamYaw = baseYaw + currentSweepAngle; | ||
| float yawRad = (float) Math.toRadians(beamYaw); | ||
|
|
||
| // Calculate beam start position | ||
| double startX = npc.posX; | ||
| double startY = npc.posY + npc.getEyeHeight() * 0.8; | ||
| double startZ = npc.posZ; | ||
| double startX = entity.posX; | ||
| double startY = entity.posY + entity.getEyeHeight() * 0.8; | ||
| double startZ = entity.posZ; | ||
|
|
||
| double dirX = -Math.sin(yawRad); | ||
| double dirZ = Math.cos(yawRad); | ||
|
|
@@ -158,18 +160,18 @@ public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World | |
| @SuppressWarnings("unchecked") | ||
| List<Entity> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, checkBox); | ||
|
|
||
| for (Entity entity : entities) { | ||
| if (!(entity instanceof EntityLivingBase)) continue; | ||
| if (entity == npc) continue; | ||
| if (hitThisTick.contains(entity.getEntityId())) continue; | ||
| for (Entity e : entities) { | ||
| if (!(e instanceof EntityLivingBase)) continue; | ||
| if (e == entity) continue; | ||
|
Comment on lines
+164
to
+165
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (e == enity || !(e instanceof EntityLivingBase)) continue |
||
| if (hitThisTick.contains(e.getEntityId())) continue; | ||
|
|
||
| EntityLivingBase livingEntity = (EntityLivingBase) entity; | ||
| EntityLivingBase livingEntity = (EntityLivingBase) e; | ||
|
|
||
| // Check if actually in beam path | ||
| if (isInBeamPath(livingEntity, startX, startY, startZ, dirX, dirZ)) { | ||
| hitThisTick.add(entity.getEntityId()); | ||
| hitThisTick.add(e.getEntityId()); | ||
| // Apply damage with scripted event support (no knockback for beam) | ||
| applyAbilityDamage(npc, livingEntity, damage, 0, 0); | ||
| applyAbilityDamage(holder, livingEntity, damage, 0, 0); | ||
|
|
||
| if (!piercing) { | ||
| return; // Stop at first hit | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fuck, why double cast ?