diff --git a/src/main/java/lee/code/pets/commands/cmds/TestCMD.java b/src/main/java/lee/code/pets/commands/cmds/TestCMD.java index 28fba9d..7968f42 100644 --- a/src/main/java/lee/code/pets/commands/cmds/TestCMD.java +++ b/src/main/java/lee/code/pets/commands/cmds/TestCMD.java @@ -48,7 +48,7 @@ public boolean performAsyncSynchronized() { @Override public void perform(Player player, String[] args) { - pets.getPetManager().spawn(player, EntityType.PHANTOM, new String[]{"&d&lMASTER_GAY"}); + pets.getPetManager().spawn(player, EntityType.SHEEP, new String[]{"true", "&d&lMASTER_GAY", "PINK"}); } @Override diff --git a/src/main/java/lee/code/pets/pets/PetManager.java b/src/main/java/lee/code/pets/pets/PetManager.java index 6fae2ee..b741d89 100644 --- a/src/main/java/lee/code/pets/pets/PetManager.java +++ b/src/main/java/lee/code/pets/pets/PetManager.java @@ -1,11 +1,8 @@ package lee.code.pets.pets; -import lee.code.pets.pets.pet.animal.VillagerPet; -import lee.code.pets.pets.pet.tamable.CatPet; -import lee.code.pets.pets.pet.animal.ChickenPet; -import lee.code.pets.pets.pet.animal.WolfPet; +import lee.code.pets.pets.pet.animal.*; +import lee.code.pets.pets.pet.animal.CatPet; import lee.code.pets.pets.pet.mob.PhantomPet; -import lee.code.pets.pets.pet.animal.SheepPet; import net.minecraft.world.entity.Entity; import org.bukkit.World; import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; @@ -23,6 +20,7 @@ public void spawn(Player player, EntityType entityType, String[] data) { case WOLF -> spawn(player.getWorld(), new WolfPet(player, Boolean.parseBoolean(data[0]), data[1])); case CAT -> spawn(player.getWorld(), new CatPet(player, Boolean.parseBoolean(data[0]), data[1], data[2], data[3])); case VILLAGER -> spawn(player.getWorld(), new VillagerPet(player, Boolean.parseBoolean(data[0]), data[1])); + case BEE -> spawn(player.getWorld(), new BeePet(player, Boolean.parseBoolean(data[0]), data[1])); } } diff --git a/src/main/java/lee/code/pets/pets/controllers/ControllerLookFlying.java b/src/main/java/lee/code/pets/pets/controllers/ControllerLookFlying.java index 55b0dab..43b0463 100644 --- a/src/main/java/lee/code/pets/pets/controllers/ControllerLookFlying.java +++ b/src/main/java/lee/code/pets/pets/controllers/ControllerLookFlying.java @@ -7,11 +7,9 @@ import java.util.UUID; public class ControllerLookFlying extends ControllerWASD { - private final float speed; - public ControllerLookFlying(Mob mob, UUID owner, float speed) { + public ControllerLookFlying(Mob mob, UUID owner) { super(mob, owner); - this.speed = speed; } @Override @@ -34,7 +32,7 @@ public void tick() { final double motionZ = forward * Math.cos(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)); // Set the mob's motion - mob.setSpeed(speed); // You can adjust the speed as needed. + mob.setSpeed(0.2F); // You can adjust the speed as needed. mob.setZza(forward); mob.setXxa(0.0F); mob.setYya((float) motionY); // Set vertical motion here diff --git a/src/main/java/lee/code/pets/pets/pet/animal/BeePet.java b/src/main/java/lee/code/pets/pets/pet/animal/BeePet.java new file mode 100644 index 0000000..309242c --- /dev/null +++ b/src/main/java/lee/code/pets/pets/pet/animal/BeePet.java @@ -0,0 +1,58 @@ +package lee.code.pets.pets.pet.animal; + +import lee.code.pets.pets.controllers.ControllerLookFlying; +import lee.code.pets.pets.goals.FollowOwnerGoal; +import lee.code.pets.utils.CoreUtil; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.AgeableMob; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.animal.Animal; +import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityTargetEvent; + +public class BeePet extends Animal { + + public BeePet(Player player, boolean baby, String name) { + super(EntityType.BEE, ((CraftWorld) player.getLocation().getWorld()).getHandle()); + setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); + setInvulnerable(true); + setCustomNameVisible(true); + setPersistenceRequired(true); + setNoGravity(true); + collides = false; + setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(name))); + setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false); + moveControl = new ControllerLookFlying(this, player.getUniqueId()); + if (baby) setBaby(true); + } + + @Override + protected void registerGoals() { + goalSelector.addGoal(0, new FollowOwnerGoal(this, 2)); + } + + public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob entity) { + return null; + } + + @Override + public void ageUp(int age) { + } + + @Override + public void ageUp(int age, boolean overGrow) { + } + + @Override + public void load(CompoundTag compoundTag) { + } + + @Override + public boolean save(CompoundTag compoundTag) { + return false; + } +} diff --git a/src/main/java/lee/code/pets/pets/pet/tamable/CatPet.java b/src/main/java/lee/code/pets/pets/pet/animal/CatPet.java similarity index 98% rename from src/main/java/lee/code/pets/pets/pet/tamable/CatPet.java rename to src/main/java/lee/code/pets/pets/pet/animal/CatPet.java index 6ee463c..f2b4997 100644 --- a/src/main/java/lee/code/pets/pets/pet/tamable/CatPet.java +++ b/src/main/java/lee/code/pets/pets/pet/animal/CatPet.java @@ -1,4 +1,4 @@ -package lee.code.pets.pets.pet.tamable; +package lee.code.pets.pets.pet.animal; import lee.code.pets.pets.controllers.ControllerWASD; import lee.code.pets.pets.goals.FollowOwnerGoal; diff --git a/src/main/java/lee/code/pets/pets/pet/mob/PhantomPet.java b/src/main/java/lee/code/pets/pets/pet/mob/PhantomPet.java index d0ecb3f..2e05f95 100644 --- a/src/main/java/lee/code/pets/pets/pet/mob/PhantomPet.java +++ b/src/main/java/lee/code/pets/pets/pet/mob/PhantomPet.java @@ -3,9 +3,9 @@ import lee.code.pets.pets.controllers.ControllerLookFlying; import lee.code.pets.pets.goals.FollowOwnerGoal; import lee.code.pets.utils.CoreUtil; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.monster.Phantom; import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; @@ -24,8 +24,7 @@ public PhantomPet(Player player, String name) { collides = false; setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(name))); setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false); - moveControl = new ControllerLookFlying(this, player.getUniqueId(), 5); - setAttributes(); + moveControl = new ControllerLookFlying(this, player.getUniqueId()); } @Override @@ -33,7 +32,12 @@ protected void registerGoals() { goalSelector.addGoal(0, new FollowOwnerGoal(this, 3)); } - protected void setAttributes() { - getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.5D); + @Override + public void load(CompoundTag compoundTag) { + } + + @Override + public boolean save(CompoundTag compoundTag) { + return false; } }