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;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.entities.pets.ZombiePet;
|
import me.night.nullvalkyrie.entities.pets.ZombiePet;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -18,6 +21,18 @@ public class BetaCommand extends Command {
|
||||||
if (sender instanceof Player player) {
|
if (sender instanceof Player player) {
|
||||||
ZombiePet a = new ZombiePet(player.getLocation(), player);
|
ZombiePet a = new ZombiePet(player.getLocation(), player);
|
||||||
((CraftWorld) player.getWorld()).getHandle().addFreshEntity(a);
|
((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;
|
import net.minecraft.world.entity.ai.goal.Goal;
|
||||||
|
|
||||||
public class PathFinderGoalPet extends Goal {
|
public class PathFinderGoalPet extends Goal {
|
||||||
|
|
||||||
private final Mob pet; // our pet
|
private final Mob pet; // our pet
|
||||||
private LivingEntity owner; // owner
|
private LivingEntity owner; // owner
|
||||||
|
private final double speed; // pet's speed
|
||||||
private final double f; // pet's speed
|
private final float distance; // distance between owner & pet
|
||||||
private final float g; // distance between owner & pet
|
private double x; // x
|
||||||
|
private double y; // y
|
||||||
private double c; // x
|
private double z; // z
|
||||||
private double d; // y
|
|
||||||
private double e; // z
|
|
||||||
|
|
||||||
|
|
||||||
public PathFinderGoalPet(Mob mob, double speed, float distance) {
|
public PathFinderGoalPet(Mob mob, double speed, float distance) {
|
||||||
this.pet = mob;
|
this.pet = mob;
|
||||||
this.f = speed;
|
this.speed = speed;
|
||||||
this.g = distance;
|
this.distance = distance;
|
||||||
this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK, Flag.TARGET, Flag.JUMP));
|
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;
|
if (this.owner == null) return false;
|
||||||
else if (this.pet.getDisplayName() == 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.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());
|
pet.getBukkitEntity().teleport(this.owner.getBukkitEntity().getLocation());
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.c = this.owner.getX();
|
this.x = this.owner.getX();
|
||||||
this.d = this.owner.getY();
|
this.y = this.owner.getY();
|
||||||
this.e = this.owner.getZ();
|
this.z = this.owner.getZ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
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
|
@Override
|
||||||
public boolean canContinueToUse() {
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue