commit cb71751fed0d7609c82d62c9d3a68db0af05bddc
parent 817a962c37d0db53045206aaf2eac3af4a87c4ac
Author: NK <[email protected]>
Date: Fri, 23 Dec 2022 17:41:02 +0000
custom model data and changing fields to readable names
Diffstat:
2 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java b/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java
@@ -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);
}
}
diff --git a/src/main/java/me/night/nullvalkyrie/entities/pets/PathFinderGoalPet.java b/src/main/java/me/night/nullvalkyrie/entities/pets/PathFinderGoalPet.java
@@ -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