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 a39b272..01e7269 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.RABBIT, new String[]{"true", "&d&lMASTER_GAY", "GOLD"}); + pets.getPetManager().spawn(player, EntityType.CREEPER, new String[]{"&d&lMASTER_GAY", "true"}); } @Override diff --git a/src/main/java/lee/code/pets/pets/PetManager.java b/src/main/java/lee/code/pets/pets/PetManager.java index 5456c9c..b814c7c 100644 --- a/src/main/java/lee/code/pets/pets/PetManager.java +++ b/src/main/java/lee/code/pets/pets/PetManager.java @@ -2,9 +2,7 @@ import lee.code.pets.pets.pet.animal.*; import lee.code.pets.pets.pet.animal.CatPet; -import lee.code.pets.pets.pet.mob.BlazePet; -import lee.code.pets.pets.pet.mob.PhantomPet; -import lee.code.pets.pets.pet.mob.ZombiePet; +import lee.code.pets.pets.pet.mob.*; import net.minecraft.world.entity.Entity; import org.bukkit.World; import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; @@ -27,6 +25,10 @@ public void spawn(Player player, EntityType entityType, String[] data) { case BLAZE -> spawn(player.getWorld(), new BlazePet(player, data[0])); case SNIFFER -> spawn(player.getWorld(), new SnifferPet(player, Boolean.parseBoolean(data[0]), data[1])); case RABBIT -> spawn(player.getWorld(), new RabbitPet(player, Boolean.parseBoolean(data[0]), data[1], data[2])); + case SLIME -> spawn(player.getWorld(), new SlimePet(player, data[0], data[1])); + case MAGMA_CUBE -> spawn(player.getWorld(), new MagmaCubePet(player, data[0], data[1])); + case RAVAGER -> spawn(player.getWorld(), new RavagerPet(player, data[0])); + case CREEPER -> spawn(player.getWorld(), new CreeperPet(player, data[0], Boolean.parseBoolean(data[1]))); } } diff --git a/src/main/java/lee/code/pets/pets/pet/mob/CreeperPet.java b/src/main/java/lee/code/pets/pets/pet/mob/CreeperPet.java new file mode 100644 index 0000000..4cf822e --- /dev/null +++ b/src/main/java/lee/code/pets/pets/pet/mob/CreeperPet.java @@ -0,0 +1,43 @@ +package lee.code.pets.pets.pet.mob; + +import lee.code.pets.pets.controllers.ControllerWASD; +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.monster.Creeper; +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 CreeperPet extends Creeper { + + public CreeperPet(Player player, String name, boolean powered) { + super(EntityType.CREEPER, ((CraftWorld) player.getLocation().getWorld()).getHandle()); + setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); + setInvulnerable(true); + setCustomNameVisible(true); + setPersistenceRequired(true); + collides = false; + setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(name))); + setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false); + moveControl = new ControllerWASD(this, player.getUniqueId()); + setPowered(powered); + } + + @Override + protected void registerGoals() { + goalSelector.addGoal(0, new FollowOwnerGoal(this, 2)); + } + + @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/mob/MagmaCubePet.java b/src/main/java/lee/code/pets/pets/pet/mob/MagmaCubePet.java new file mode 100644 index 0000000..9df0e4d --- /dev/null +++ b/src/main/java/lee/code/pets/pets/pet/mob/MagmaCubePet.java @@ -0,0 +1,43 @@ +package lee.code.pets.pets.pet.mob; + +import lee.code.pets.pets.controllers.ControllerWASD; +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.monster.MagmaCube; +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 MagmaCubePet extends MagmaCube { + + public MagmaCubePet(Player player, String name, String size) { + super(EntityType.MAGMA_CUBE, ((CraftWorld) player.getLocation().getWorld()).getHandle()); + setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); + setInvulnerable(true); + setCustomNameVisible(true); + setPersistenceRequired(true); + collides = false; + setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(name))); + setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false); + moveControl = new ControllerWASD(this, player.getUniqueId()); + setSize(Integer.parseInt(size), true); + } + + @Override + protected void registerGoals() { + goalSelector.addGoal(0, new FollowOwnerGoal(this, 0.7)); + } + + @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/mob/RavagerPet.java b/src/main/java/lee/code/pets/pets/pet/mob/RavagerPet.java new file mode 100644 index 0000000..9232048 --- /dev/null +++ b/src/main/java/lee/code/pets/pets/pet/mob/RavagerPet.java @@ -0,0 +1,44 @@ +package lee.code.pets.pets.pet.mob; + +import lee.code.pets.pets.controllers.ControllerWASD; +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.Mob; +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 RavagerPet extends Mob { + + //TODO CONTROLLER WONT WORK + + public RavagerPet(Player player, String name) { + super(EntityType.RAVAGER, ((CraftWorld) player.getLocation().getWorld()).getHandle()); + setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); + setInvulnerable(true); + setCustomNameVisible(true); + setPersistenceRequired(true); + collides = false; + setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(name))); + setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false); + moveControl = new ControllerWASD(this, player.getUniqueId()); + } + + @Override + protected void registerGoals() { + goalSelector.addGoal(0, new FollowOwnerGoal(this, 2)); + } + + @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/mob/SlimePet.java b/src/main/java/lee/code/pets/pets/pet/mob/SlimePet.java new file mode 100644 index 0000000..203a90d --- /dev/null +++ b/src/main/java/lee/code/pets/pets/pet/mob/SlimePet.java @@ -0,0 +1,43 @@ +package lee.code.pets.pets.pet.mob; + +import lee.code.pets.pets.controllers.ControllerWASD; +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.monster.Slime; +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 SlimePet extends Slime { + + public SlimePet(Player player, String name, String size) { + super(EntityType.SLIME, ((CraftWorld) player.getLocation().getWorld()).getHandle()); + setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); + setInvulnerable(true); + setCustomNameVisible(true); + setPersistenceRequired(true); + collides = false; + setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(name))); + setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false); + moveControl = new ControllerWASD(this, player.getUniqueId()); + setSize(Integer.parseInt(size), true); + } + + @Override + protected void registerGoals() { + goalSelector.addGoal(0, new FollowOwnerGoal(this, 0.7)); + } + + @Override + public void load(CompoundTag compoundTag) { + } + + @Override + public boolean save(CompoundTag compoundTag) { + return false; + } +}