Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTheTech committed Sep 20, 2023
1 parent 2f1ccee commit dbb3533
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/lee/code/pets/commands/cmds/TestCMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/lee/code/pets/pets/PetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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])));
}
}

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/mob/CreeperPet.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
43 changes: 43 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/mob/MagmaCubePet.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
44 changes: 44 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/mob/RavagerPet.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
43 changes: 43 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/mob/SlimePet.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit dbb3533

Please sign in to comment.