Skip to content

Commit

Permalink
Pet-Spawn-Fix - Started detective work on why exactly they are not fo…
Browse files Browse the repository at this point in the history
…llowing
  • Loading branch information
Jakllp committed Aug 19, 2021
1 parent e5ba2b7 commit b279ce5
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public enum MyPetType {
Cow("COW", "1.7.10", MyCow.class, new Compat<>()
.v("1.7.10", 92)
.v("1.13", "cow")
.v("1.17", "n") //This creates a... pig
.search()),
Creeper("CREEPER", "1.7.10", MyCreeper.class, new Compat<>()
.v("1.7.10", 50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.minecraft.world.entity.EntitySize;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.EnumCreatureType;
import net.minecraft.world.entity.animal.EntityFox;
import net.minecraft.world.level.World;

import org.bukkit.Bukkit;
Expand All @@ -57,10 +58,10 @@ public class EntityRegistry extends de.Keyle.MyPet.api.entity.EntityRegistry {
BiMap<MyPetType, Class<? extends EntityMyPet>> entityClasses = HashBiMap.create();
Map<MyPetType, EntityTypes> entityTypes = new HashMap<>();

protected void registerEntityType(MyPetType petType, String key, RegistryBlocks<EntityTypes<?>> entityRegistry) {
EntitySize size = entityRegistry.get(new MinecraftKey(key.toLowerCase())).m();
entityTypes.put(petType, IRegistry.a(entityRegistry, "mypet_" + key.toLowerCase(), EntityTypes.Builder.a(EnumCreatureType.b).b().a().a(size.a, size.b).a(key)));
registerDefaultAttributes(entityTypes.get(petType), (EntityTypes<? extends EntityLiving>) ReflectionUtil.getFieldValue(EntityTypes.class, null, ("" + petType.getTypeID()).toUpperCase()));
protected void registerEntityType(MyPetType petType, String key, RegistryBlocks<EntityTypes<?>> entityRegistry) { //TODO 2021/08/19 The only thing left: They need to follow the player
EntityTypes<? extends EntityLiving> types = (EntityTypes<? extends EntityLiving>) entityRegistry.get(new MinecraftKey(key));
entityTypes.put(petType, types);
registerDefaultAttributes(entityTypes.get(petType), types);
overwriteEntityID(entityTypes.get(petType), getEntityTypeId(petType, entityRegistry), entityRegistry);
}

Expand Down Expand Up @@ -89,7 +90,7 @@ public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bu

try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet); //TODO 2021/08/18 This fails - pet not having the right class?
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class MyAttributeDefaults {
.putFast(EntityTypes.G, EntityGiantZombie.n().a()) //Giant
.putFast(EntityTypes.K, EntityGuardian.fw().a()) //Guardian
.putFast(EntityTypes.J, Goat.p().a()) //Goat
.putFast(EntityTypes.I, GlowSquid.fw().a()) //Goat
.putFast(EntityTypes.I, GlowSquid.fw().a()) //GlowSquid
.putFast(EntityTypes.L, EntityHoglin.p().a()) //Hoglin
.putFast(EntityTypes.M, EntityHorseAbstract.fS().a()) //Horse
.putFast(EntityTypes.N, EntityZombie.fB().a()) //Husk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import net.minecraft.world.entity.EntityLiving;
import net.minecraft.world.entity.ai.attributes.AttributeModifiable;
import net.minecraft.world.entity.ai.attributes.GenericAttributes;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;

Expand Down Expand Up @@ -105,10 +107,11 @@ public void tick() {
if (ownerLocation.getWorld() != petLocation.getWorld()) {
return;
}

//Look at Owner
this.petEntity.getControllerLook().a(owner, this.petEntity.eZ(), this.petEntity.eZ());

//I'm guessing "eY" was yaw (that is now aY) - might not be - MARK: Look
this.petEntity.getControllerLook().a(owner, this.petEntity.aY(), (float) this.petEntity.aY());

//Teleportation
if (this.petEntity.canMove()) {
if (!owner.getAbilities().b) {
if (!waitForGround) {
Expand All @@ -132,10 +135,10 @@ public void tick() {
} else {
waitForGround = true;
}

if (--this.setPathTimer <= 0) {
this.setPathTimer = 10;
if (this.nav.navigateTo(owner.getBukkitEntity())) {
if (this.nav.navigateTo(owner.getBukkitEntity())) { //TODO 2021/08/19 Seemingly not doing that properly?
applyWalkSpeed();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public void finish() {

@Override
public void tick() {
//I'm guessing "eY" was yaw (that is now aY) - might not be - MARK: Look
this.petEntity.getControllerLook().a(this.targetPlayer.locX(), this.targetPlayer.locY() + this.targetPlayer.getHeadHeight(), this.targetPlayer.locZ(), petEntity.aY(), this.petEntity.aY());
this.petEntity.getControllerLook().a(this.targetPlayer.locX(), this.targetPlayer.locY() + this.targetPlayer.getHeadHeight(), this.targetPlayer.locZ(), petEntity.eZ(), this.petEntity.eZ());
this.ticksUntilStopLooking -= 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public void start() {

@Override
public void tick() {
//I'm guessing "eY" was yaw (that is now aY) - might not be - MARK: Look
this.ticksUntilStopLookingAround--;
this.petEntity.getControllerLook().a(this.petEntity.locX() + this.directionX, this.petEntity.locY() + this.petEntity.getHeadHeight(), this.petEntity.locZ() + this.directionZ, this.petEntity.aY(), this.petEntity.aY());
this.petEntity.getControllerLook().a(this.petEntity.locX() + this.directionX, this.petEntity.locY() + this.petEntity.getHeadHeight(), this.petEntity.locZ() + this.directionZ, this.petEntity.eZ(), this.petEntity.eZ());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean navigateTo(LivingEntity entity) {

public boolean navigateTo(EntityLiving entity) {
if (this.nav.a(entity, 1.D)) {
applyNavigationParameters();
applyNavigationParameters(); //TODO 2021/08/19 Potentially doing this wrong...
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MyPetLargeFireball extends EntityLargeFireball implements EntityMyP
protected CraftMyPetLargeFireball bukkitEntity = null;

public MyPetLargeFireball(World world, EntityMyPet entityliving, double d0, double d1, double d2) {
super(world, entityliving, d0, d1, d2, 1); // TODO: 2021/06/28 temp value (i)
super(world, entityliving, d0, d1, d2, 1); // TODO: 2021/06/28 temp value (i) - 2021/08/19 is this done? Where is i here?
}

@Override
Expand Down

0 comments on commit b279ce5

Please sign in to comment.