async hitbox

Discussion in 'Spigot Plugin Development' started by zDoeProgram, Feb 10, 2019.

  1. Hey, I made a custom async hitbox, although now I have to manually add all the normal damage stuff into it.
    Was wondering if anyone had the source to the regular minecraft hitbox damage system, so I would not have to type it all out :p
     
  2. Just look into the server source code or use mcp to get the client source code
     
    • Agree Agree x 1
  3. Code (Java):
    public void runAsync(final Player attacker, final Entity e, final Player dmgd, final Packet packet) {
            new BukkitRunnable() {
                public void run() {
                    for(Player p : Bukkit.getOnlinePlayers()) {
                        CraftPlayer cp = (CraftPlayer) p;
                       
                        EntityPlayer ep = ((CraftPlayer) dmgd).getHandle();
                        EntityPlayer epa = ((CraftPlayer) attacker).getHandle();
                       
                       
                        //THIS LINE BELOW!!
                        ep.setHealth(ep.getHealth() - 1);
                       
                       
                        double victimMotX = e.motX;
                        double victimMotY = e.motY;
                        double victimMotZ = e.motZ;
                       
                        ep.velocityChanged = true;
                       
                        g(ep, -MathHelper.sin(epa.yaw * 3.1415927F / 180.0F) * 1 * 0.5F * 0.95D * 1.05, 0.1D * 1.05,
                                MathHelper.cos(epa.yaw * 3.1415927F / 180.0F)* 1 * 0.5F * 0.95D * 1.05);
                       
                        //ep.motX *= 1.05;
                        //ep.motY *= 1.05;
                        //ep.motZ *= 1.05;
                       
                        PlayerVelocityEvent event = new PlayerVelocityEvent(ep.getBukkitEntity(), ep.getBukkitEntity().getVelocity());
                        Bukkit.getPluginManager().callEvent(event);
                        if(!event.isCancelled()) {
                            ep.getBukkitEntity().setVelocity(event.getVelocity());
                        }
                        ep.velocityChanged = false;
                        ep.motX = victimMotX;
                        ep.motY = victimMotY;
                        ep.motZ = victimMotZ;
                       
                        cp.getHandle().playerConnection.sendPacket(packet);
                    }
                }
            }.runTaskAsynchronously(this);
        }
    As you can see from the code, I dont know how to apply the regular damage, concidering armor and weapons. Anyone know how?