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 7ab3230 commit 59a20ff
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 16 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.PHANTOM, new String[]{"&d&lMASTER_GAY"});
pets.getPetManager().spawn(player, EntityType.SHEEP, new String[]{"true", "&d&lMASTER_GAY", "PINK"});
}

@Override
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/lee/code/pets/pets/PetManager.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/animal/BeePet.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/lee/code/pets/pets/pet/mob/PhantomPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,16 +24,20 @@ 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
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;
}
}

0 comments on commit 59a20ff

Please sign in to comment.