Fix some small issues and optimize some entity goals

This commit is contained in:
SeanOMik 2020-07-14 13:51:00 -05:00
parent 304762408f
commit 1b3c38a64e
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
10 changed files with 214 additions and 141 deletions

View File

@ -2,28 +2,16 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="dcab9632-7b1a-44d7-9283-be9b37640afc" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/NMSInterface_1_15_R1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/Utils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/LanguageConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/LanguageConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/CommandSpawnTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/CommandSpawnTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalFollowOwner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalFollowOwner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalHurtByTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalHurtByTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalMeleeAttack.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalMeleeAttack.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalPanic.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalPanic.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalSit.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalSit.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/language.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/language.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/pathfinding/FoxPathfinderGoalMeleeAttack.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/pathfinding/FoxPathfinderGoalSleepWithOwner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/pathfinding/FoxPathfinderGoalSleepWithOwner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-archiver/pom.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-archiver/pom.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -83,6 +71,7 @@
<recent name="net.seanomik.tamablefoxes.versions" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="net.seanomik.tamablefoxes.versions.version_1_15_R1.pathfinding" />
<recent name="net.seanomik.tamablefoxes.versions.version_1_16_R1.command" />
<recent name="net.seanomik.tamablefoxes.versions.version_1_15_R1.command" />
<recent name="net.seanomik.tamablefoxes.versions.version_1_15" />
@ -94,7 +83,7 @@
<recent name="E:\TamableFoxesCustomEntity\src\main\resources" />
</key>
</component>
<component name="RunManager" selected="JAR Application.Spigot-1.16.1">
<component name="RunManager" selected="JAR Application.Spigot-1.15.2">
<configuration name="Spigot-1.15.2" type="JarApplication">
<option name="JAR_PATH" value="$PROJECT_DIR$/../../_TEST_SERVER_1.15.2_/spigot-1.15.2.jar" />
<option name="PROGRAM_PARAMETERS" value="nogui" />
@ -226,38 +215,38 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="740" y="275" key="FileChooserDialogImpl/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1590119699228" />
<state width="1877" height="197" key="GridCell.Tab.0.bottom" timestamp="1594748168001">
<state width="1877" height="211" key="GridCell.Tab.0.bottom" timestamp="1594752102677">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748168001" />
<state width="1877" height="197" key="GridCell.Tab.0.center" timestamp="1594748168001">
<state width="1877" height="211" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102677" />
<state width="1877" height="211" key="GridCell.Tab.0.center" timestamp="1594752102676">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748168001" />
<state width="1877" height="197" key="GridCell.Tab.0.left" timestamp="1594748168001">
<state width="1877" height="211" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102676" />
<state width="1877" height="211" key="GridCell.Tab.0.left" timestamp="1594752102676">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748168001" />
<state width="1877" height="197" key="GridCell.Tab.0.right" timestamp="1594748168001">
<state width="1877" height="211" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102676" />
<state width="1877" height="211" key="GridCell.Tab.0.right" timestamp="1594752102676">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748168001" />
<state width="1877" height="197" key="GridCell.Tab.1.bottom" timestamp="1594748167920">
<state width="1877" height="211" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102676" />
<state width="1877" height="211" key="GridCell.Tab.1.bottom" timestamp="1594752102527">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748167920" />
<state width="1877" height="197" key="GridCell.Tab.1.center" timestamp="1594748167920">
<state width="1877" height="211" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102527" />
<state width="1877" height="211" key="GridCell.Tab.1.center" timestamp="1594752102527">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748167920" />
<state width="1877" height="197" key="GridCell.Tab.1.left" timestamp="1594748167919">
<state width="1877" height="211" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102527" />
<state width="1877" height="211" key="GridCell.Tab.1.left" timestamp="1594752102527">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748167919" />
<state width="1877" height="197" key="GridCell.Tab.1.right" timestamp="1594748167920">
<state width="1877" height="211" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102527" />
<state width="1877" height="211" key="GridCell.Tab.1.right" timestamp="1594752102527">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594748167920" />
<state width="1877" height="211" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594752102527" />
<state x="461" y="162" key="SettingsEditor" timestamp="1588876397734">
<screen x="0" y="0" width="1920" height="1040" />
</state>
@ -266,14 +255,18 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="656" y="343" key="com.intellij.ide.util.TipDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1590119557040" />
<state x="-876" y="0" width="883" height="1047" key="dock-window-1" timestamp="1594704170924">
<state x="607" y="135" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser" timestamp="1594751055964">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="607" y="135" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594751055964" />
<state x="568" y="283" width="1348" height="1027" key="dock-window-1" timestamp="1594751513464">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="568" y="283" width="1348" height="1027" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594751513464" />
<state x="-941" y="0" width="948" height="1047" key="dock-window-2" timestamp="1594749231953">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="-876" y="0" width="883" height="1047" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594704170924" />
<state x="-941" y="0" width="948" height="1047" key="dock-window-2" timestamp="1594707356239">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="-941" y="0" width="948" height="1047" key="dock-window-2/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594707356239" />
<state x="-941" y="0" width="948" height="1047" key="dock-window-2/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594749231953" />
<state x="656" y="252" width="607" height="536" key="find.popup" timestamp="1594704998390">
<screen x="0" y="0" width="1920" height="1040" />
</state>

View File

@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
/* @CHANGELOG (1.7-SNAPSHOT):
* Update to Minecraft 1.16.1.
* This jar file will also work with Minecraft 1.15.2, and 1.16.1.
* Foxes now sleep with their owner once again.
*/
public final class TamableFoxes extends JavaPlugin implements Listener {
private static TamableFoxes plugin;

View File

@ -24,12 +24,14 @@ public class EntityTamableFox extends EntityFox {
protected static final DataWatcherObject<Byte> tamed;
protected static final DataWatcherObject<Optional<UUID>> ownerUUID;
private static final DataWatcherObject<Byte> bx;
private static final Predicate<Entity> bD;
static {
tamed = DataWatcher.a(EntityTamableFox.class, DataWatcherRegistry.a);
ownerUUID = DataWatcher.a(EntityTamableFox.class, DataWatcherRegistry.o);
bx = DataWatcher.a(EntityFox.class, DataWatcherRegistry.a);
bD = (entity) -> !entity.bm() && IEntitySelector.e.test(entity);
}
@ -43,51 +45,9 @@ public class EntityTamableFox extends EntityFox {
@Override
public void initPathfinder() {
try {
this.goalSelector.a(0, getFoxInnerPathfinderGoal("g")); // FloatGoal
this.goalSit = new FoxPathfinderGoalSit(this);
this.goalSelector.a(1, goalSit);
this.goalSelector.a(2, getFoxInnerPathfinderGoal("b")); // FaceplantGoal
this.goalSelector.a(3, new FoxPathfinderGoalPanic(this, 2.2D)); // PanicGoal
this.goalSelector.a(4, getFoxInnerPathfinderGoal("e", Arrays.asList(1.0D), Arrays.asList(double.class))); // BreedGoal
// Avoid human only if not tamed
this.goalSelector.a(5, new PathfinderGoalAvoidTarget(this, EntityHuman.class, 16.0F, 1.6D, 1.4D, (entityliving) -> {
return !isTamed() && bD.test((EntityLiving) entityliving);
}));
// Avoid wolf if it is not tamed
this.goalSelector.a(5, new PathfinderGoalAvoidTarget(this, EntityWolf.class, 8.0F, 1.6D, 1.4D, (entityliving) -> {
try {
Method eFMethod = EntityFox.class.getDeclaredMethod("eF");
eFMethod.setAccessible(true);
boolean eF = (boolean) eFMethod.invoke(this);
eFMethod.setAccessible(false);
return !((EntityWolf) entityliving).isTamed() && !eF;
} catch (Exception e) {
return !((EntityWolf) entityliving).isTamed();
}
}));
this.goalSelector.a(8, new FoxPathfinderGoalMeleeAttack(this, 1.2000000476837158D, true));
this.goalSelector.a(9, new FoxPathfinderGoalFollowOwner(this, 1.3D, 10.0F, 2.0F, false));
this.goalSelector.a(6, getFoxInnerPathfinderGoal("u")); // StalkPrey
this.goalSelector.a(7, new o()); // Pounce
this.goalSelector.a(9, getFoxInnerPathfinderGoal("h", Arrays.asList(this, 1.25D), Arrays.asList(EntityFox.class, double.class))); // FollowParent
this.goalSelector.a(11, new PathfinderGoalLeapAtTarget(this, 0.4F));
this.goalSelector.a(12, new PathfinderGoalRandomStrollLand(this, 1.15D));
this.goalSelector.a(12, getFoxInnerPathfinderGoal("p")); // SearchForItems
this.goalSelector.a(13, getFoxInnerPathfinderGoal("j", Arrays.asList(this, EntityHuman.class, 24.0f), Arrays.asList(EntityInsentient.class, Class.class, float.class))); // LookAtPlayer
this.targetSelector.a(1, new FoxPathfinderGoalOwnerHurtByTarget(this));
this.targetSelector.a(2, new FoxPathfinderGoalOwnerHurtTarget(this));
this.targetSelector.a(3, (new FoxPathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0]));
// Wild animal attacking
Field bE = this.getClass().getSuperclass().getDeclaredField("bE");
bE.setAccessible(true);
@ -107,29 +67,56 @@ public class EntityTamableFox extends EntityFox {
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && entityliving instanceof EntityFishSchool;
}));
this.goalSelector.a(0, getFoxInnerPathfinderGoal("g")); // FoxFloatGoal
this.goalSelector.a(1, getFoxInnerPathfinderGoal("b")); // FaceplantGoal
this.goalSelector.a(2, new FoxPathfinderGoalPanic(this, 2.2D));
this.goalSelector.a(3, getFoxInnerPathfinderGoal("e", Arrays.asList(1.0D), Arrays.asList(double.class))); // FoxBreedGoal
this.goalSelector.a(4, new PathfinderGoalAvoidTarget(this, EntityHuman.class, 16.0F, 1.6D, 1.4D, (entityliving) -> {
return !isTamed() && bD.test((EntityLiving) entityliving) && !this.isDefending();
}));
this.goalSelector.a(4, new PathfinderGoalAvoidTarget(this, EntityWolf.class, 8.0F, 1.6D, 1.4D, (entityliving) -> {
return !((net.minecraft.server.v1_16_R1.EntityWolf)entityliving).isTamed() && !this.isDefending();
}));
this.goalSelector.a(5, getFoxInnerPathfinderGoal("u")); // StalkPreyGoal
this.goalSelector.a(6, getFoxInnerPathfinderGoal("o")); // FoxPounceGoal
this.goalSelector.a(7, getFoxInnerPathfinderGoal("l", Arrays.asList(1.2000000476837158D, true), Arrays.asList(double.class, boolean.class))); // FoxMeleeAttackGoal
this.goalSelector.a(8, getFoxInnerPathfinderGoal("h", Arrays.asList(this, 1.25D), Arrays.asList(EntityFox.class, double.class))); // FoxFollowParentGoal
this.goalSelector.a(8, new FoxPathfinderGoalSleepWithOwner(this));
this.goalSelector.a(9, new FoxPathfinderGoalFollowOwner(this, 1.3D, 10.0F, 2.0F, false));
this.goalSelector.a(10, new PathfinderGoalLeapAtTarget(this, 0.4F));
this.goalSelector.a(11, new PathfinderGoalRandomStrollLand(this, 1.0D));
this.goalSelector.a(11, getFoxInnerPathfinderGoal("p")); // FoxSearchForItemsGoal
this.goalSelector.a(12, getFoxInnerPathfinderGoal("j", Arrays.asList(this, EntityHuman.class, 24.0F), Arrays.asList(EntityInsentient.class, Class.class, float.class))); // FoxLookAtPlayerGoal
this.targetSelector.a(1, new FoxPathfinderGoalOwnerHurtByTarget(this));
this.targetSelector.a(2, new FoxPathfinderGoalOwnerHurtTarget(this));
this.targetSelector.a(3, (new FoxPathfinderGoalHurtByTarget(this)).a(new Class[0]));
untamedGoals = new ArrayList<>();
// Sleep
PathfinderGoal sleep = getFoxInnerPathfinderGoal("t");
this.goalSelector.a(8, sleep);
this.goalSelector.a(7, sleep);
untamedGoals.add(sleep);
// PerchAndSearch (Random sitting?)
PathfinderGoal perchAndSearch = getFoxInnerPathfinderGoal("r");
this.goalSelector.a(14, perchAndSearch);
this.goalSelector.a(13, perchAndSearch);
untamedGoals.add(perchAndSearch);
// EatBerries (Pick berry bushes)
PathfinderGoal eatBerries = new f(1.2000000476837158D, 12, 2);
this.goalSelector.a(11, eatBerries);
this.goalSelector.a(10, eatBerries);
untamedGoals.add(eatBerries); // Maybe this should be configurable too?
PathfinderGoal seekShelter = getFoxInnerPathfinderGoal("s", Arrays.asList(1.25D), Arrays.asList(double.class));
this.goalSelector.a(7, seekShelter); // SeekShelter
this.goalSelector.a(6, seekShelter); // SeekShelter
untamedGoals.add(seekShelter);
PathfinderGoal strollThroughVillage = getFoxInnerPathfinderGoal("q", Arrays.asList(32, 200), Arrays.asList(int.class, int.class));
this.goalSelector.a(10, strollThroughVillage); // StrollThroughVillage
this.goalSelector.a(9, strollThroughVillage); // StrollThroughVillage
untamedGoals.add(strollThroughVillage);
} catch (Exception e) {
@ -161,6 +148,16 @@ public class EntityTamableFox extends EntityFox {
}
}
// deobf: getFlag
private boolean t(int i) {
return ((Byte)this.datawatcher.get(bx) & i) != 0;
}
// deobf: 'isDefending' from 'eF'
public boolean isDefending() {
return this.t(128);
}
public static Object getPrivateField(String fieldName, Class clazz, Object object) {
Field field;
Object o = null;

View File

@ -1,37 +0,0 @@
package net.seanomik.tamablefoxes.versions.version_1_15_R1.pathfinding;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoalMeleeAttack;
import net.minecraft.server.v1_15_R1.SoundEffects;
import net.seanomik.tamablefoxes.versions.version_1_15_R1.EntityTamableFox;
public class FoxPathfinderGoalMeleeAttack extends PathfinderGoalMeleeAttack {
EntityTamableFox tamableFox;
EntityLiving enemy;
public FoxPathfinderGoalMeleeAttack(EntityTamableFox tamableFox, double d0, boolean flag) {
super(tamableFox, d0, flag);
this.tamableFox = tamableFox;
}
protected void a(EntityLiving entityliving, double d0) {
double d1 = this.a(entityliving);
this.enemy = entityliving;
if (d0 <= d1 && this.b <= 0) {
this.b = 20;
this.a.B(entityliving);
tamableFox.a(SoundEffects.ENTITY_FOX_BITE, 1.0F, 1.0F);
}
}
public void c() {
tamableFox.u(false);
super.c();
}
public boolean a() {
return !tamableFox.isSitting() && !tamableFox.isSleeping() && !tamableFox.isCrouching() && !tamableFox.es() && super.a();
}
}

View File

@ -15,16 +15,6 @@ public class FoxPathfinderGoalPanic extends PathfinderGoalPanic {
}
public boolean a() {
try {
Method isDefendingMethod = EntityFox.class.getDeclaredMethod("eF");
isDefendingMethod.setAccessible(true);
boolean isDefending = (boolean) isDefendingMethod.invoke(tamableFox);
isDefendingMethod.setAccessible(false);
return !tamableFox.isTamed() && !isDefending && super.a();
} catch (Exception e) {
e.printStackTrace();
}
return false;
return !tamableFox.isTamed() && !tamableFox.isDefending() && super.a();
}
}

View File

@ -0,0 +1,130 @@
package net.seanomik.tamablefoxes.versions.version_1_15_R1.pathfinding;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.versions.version_1_15_R1.EntityTamableFox;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
public class FoxPathfinderGoalSleepWithOwner extends PathfinderGoal {
private final EntityTamableFox a;
private EntityHuman b;
private BlockPosition c;
private int d;
public FoxPathfinderGoalSleepWithOwner(EntityTamableFox tamableFox) {
this.a = tamableFox;
}
public boolean a() {
if (!this.a.isTamed()) {
return false;
} else if (this.a.isSitting()) { // this.a.isWillSit()
return false;
} else {
EntityLiving entityliving = this.a.getOwner();
if (entityliving instanceof EntityHuman) {
this.b = (EntityHuman)entityliving;
if (!entityliving.isSleeping()) {
return false;
}
if (this.a.h(this.b) > 100.0D) {
return false;
}
BlockPosition blockposition = new BlockPosition(this.b);
IBlockData iblockdata = this.a.world.getType(blockposition);
if (iblockdata.getBlock().a(TagsBlock.BEDS)) {
EnumDirection enumdirection = (EnumDirection)iblockdata.get(BlockBed.FACING);
this.c = new BlockPosition(blockposition.getX() - enumdirection.getAdjacentX(), blockposition.getY(), blockposition.getZ() - enumdirection.getAdjacentZ());
return !this.g();
}
}
return false;
}
}
private boolean g() {
List<EntityTamableFox> list = this.a.world.a(EntityTamableFox.class, (new AxisAlignedBB(this.c)).g(2.0D));
Iterator iterator = list.iterator();
EntityTamableFox entityTamableFox;
do {
do {
if (!iterator.hasNext()) {
return false;
}
entityTamableFox = (EntityTamableFox) iterator.next();
} while(entityTamableFox == this.a);
} while(!entityTamableFox.isSleeping()); // !entityTamableFox.eY()
return true;
}
public boolean b() {
//!this.a.isWillSit()
return this.a.isTamed() && !this.a.isSitting() && this.b != null && this.b.isSleeping() && this.c != null && !this.g();
}
public void c() {
if (this.c != null) {
this.a.setSitting(false);
this.a.getNavigation().a((double)this.c.getX(), (double)this.c.getY(), (double)this.c.getZ(), 1.100000023841858D);
}
}
public void d() {
this.a.setSleeping(false);
float f = this.a.world.f(1.0F);
if (this.b.ef() >= 100 && (double)f > 0.77D && (double)f < 0.8D && (double)this.a.world.getRandom().nextFloat() < 0.7D) {
this.h();
}
this.d = 0;
//this.a.v(false); // setRelaxStateOne
this.a.getNavigation().o();
}
private void h() {
Random random = this.a.getRandom();
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
blockposition_mutableblockposition.g(this.a.getChunkCoordinates());
this.a.a((double)(blockposition_mutableblockposition.getX() + random.nextInt(11) - 5), (double)(blockposition_mutableblockposition.getY() + random.nextInt(5) - 2), (double)(blockposition_mutableblockposition.getZ() + random.nextInt(11) - 5), false);
blockposition_mutableblockposition.g(this.a.getChunkCoordinates());
LootTable loottable = this.a.world.getMinecraftServer().getLootTableRegistry().getLootTable(LootTables.ak);
LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer)this.a.world)).set(LootContextParameters.POSITION, blockposition_mutableblockposition).set(LootContextParameters.THIS_ENTITY, this.a).a(random);
List<ItemStack> list = loottable.populateLoot(loottableinfo_builder.build(LootContextParameterSets.GIFT));
Iterator iterator = list.iterator();
while(iterator.hasNext()) {
ItemStack itemstack = (ItemStack)iterator.next();
this.a.world.addEntity(new EntityItem(this.a.world, (double)blockposition_mutableblockposition.getX() - (double)MathHelper.sin(this.a.aH * 0.017453292F), (double)blockposition_mutableblockposition.getY(), (double)blockposition_mutableblockposition.getZ() + (double)MathHelper.cos(this.a.aH * 0.017453292F), itemstack));
}
}
public void e() {
if (this.b != null && this.c != null) {
this.a.setSitting(false);
this.a.getNavigation().a((double)this.c.getX(), (double)this.c.getY(), (double)this.c.getZ(), 1.100000023841858D);
if (this.a.h(this.b) < 2.5D) {
++this.d;
if (this.d > 16) {
this.a.setSleeping(true);
//this.a.y(false); // setRelaxStateOne
} else {
this.a.a(this.b, 45.0F, 45.0F);
//this.a.y(true); // setRelaxStateOne
}
} else {
this.a.setSleeping(false);
//this.a.x(false);
}
}
}
}

View File

@ -69,11 +69,11 @@ public class EntityTamableFox extends EntityFox {
this.goalSelector.a(0, getFoxInnerPathfinderGoal("g")); // FoxFloatGoal
this.goalSelector.a(1, getFoxInnerPathfinderGoal("b")); // FaceplantGoal
this.goalSelector.a(2, new FoxPathfinderGoalPanic(this, 2.2D)); // FoxPanicGoal
this.goalSelector.a(2, new FoxPathfinderGoalPanic(this, 2.2D));
this.goalSelector.a(3, getFoxInnerPathfinderGoal("e", Arrays.asList(1.0D), Arrays.asList(double.class))); // FoxBreedGoal
this.goalSelector.a(4, new PathfinderGoalAvoidTarget(this, EntityHuman.class, 16.0F, 1.6D, 1.4D, (entityliving) -> {
return !isTamed() && bC.test((EntityLiving) entityliving);
return !isTamed() && bC.test((EntityLiving) entityliving) && !this.isDefending();
}));
this.goalSelector.a(4, new PathfinderGoalAvoidTarget(this, EntityWolf.class, 8.0F, 1.6D, 1.4D, (entityliving) -> {
return !((EntityWolf)entityliving).isTamed() && !this.isDefending();
@ -94,8 +94,6 @@ public class EntityTamableFox extends EntityFox {
this.goalSelector.a(12, getFoxInnerPathfinderGoal("j", Arrays.asList(this, EntityHuman.class, 24.0f),
Arrays.asList(EntityInsentient.class, Class.class, float.class))); // LookAtPlayer
//this.goalSelector.a(10, new EntityFox.f(1.2000000476837158D, 12, 2));
this.targetSelector.a(1, new FoxPathfinderGoalOwnerHurtByTarget(this));
this.targetSelector.a(2, new FoxPathfinderGoalOwnerHurtTarget(this));
this.targetSelector.a(3, (new FoxPathfinderGoalHurtByTarget(this)).a(new Class[0]));

View File

@ -63,7 +63,7 @@ public class FoxPathfinderGoalSleepWithOwner extends PathfinderGoal {
entityTamableFox = (EntityTamableFox) iterator.next();
} while(entityTamableFox == this.a);
} while(!entityTamableFox.eX() && true); // !entityTamableFox.eY()
} while(!entityTamableFox.isSleeping()); // !entityTamableFox.eY()
return true;
}

View File

@ -8,7 +8,6 @@ net\seanomik\tamablefoxes\CommandSpawnTamableFox.class
net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalHurtByTarget.class
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.class
net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalPanic.class
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalMeleeAttack.class
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalFollowOwner.class
net\seanomik\tamablefoxes\io\LanguageConfig.class
net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.class
@ -21,5 +20,6 @@ net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoal
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalPanic.class
net\seanomik\tamablefoxes\versions\version_1_15_R1\NMSInterface_1_15_R1.class
net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalSleepWithOwner.class
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalSleepWithOwner.class
net\seanomik\tamablefoxes\Utils.class
net\seanomik\tamablefoxes\io\Config.class

View File

@ -1,6 +1,5 @@
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalHurtByTarget.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalPanic.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalMeleeAttack.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\EntityTamableFox.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\Utils.java
@ -17,7 +16,9 @@ D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tam
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalSit.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalFollowOwner.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalSit.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalSleepWithOwner.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\LanguageConfig.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\NMSInterface_1_15_R1.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\CommandSpawnTamableFox.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalSleepWithOwner.java