Hello I would like to create CustomPlayer using NMS to modify the player in creative mode to be able to receive damage. I found something in NMS (I guess it's it), but I don't know how to create the CustomPlayer or what I need to do to be able to modify it. Code: public boolean damageEntity(DamageSource damagesource, float f){ if(this.isInvulnerable(damagesource)){ returnfalse; } etc. I've been searching for it for a long time. If anyone know how, please tell me, thank you so much.
Iam sorry, but I don't understand, wdym. Also I was searching for that and someone said that it's possible to override entity listing. I also don't care about animation, damage, etc., I just want to be able trigger event when player is getting damaged.
@joojn Why do you want them in creative? What is the goal of this plugin? There might be an easier way to do what you want.
What I wanted to achive was, you would be normally in creative mode, but it would act as survival mode. I don't need it anymore, I only want if the player hits you (DamageEntityByEntity not because you don't deal dmg). I already found a way using PlayerInteract event and then calculating if you are looking on player, but I works only like 50%, so do you have any idea? The code (Move your mouse to reveal the content) The code (open) The code (close) Code: public static Player getTargetPlayer(final Player player) { return getTarget(player, player.getWorld().getPlayers()); } public static <T extends Entity> T getTarget(final Entity entity, final Iterable<T> entities) { if (entity == null) return null; T target = null; final double threshold = 1; for (final T other : entities) { final Vector n = other.getLocation().toVector() .subtract(entity.getLocation().toVector()); if (entity.getLocation().getDirection().normalize().crossProduct(n) .lengthSquared() < threshold && n.normalize().dot( entity.getLocation().getDirection().normalize()) >= 0) { if (target == null || target.getLocation().distanceSquared( entity.getLocation()) > other.getLocation() .distanceSquared(entity.getLocation())) target = other; } } return target; } @EventHandler public void onPlayerEvent(PlayerInteractEvent event) { if (event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK)) { Player p = event.getPlayer();Player target = getTargetPlayer(p); if(target != null){ if(target.getGameMode() == GameMode.CREATIVE){ Location targetLoc = target.getLocation(); Location playerLoc = p.getLocation(); double reach = p.getGameMode() == GameMode.CREATIVE ? 4 : 3; if(targetLoc.distance(playerLoc) > reach){return;} // velocity knockBack(target, playerLoc); // fake packet animation + sound fakeHit(target);} } } }