Fix #43 (Randomly stuck sitting foxes)

This commit is contained in:
SeanOMik 2021-06-23 20:09:49 -04:00
parent 63814427db
commit 7510a51f96
No known key found for this signature in database
GPG Key ID: CA09E5BE1F32728A
12 changed files with 45 additions and 39 deletions

View File

@ -181,7 +181,7 @@ public class EntityTamableFox extends EntityFox {
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
compound.setBoolean("Sitting", this.isSitting());
compound.setBoolean("Sitting", this.goalSit.isWillSit());
}
// readAdditionalSaveData
@ -192,10 +192,7 @@ public class EntityTamableFox extends EntityFox {
if (compound.hasKeyOfType("OwnerUUID", 8)) {
ownerUuid = compound.getString("OwnerUUID");
}/* else {
String var2 = compound.getString("Owner");
ownerUuid = NameReferencingFileConverter.a(this.getMinecraftServer(), var2);
}*/
}
if (!ownerUuid.isEmpty()) {
try {
@ -210,7 +207,9 @@ public class EntityTamableFox extends EntityFox {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
if (!this.isTamed()) {
goalSit.setSitting(false);
}
}
public boolean isTamed() {

View File

@ -48,6 +48,8 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
this.entity.setSitting(false);
}
public boolean isWillSit() { return this.willSit; }
public void setSitting(boolean flag) {
this.willSit = flag;
}

View File

@ -181,7 +181,7 @@ public class EntityTamableFox extends EntityFox {
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
compound.setBoolean("Sitting", this.isSitting());
compound.setBoolean("Sitting", this.goalSit.isWillSit());
}
// readAdditionalSaveData
@ -192,10 +192,7 @@ public class EntityTamableFox extends EntityFox {
if (compound.hasKeyOfType("OwnerUUID", 8)) {
ownerUuid = compound.getString("OwnerUUID");
}/* else {
String var2 = compound.getString("Owner");
ownerUuid = NameReferencingFileConverter.a(this.getMinecraftServer(), var2);
}*/
}
if (!ownerUuid.isEmpty()) {
try {
@ -210,7 +207,9 @@ public class EntityTamableFox extends EntityFox {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
if (!this.isTamed()) {
goalSit.setSitting(false);
}
}
public boolean isTamed() {

View File

@ -49,6 +49,8 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
this.entity.setSitting(false);
}
public boolean isWillSit() { return this.willSit; }
public void setSitting(boolean flag) {
this.willSit = flag;
}

View File

@ -180,7 +180,7 @@ public class EntityTamableFox extends EntityFox {
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
compound.setBoolean("Sitting", this.isSitting());
compound.setBoolean("Sitting", this.goalSit.isWillSit());
}
@Override
@ -190,10 +190,7 @@ public class EntityTamableFox extends EntityFox {
if (compound.hasKeyOfType("OwnerUUID", 8)) {
ownerUuid = compound.getString("OwnerUUID");
}/* else {
String var2 = compound.getString("Owner");
ownerUuid = NameReferencingFileConverter.a(this.getMinecraftServer(), var2);
}*/
}
if (!ownerUuid.isEmpty()) {
try {
@ -208,7 +205,9 @@ public class EntityTamableFox extends EntityFox {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
if (!this.isTamed()) {
goalSit.setSitting(false);
}
}
public boolean isTamed() {

View File

@ -48,6 +48,8 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
this.entity.setSitting(false);
}
public boolean isWillSit() { return this.willSit; }
public void setSitting(boolean flag) {
this.willSit = flag;
}

View File

@ -178,7 +178,7 @@ public class EntityTamableFox extends EntityFox {
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
compound.setBoolean("Sitting", this.isSitting());
compound.setBoolean("Sitting", this.goalSit.isWillSit());
}
@Override
@ -188,10 +188,7 @@ public class EntityTamableFox extends EntityFox {
if (compound.hasKeyOfType("OwnerUUID", 8)) {
ownerUuid = compound.getString("OwnerUUID");
}/* else {
String var2 = compound.getString("Owner");
ownerUuid = NameReferencingFileConverter.a(this.getMinecraftServer(), var2);
}*/
}
if (!ownerUuid.isEmpty()) {
try {
@ -206,7 +203,9 @@ public class EntityTamableFox extends EntityFox {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
if (!this.isTamed()) {
goalSit.setSitting(false);
}
}
public boolean isTamed() {

View File

@ -48,6 +48,8 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
this.entity.setSitting(false);
}
public boolean isWillSit() { return this.willSit; }
public void setSitting(boolean flag) {
this.willSit = flag;
}

View File

@ -178,7 +178,7 @@ public class EntityTamableFox extends EntityFox {
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
compound.setBoolean("Sitting", this.isSitting());
compound.setBoolean("Sitting", this.goalSit.isWillSit());
}
@Override
@ -188,10 +188,7 @@ public class EntityTamableFox extends EntityFox {
if (compound.hasKeyOfType("OwnerUUID", 8)) {
ownerUuid = compound.getString("OwnerUUID");
}/* else {
String var2 = compound.getString("Owner");
ownerUuid = NameReferencingFileConverter.a(this.getMinecraftServer(), var2);
}*/
}
if (!ownerUuid.isEmpty()) {
try {
@ -206,7 +203,9 @@ public class EntityTamableFox extends EntityFox {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
if (!this.isTamed()) {
goalSit.setSitting(false);
}
}
public boolean isTamed() {

View File

@ -48,6 +48,10 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
this.entity.setSitting(false);
}
public boolean isWillSit() {
return this.willSit;
}
public void setSitting(boolean flag) {
this.willSit = flag;
}

View File

@ -231,7 +231,7 @@ public class EntityTamableFox extends EntityFox {
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
compound.setBoolean("Sitting", this.isSitting());
compound.setBoolean("Sitting", this.goalSit.isWillSit());
}
@Override
@ -241,10 +241,7 @@ public class EntityTamableFox extends EntityFox {
if (compound.hasKeyOfType("OwnerUUID", 8)) {
ownerUuid = compound.getString("OwnerUUID");
}/* else {
String var2 = compound.getString("Owner");
ownerUuid = NameReferencingFileConverter.a(this.getMinecraftServer(), var2);
}*/
}
if (!ownerUuid.isEmpty()) {
try {
@ -259,7 +256,9 @@ public class EntityTamableFox extends EntityFox {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
if (!this.isTamed()) {
goalSit.setSitting(false);
}
}
public boolean isTamed() {

View File

@ -40,12 +40,10 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
}
public void c() {
this.entity.getNavigation().o();
this.entity.setGoalTarget(null);
// For some reason it needs to be ran later to not have the fox slide across the floor.
Bukkit.getScheduler().runTaskLater(Utils.tamableFoxesPlugin, () -> {
this.entity.setSitting(true);
this.entity.getNavigation().o();
}, 1L);
}
@ -53,6 +51,8 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
this.entity.setSitting(false);
}
public boolean isWillSit() { return this.willSit; }
public void setSitting(boolean flag) {
this.willSit = flag;
}