Skip to content

Commit

Permalink
Attack target method: use new(ish) Spigot API method for setTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 20, 2022
1 parent 6624be6 commit 6885cf0
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 34 deletions.
Expand Up @@ -47,8 +47,6 @@ public void setSneaking(Entity player, boolean sneak) {

public abstract Entity getEntity(World world, UUID uuid);

public abstract void setTarget(Creature entity, LivingEntity target);

public abstract CompoundTag getNbtData(Entity entity);

public abstract void setNbtData(Entity entity, CompoundTag compoundTag);
Expand Down
Expand Up @@ -1009,8 +1009,8 @@ public void target(LivingEntity target) {
if (!isSpawned()) {
return;
}
if (entity instanceof Creature) {
NMSHandler.entityHelper.setTarget((Creature) entity, target);
if (entity instanceof Mob) {
((Mob) entity).setTarget(target);
}
else if (entity instanceof ShulkerBullet) {
((ShulkerBullet) entity).setTarget(target);
Expand Down
Expand Up @@ -629,11 +629,13 @@ else if (value.startsWith("e@")) {
}

// <--[tag]
// @attribute <server.command_source_plugin[<name>]>
// @attribute <server.command_plugin[<name>]>
// @returns PluginTag
// @description
// Returns the plugin that created a command (if known).
// For example, <server.command_plugin[ex]> should return a PluginTag of Denizen.
// @example
// # Should show "Denizen".
// - narrate <server.command_plugin[ex].name>
// -->
if (attribute.startsWith("command_plugin")) {
PluginCommand cmd = Bukkit.getPluginCommand(attribute.getParam());
Expand Down
Expand Up @@ -120,13 +120,6 @@ public Entity getEntity(World world, UUID uuid) {
return entity == null ? null : entity.getBukkitEntity();
}

@Override
public void setTarget(Creature entity, LivingEntity target) {
EntityLiving nmsTarget = target != null ? ((CraftLivingEntity) target).getHandle() : null;
((CraftCreature) entity).getHandle().setGoalTarget(nmsTarget, EntityTargetEvent.TargetReason.CUSTOM, true);
entity.setTarget(target);
}

@Override
public CompoundTag getNbtData(Entity entity) {
NBTTagCompound compound = new NBTTagCompound();
Expand Down
Expand Up @@ -149,13 +149,6 @@ public Entity getEntity(World world, UUID uuid) {
return entity == null ? null : entity.getBukkitEntity();
}

@Override
public void setTarget(Creature entity, LivingEntity target) {
net.minecraft.world.entity.LivingEntity nmsTarget = target != null ? ((CraftLivingEntity) target).getHandle() : null;
((CraftCreature) entity).getHandle().setGoalTarget(nmsTarget, EntityTargetEvent.TargetReason.CUSTOM, true);
entity.setTarget(target);
}

@Override
public CompoundTag getNbtData(Entity entity) {
net.minecraft.nbt.CompoundTag compound = new net.minecraft.nbt.CompoundTag();
Expand Down
Expand Up @@ -166,13 +166,6 @@ public Entity getEntity(World world, UUID uuid) {
return entity == null ? null : entity.getBukkitEntity();
}

@Override
public void setTarget(Creature entity, LivingEntity target) {
net.minecraft.world.entity.LivingEntity nmsTarget = target != null ? ((CraftLivingEntity) target).getHandle() : null;
((CraftCreature) entity).getHandle().setTarget(nmsTarget, EntityTargetEvent.TargetReason.CUSTOM, true);
entity.setTarget(target);
}

@Override
public CompoundTag getNbtData(Entity entity) {
net.minecraft.nbt.CompoundTag compound = new net.minecraft.nbt.CompoundTag();
Expand Down
Expand Up @@ -172,13 +172,6 @@ public Entity getEntity(World world, UUID uuid) {
return entity == null ? null : entity.getBukkitEntity();
}

@Override
public void setTarget(Creature entity, LivingEntity target) {
net.minecraft.world.entity.LivingEntity nmsTarget = target != null ? ((CraftLivingEntity) target).getHandle() : null;
((CraftCreature) entity).getHandle().setTarget(nmsTarget, EntityTargetEvent.TargetReason.CUSTOM, true);
entity.setTarget(target);
}

@Override
public CompoundTag getNbtData(Entity entity) {
net.minecraft.nbt.CompoundTag compound = new net.minecraft.nbt.CompoundTag();
Expand Down

0 comments on commit 6885cf0

Please sign in to comment.