From 7510a51f96573fe346a569597c914ae6e10cef3d Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Wed, 23 Jun 2021 20:09:49 -0400 Subject: [PATCH] Fix #43 (Randomly stuck sitting foxes) --- .../versions/version_1_14_R1/EntityTamableFox.java | 11 +++++------ .../pathfinding/FoxPathfinderGoalSit.java | 2 ++ .../versions/version_1_15_R1/EntityTamableFox.java | 11 +++++------ .../pathfinding/FoxPathfinderGoalSit.java | 2 ++ .../versions/version_1_16_R1/EntityTamableFox.java | 11 +++++------ .../pathfinding/FoxPathfinderGoalSit.java | 2 ++ .../versions/version_1_16_R2/EntityTamableFox.java | 11 +++++------ .../pathfinding/FoxPathfinderGoalSit.java | 2 ++ .../versions/version_1_16_R3/EntityTamableFox.java | 11 +++++------ .../pathfinding/FoxPathfinderGoalSit.java | 4 ++++ .../versions/version_1_17_R1/EntityTamableFox.java | 11 +++++------ .../pathfinding/FoxPathfinderGoalSit.java | 6 +++--- 12 files changed, 45 insertions(+), 39 deletions(-) diff --git a/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java b/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java index 78afc0e..c0dfb05 100644 --- a/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java +++ b/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java @@ -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() { diff --git a/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/pathfinding/FoxPathfinderGoalSit.java b/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/pathfinding/FoxPathfinderGoalSit.java index d2196cf..e9159c2 100644 --- a/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/pathfinding/FoxPathfinderGoalSit.java +++ b/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/pathfinding/FoxPathfinderGoalSit.java @@ -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; } diff --git a/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java b/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java index 9c47eac..50e1efe 100644 --- a/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java +++ b/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java @@ -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() { diff --git a/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalSit.java b/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalSit.java index b38ab79..851d68c 100644 --- a/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalSit.java +++ b/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalSit.java @@ -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; } diff --git a/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java b/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java index 07a3608..7fec7cb 100644 --- a/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java +++ b/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java @@ -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() { diff --git a/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/pathfinding/FoxPathfinderGoalSit.java b/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/pathfinding/FoxPathfinderGoalSit.java index a181625..d10203a 100644 --- a/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/pathfinding/FoxPathfinderGoalSit.java +++ b/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/pathfinding/FoxPathfinderGoalSit.java @@ -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; } diff --git a/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java b/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java index 4274980..5c5be7e 100644 --- a/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java +++ b/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java @@ -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() { diff --git a/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/pathfinding/FoxPathfinderGoalSit.java b/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/pathfinding/FoxPathfinderGoalSit.java index 2dee1f7..f3294b2 100644 --- a/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/pathfinding/FoxPathfinderGoalSit.java +++ b/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/pathfinding/FoxPathfinderGoalSit.java @@ -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; } diff --git a/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/EntityTamableFox.java b/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/EntityTamableFox.java index 23efcce..cc51cb3 100644 --- a/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/EntityTamableFox.java +++ b/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/EntityTamableFox.java @@ -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() { diff --git a/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/pathfinding/FoxPathfinderGoalSit.java b/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/pathfinding/FoxPathfinderGoalSit.java index e0e62f7..0f5167d 100644 --- a/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/pathfinding/FoxPathfinderGoalSit.java +++ b/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/pathfinding/FoxPathfinderGoalSit.java @@ -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; } diff --git a/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/EntityTamableFox.java b/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/EntityTamableFox.java index 094fe14..161afd1 100644 --- a/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/EntityTamableFox.java +++ b/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/EntityTamableFox.java @@ -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() { diff --git a/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/pathfinding/FoxPathfinderGoalSit.java b/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/pathfinding/FoxPathfinderGoalSit.java index 539af6f..b167ae4 100644 --- a/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/pathfinding/FoxPathfinderGoalSit.java +++ b/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/pathfinding/FoxPathfinderGoalSit.java @@ -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; }