custom model data and changing fields to readable names
This commit is contained in:
parent
817a962c37
commit
cb71751fed
2 changed files with 28 additions and 16 deletions
|
@ -1,9 +1,12 @@
|
|||
package me.night.nullvalkyrie.commands;
|
||||
|
||||
import me.night.nullvalkyrie.entities.pets.ZombiePet;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,6 +21,18 @@ public class BetaCommand extends Command {
|
|||
if (sender instanceof Player player) {
|
||||
ZombiePet a = new ZombiePet(player.getLocation(), player);
|
||||
((CraftWorld) player.getWorld()).getHandle().addFreshEntity(a);
|
||||
ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
assert itemMeta != null;
|
||||
itemMeta.setCustomModelData(1010101);
|
||||
item.setItemMeta(itemMeta);
|
||||
player.getInventory().addItem(item);
|
||||
ItemStack item2 = new ItemStack(Material.GOLDEN_SWORD);
|
||||
ItemMeta itemMeta2 = item2.getItemMeta();
|
||||
assert itemMeta2 != null;
|
||||
itemMeta2.setCustomModelData(1010101);
|
||||
item2.setItemMeta(itemMeta2);
|
||||
player.getInventory().addItem(item2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,22 +6,19 @@ import net.minecraft.world.entity.*;
|
|||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
|
||||
public class PathFinderGoalPet extends Goal {
|
||||
|
||||
private final Mob pet; // our pet
|
||||
private LivingEntity owner; // owner
|
||||
|
||||
private final double f; // pet's speed
|
||||
private final float g; // distance between owner & pet
|
||||
|
||||
private double c; // x
|
||||
private double d; // y
|
||||
private double e; // z
|
||||
private final double speed; // pet's speed
|
||||
private final float distance; // distance between owner & pet
|
||||
private double x; // x
|
||||
private double y; // y
|
||||
private double z; // z
|
||||
|
||||
|
||||
public PathFinderGoalPet(Mob mob, double speed, float distance) {
|
||||
this.pet = mob;
|
||||
this.f = speed;
|
||||
this.g = distance;
|
||||
this.speed = speed;
|
||||
this.distance = distance;
|
||||
this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK, Flag.TARGET, Flag.JUMP));
|
||||
}
|
||||
|
||||
|
@ -31,25 +28,25 @@ public class PathFinderGoalPet extends Goal {
|
|||
if (this.owner == null) return false;
|
||||
else if (this.pet.getDisplayName() == null) return false;
|
||||
else if (!this.pet.getDisplayName().getString().contains(this.owner.getName().getString())) return false;
|
||||
else if (this.owner.distanceToSqr(this.pet) > (double) (this.g * this.g)) {
|
||||
else if (this.owner.distanceToSqr(this.pet) > (double) (this.distance * this.distance)) {
|
||||
pet.getBukkitEntity().teleport(this.owner.getBukkitEntity().getLocation());
|
||||
return false;
|
||||
} else {
|
||||
this.c = this.owner.getX();
|
||||
this.d = this.owner.getY();
|
||||
this.e = this.owner.getZ();
|
||||
this.x = this.owner.getX();
|
||||
this.y = this.owner.getY();
|
||||
this.z = this.owner.getZ();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
this.pet.getNavigation().moveTo(this.c, this.d, this.e, this.f);
|
||||
this.pet.getNavigation().moveTo(this.x, this.y, this.z, this.speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
return !this.pet.getNavigation().isDone() && this.owner.distanceToSqr(this.pet) < (double) (this.g * this.g);
|
||||
return !this.pet.getNavigation().isDone() && this.owner.distanceToSqr(this.pet) < (double) (this.distance * this.distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue