Compare commits

...

2 Commits

Author SHA1 Message Date
Justus Wolff
e0ebe898b4 clean
Some checks failed
Compile / gradle (ubuntu-latest) (push) Has been cancelled
2026-03-04 16:18:38 +01:00
Justus Wolff
a3d1b3fcf3 add functionality for maces 2026-03-04 16:18:26 +01:00
35 changed files with 247 additions and 28 deletions

Binary file not shown.

11
.idea/gradle.xml generated Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="21" />
</GradleProjectSettings>
</option>
</component>
</project>

4
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

81
.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="5102ee95-ea95-49aa-8d82-42bb833a7600" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/checksums/checksums.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/checksums/checksums.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/checksums/sha1-checksums.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/checksums/sha1-checksums.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/executionHistory/executionHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/executionHistory/executionHistory.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/executionHistory/executionHistory.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/fileHashes/fileHashes.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/fileHashes/fileHashes.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/9.0.0/fileHashes/resourceHashesCache.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/9.0.0/fileHashes/resourceHashesCache.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/file-system.probe" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/file-system.probe" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/Terminator.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/Terminator.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/botagent/BotAgent.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/botagent/BotAgent.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent$1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent$2.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent$2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/utils/ItemUtils.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/bin/main/net/nuggetmc/tplus/api/utils/ItemUtils.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/Terminator.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/Terminator.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/agent/botagent/BotAgent.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/agent/botagent/BotAgent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/agent/legacyagent/LegacyAgent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/utils/ItemUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-API/src/main/java/net/nuggetmc/tplus/api/utils/ItemUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/.gradle/caches/paperweight/taskCache/reobfJar.log" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/.gradle/caches/paperweight/taskCache/reobfJar.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/bot/Bot.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/bot/Bot.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/bot/BotManagerImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/bot/BotManagerImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/bot/CitizensNPC.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/bot/CitizensNPC.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/utils/Debugger.class" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/bin/main/net/nuggetmc/tplus/utils/Debugger.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/bot/Bot.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/bot/Bot.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/bot/BotManagerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/bot/BotManagerImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/bot/CitizensNPC.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/bot/CitizensNPC.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/utils/Debugger.java" beforeDir="false" afterPath="$PROJECT_DIR$/TerminatorPlus-Plugin/src/main/java/net/nuggetmc/tplus/utils/Debugger.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/buildSrc/.gradle/9.0.0/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/buildSrc/.gradle/9.0.0/executionHistory/executionHistory.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/buildSrc/.gradle/file-system.probe" beforeDir="false" afterPath="$PROJECT_DIR$/buildSrc/.gradle/file-system.probe" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": 3
}]]></component>
<component name="ProjectId" id="3AUBaHjRoLsKlorfhrHm7B6wL6W" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true"
}
}]]></component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-jdk-30f59d01ecdd-2fc7cc6b9a17-intellij.indexing.shared.core-IU-253.30387.90" />
</set>
</attachedChunks>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="5102ee95-ea95-49aa-8d82-42bb833a7600" name="Changes" comment="" />
<created>1772637332226</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1772637332226</updated>
</task>
<servers />
</component>
</project>

View File

@@ -18,7 +18,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public interface Terminator { public interface Terminator {
String getBotName(); String getBotName();
int getEntityId(); int getEntityId();
@@ -74,6 +73,7 @@ public interface Terminator {
void faceLocation(Location location); void faceLocation(Location location);
void attack(Entity target); void attack(Entity target);
void attack(Entity target, double extra);
void attemptBlockPlace(Location loc, Material type, boolean down); void attemptBlockPlace(Location loc, Material type, boolean down);
@@ -103,6 +103,8 @@ public interface Terminator {
void setDefaultItem(ItemStack item); void setDefaultItem(ItemStack item);
ItemStack getDefaultItem();
Vector getOffset(); Vector getOffset();
Vector getVelocity(); Vector getVelocity();

View File

@@ -7,7 +7,10 @@ import net.nuggetmc.tplus.api.utils.MathUtils;
import net.nuggetmc.tplus.api.utils.PlayerUtils; import net.nuggetmc.tplus.api.utils.PlayerUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;

View File

@@ -13,6 +13,7 @@ import net.nuggetmc.tplus.api.event.BotDeathEvent;
import net.nuggetmc.tplus.api.event.BotFallDamageEvent; import net.nuggetmc.tplus.api.event.BotFallDamageEvent;
import net.nuggetmc.tplus.api.event.TerminatorLocateTargetEvent; import net.nuggetmc.tplus.api.event.TerminatorLocateTargetEvent;
import net.nuggetmc.tplus.api.utils.BotUtils; import net.nuggetmc.tplus.api.utils.BotUtils;
import net.nuggetmc.tplus.api.utils.ItemUtils;
import net.nuggetmc.tplus.api.utils.MathUtils; import net.nuggetmc.tplus.api.utils.MathUtils;
import net.nuggetmc.tplus.api.utils.PlayerUtils; import net.nuggetmc.tplus.api.utils.PlayerUtils;
import org.bukkit.*; import org.bukkit.*;
@@ -1394,12 +1395,111 @@ public class LegacyAgent extends Agent {
return check; return check;
} }
private double clamp(double value, double min, double max) {
return Math.max(min, Math.min(max, value));
}
/*private double getdistfromfloor(LivingEntity entity) {
return Math.abs(entity.getWorld().getHighestBlockYAt(entity.getLocation()) - entity.getLocation().getY());
}*/
private boolean tryWindchargeMaceAttack(Terminator bot, LivingEntity target) {
LivingEntity botEntity = bot.getBukkitEntity();
if (botEntity == null) {
return false;
}
// Get inventory - Citizens NPCs should have inventory even if not Player instance
ItemStack mainHand;
if (botEntity instanceof Player player) {
mainHand = player.getInventory().getItemInMainHand();
} else {
return false;
}
// Check if bot has a mace in main hand
if (bot.getDefaultItem().getType() != Material.MACE && mainHand.getType() != Material.MACE) {
return false;
}
if (!bot.isBotOnGround() && Math.random() >= 0.5) return false;
// Face the ground at own position to launch upward
bot.look(org.bukkit.block.BlockFace.DOWN);
// Jump boost from windcharge with higher velocity
bot.setItem(new ItemStack(Material.WIND_CHARGE, 1));
Vector jumpVel = new Vector(0, 0.6, 0);
Vector cvel = bot.getVelocity().add(jumpVel);
cvel.setX(clamp(cvel.getX(), -0.05, 0.05));
cvel.setZ(clamp(cvel.getZ(), -0.05, 0.05));
bot.setVelocity(cvel);
World world = bot.getLocation().getWorld();
if (world != null) {
world.playSound(bot.getLocation(), Sound.ENTITY_WIND_CHARGE_WIND_BURST, SoundCategory.PLAYERS, 1, 1);
world.spawnParticle(Particle.GUST_EMITTER_SMALL, target.getLocation(), 1, 0, 0, 0, 0.1);
}
Bukkit.getScheduler().scheduleAsyncDelayedTask(plugin, () -> {
while (!bot.isBotOnGround() && bot.getLocation().distanceSquared(target.getLocation()) > 3) {}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
double falldist = -(bot.getVelocity().getY()*10); // CERTAINLY not the best way but meh
//Bukkit.getLogger().info("fall dist: "+falldist+" cvy: "+bot.getVelocity().getY());
if (bot.isBotOnGround()) {
//Bukkit.getLogger().info("Bot -> ground, no mace");
return;
}
double extradmg = 0;
if (falldist >= 1.5) {
extradmg += clamp(falldist,0,3)*4; // first 3 blocks handling
falldist = clamp(falldist-3,0,Double.MAX_VALUE);
extradmg += clamp(falldist,0,5)*2; // next 5 blocks handling
falldist = clamp(falldist-5,0,Double.MAX_VALUE);
extradmg += falldist; // remaining blocks handling
}
bot.setItem(bot.getDefaultItem());
bot.faceLocation(target.getLocation());
bot.punch();
if (bot.getLocation().distanceSquared(target.getLocation()) <= 5) {
double exdmg = extradmg;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
bot.attack(target, exdmg); // apply damage only if within range
// effect stuff
if (world != null && exdmg > 0) {
bot.setVelocity(bot.getVelocity().setY(0.1)); // no fall damage
// schedule next mace attempt to make a streak potentially
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {tryWindchargeMaceAttack(bot, target);}, 0);
world.playSound(bot.getLocation(), Sound.ITEM_MACE_SMASH_GROUND, SoundCategory.PLAYERS, 1, 1);
world.spawnParticle(Particle.EXPLOSION, target.getLocation(), 10, 0.5, 0.5, 0.5, 0.1);
} else {
//Bukkit.getLogger().info("exdmg !> 0");
}
}, 1);
} else {
//Bukkit.getLogger().info("Bot out of range.");
}
}, 0);
}, 8);
return true;
}
private void attack(Terminator bot, LivingEntity target, Location loc) { private void attack(Terminator bot, LivingEntity target, Location loc) {
if ((target instanceof Player && PlayerUtils.isInvincible(((Player) target).getGameMode())) || target.getNoDamageTicks() >= 5 || loc.distance(target.getLocation()) >= 4) if ((target instanceof Player && PlayerUtils.isInvincible(((Player) target).getGameMode())) || target.getNoDamageTicks() >= 5 || loc.distance(target.getLocation()) >= 4)
return; return;
if (tryWindchargeMaceAttack(bot, target)) {
return;
}
bot.attack(target); bot.attack(target);
} }
public void setRegion(BoundingBox region, double regionWeightX, double regionWeightY, double regionWeightZ) { public void setRegion(BoundingBox region, double regionWeightX, double regionWeightY, double regionWeightZ) {
this.region = region; this.region = region;

View File

@@ -46,6 +46,7 @@ public class ItemUtils {
case IRON_SWORD: case IRON_SWORD:
case DIAMOND_AXE: case DIAMOND_AXE:
case NETHERITE_PICKAXE: case NETHERITE_PICKAXE:
case MACE:
return 6; return 6;
case DIAMOND_SWORD: case DIAMOND_SWORD:

View File

@@ -1,2 +1,2 @@
Command: C:\Program Files\Java\jdk-21.0.10\bin\java.exe -Xmx1G -classpath C:\Users\JUFS-STL-SECONDARY\.gradle\caches\modules-2\files-2.1\net.fabricmc\tiny-remapper\0.12.0\bfb93e1bfb66d47272ccd37ce894dcfc20ba0b6\tiny-remapper-0.12.0-fat.jar net.fabricmc.tinyremapper.Main C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\build\libs\TerminatorPlus-Plugin-4.5.1-BETA.jar C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\build\libs\TerminatorPlus-Plugin-4.5.1-BETA-reobf.jar C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\.gradle\caches\paperweight\taskCache\reobfMappings.tiny mojang spigot C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\.gradle\caches\paperweight\taskCache\mappedServerJar.jar --threads=1 Command: C:\Program Files\Java\jdk-21.0.10\bin\java.exe -Xmx1G -classpath C:\Users\JUFS-STL-SECONDARY\.gradle\caches\modules-2\files-2.1\net.fabricmc\tiny-remapper\0.12.0\bfb93e1bfb66d47272ccd37ce894dcfc20ba0b6\tiny-remapper-0.12.0-fat.jar net.fabricmc.tinyremapper.Main C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\build\libs\TerminatorPlus-Plugin-4.5.1-BETA.jar C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\build\libs\TerminatorPlus-Plugin-4.5.1-BETA-reobf.jar C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\.gradle\caches\paperweight\taskCache\reobfMappings.tiny mojang spigot C:\Users\JUFS-STL-SECONDARY\Desktop\terminatorplus\TerminatorPlus-Plugin\.gradle\caches\paperweight\taskCache\mappedServerJar.jar --threads=1
[INFO] Finished after 1642.84 ms. [INFO] Finished after 1622.09 ms.

View File

@@ -345,6 +345,11 @@ public class Bot extends ServerPlayer implements Terminator {
} }
} }
@Override
public ItemStack getDefaultItem() {
return defaultItem;
}
@Override @Override
public UUID getTargetPlayer() { public UUID getTargetPlayer() {
return targetPlayer; return targetPlayer;
@@ -367,7 +372,8 @@ public class Bot extends ServerPlayer implements Terminator {
plugin.getManager().getAgent().onFallDamage(event); plugin.getManager().getAgent().onFallDamage(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
hurt(damageSources().fall(), (float) Math.pow(3.6, -oldVelocity.getY())); Bukkit.getLogger().info("clutch failed");
//hurt(damageSources().fall(), (float) Math.pow(3.6, -oldVelocity.getY()));
} }
} }
} }
@@ -505,17 +511,22 @@ public class Bot extends ServerPlayer implements Terminator {
} }
@Override @Override
public void attack(org.bukkit.entity.Entity entity) { public void attack(org.bukkit.entity.Entity entity, double extra) {
faceLocation(entity.getLocation()); faceLocation(entity.getLocation());
punch(); punch();
double damage = ItemUtils.getLegacyAttackDamage(defaultItem); double damage = ItemUtils.getLegacyAttackDamage(defaultItem)+extra;
if (entity instanceof Damageable) { if (entity instanceof Damageable) {
((Damageable) entity).damage(damage, getBukkitEntity()); ((Damageable) entity).damage(damage, getBukkitEntity());
} }
} }
@Override
public void attack(org.bukkit.entity.Entity entity) {
attack(entity, 0);
}
@Override @Override
public void punch() { public void punch() {
swing(InteractionHand.MAIN_HAND); swing(InteractionHand.MAIN_HAND);

View File

@@ -17,7 +17,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@@ -284,17 +283,4 @@ public class BotManagerImpl implements BotManager, Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Entity killer = player.getKiller();
if (killer != null) {
Terminator bot = getBot(killer.getEntityId());
if (bot != null) {
bot.incrementKills();
}
}
}
} }

View File

@@ -124,6 +124,11 @@ public class CitizensNPC implements Terminator {
return citizensNPC; return citizensNPC;
} }
@Override
public ItemStack getDefaultItem() {
return defaultItem;
}
public static CitizensNPC createNPC(Location loc, String name) { public static CitizensNPC createNPC(Location loc, String name) {
return createNPC(loc, name, name); return createNPC(loc, name, name);
} }
@@ -204,7 +209,7 @@ public class CitizensNPC implements Terminator {
@Override @Override
public boolean isFalling() { public boolean isFalling() {
return velocity.getY() < -0.8; return velocity.getY() < 0;
} }
@Override @Override
@@ -318,18 +323,22 @@ public class CitizensNPC implements Terminator {
look(location.toVector().subtract(entity.getLocation().toVector()), false); look(location.toVector().subtract(entity.getLocation().toVector()), false);
} }
} }
@Override @Override
public void attack(Entity target) { public void attack(Entity target, double extra) {
faceLocation(target.getLocation()); faceLocation(target.getLocation());
punch(); punch();
double damage = ItemUtils.getLegacyAttackDamage(defaultItem); double damage = ItemUtils.getLegacyAttackDamage(defaultItem)+extra;
if (target instanceof Damageable) { if (target instanceof Damageable) {
((Damageable) target).damage(damage, getBukkitEntity()); ((Damageable) target).damage(damage, getBukkitEntity());
} }
} }
@Override
public void attack(Entity target) {
attack(target,0);
}
@Override @Override
public void attemptBlockPlace(Location loc, Material type, boolean down) { public void attemptBlockPlace(Location loc, Material type, boolean down) {
@@ -527,8 +536,13 @@ public class CitizensNPC implements Terminator {
} }
public void tick() { public void tick() {
if (!isBotAlive()) return; if (!isBotAlive()) {
this.removeBot();
return;
}
getBukkitEntity().setFallDistance(0);
aliveTicks++; aliveTicks++;
if (jumpTicks > 0) --jumpTicks; if (jumpTicks > 0) --jumpTicks;
@@ -596,7 +610,7 @@ public class CitizensNPC implements Terminator {
} }
private void doTick() { private void doTick() {
// Can be extended for additional tick logic // Custom behavior can be implemented here or in a trait
} }
private void fallDamageCheck() { private void fallDamageCheck() {
@@ -606,10 +620,11 @@ public class CitizensNPC implements Terminator {
agent.onFallDamage(event); agent.onFallDamage(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
Bukkit.getLogger().info("clutch failed");
LivingEntity entity = getBukkitEntity(); LivingEntity entity = getBukkitEntity();
if (entity != null && entity instanceof Damageable damageable) { if (entity != null && entity instanceof Damageable damageable) {
float damage = (float) Math.pow(3.6, -oldVelocity.getY()); float damage = (float) Math.pow(3.6, -oldVelocity.getY());
damageable.damage(damage); //damageable.damage(damage);
} }
} }
} }

View File

@@ -8,7 +8,6 @@ import net.nuggetmc.tplus.api.agent.legacyagent.ai.IntelligenceAgent;
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork; import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
import net.nuggetmc.tplus.api.utils.DebugLogUtils; import net.nuggetmc.tplus.api.utils.DebugLogUtils;
import net.nuggetmc.tplus.api.utils.MathUtils; import net.nuggetmc.tplus.api.utils.MathUtils;
import net.nuggetmc.tplus.api.utils.MojangAPI;
import net.nuggetmc.tplus.api.utils.PlayerUtils; import net.nuggetmc.tplus.api.utils.PlayerUtils;
import net.nuggetmc.tplus.bot.CitizensNPC; import net.nuggetmc.tplus.bot.CitizensNPC;
import net.nuggetmc.tplus.command.commands.AICommand; import net.nuggetmc.tplus.command.commands.AICommand;

Binary file not shown.