Do some more fixes, and add 1.14 in the single jar which fix 1.14 errors
This commit is contained in:
parent
1b3c38a64e
commit
e43cd97847
|
@ -4,14 +4,15 @@
|
|||
<list default="true" id="dcab9632-7b1a-44d7-9283-be9b37640afc" name="Default Changelist" comment="">
|
||||
<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/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/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-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" />
|
||||
|
@ -52,7 +53,7 @@
|
|||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="WebServerToolWindowFactoryState" value="true" />
|
||||
<property name="aspect.path.notification.shown" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions" />
|
||||
<property name="node.js.detected.package.eslint" value="true" />
|
||||
<property name="node.js.detected.package.tslint" value="true" />
|
||||
<property name="node.js.path.for.package.eslint" value="project" />
|
||||
|
@ -78,12 +79,20 @@
|
|||
<recent name="net.seanomik.tamablefoxes.versions.version_1_16" />
|
||||
</key>
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions" />
|
||||
<recent name="D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1" />
|
||||
<recent name="D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\io" />
|
||||
<recent name="E:\TamableFoxesCustomEntity\src\main\resources" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="JAR Application.Spigot-1.15.2">
|
||||
<component name="RunManager" selected="JAR Application.Spigot-1.16.1">
|
||||
<configuration name="Spigot-1.14.4" type="JarApplication">
|
||||
<option name="JAR_PATH" value="$PROJECT_DIR$/../../_TEST_SERVER_1.14.4_/spigot-1.14.4.jar" />
|
||||
<option name="PROGRAM_PARAMETERS" value="nogui" />
|
||||
<option name="WORKING_DIRECTORY" value="D:\Code\java\spigotPlugins\_TEST_SERVER_1.14.4_" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<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" />
|
||||
|
@ -132,6 +141,7 @@
|
|||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="JAR Application.Spigot-1.15.2" />
|
||||
<item itemvalue="JAR Application.Spigot-1.14.4" />
|
||||
<item itemvalue="JAR Application.Spigot-1.16.1" />
|
||||
<item itemvalue="Maven.TamableFoxesCustomEntity build" />
|
||||
</list>
|
||||
|
@ -195,10 +205,10 @@
|
|||
<option name="LAST_COMMIT_MESSAGE" value="New way of implementing foxes" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1594704621064">
|
||||
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1594757119591">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594704621064" />
|
||||
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594757119591" />
|
||||
<state x="765" y="229" key="#com.intellij.ide.util.MemberChooser" timestamp="1594703907165">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
|
@ -215,38 +225,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="211" key="GridCell.Tab.0.bottom" timestamp="1594752102677">
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.bottom" timestamp="1594762175885">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175885" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.center" timestamp="1594762175885">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175885" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.left" timestamp="1594762175885">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175885" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.right" timestamp="1594762175885">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175885" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.bottom" timestamp="1594762175796">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175796" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.center" timestamp="1594762175796">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175796" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.left" timestamp="1594762175795">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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">
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175795" />
|
||||
<state width="1877" height="211" key="GridCell.Tab.1.right" timestamp="1594762175796">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<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 width="1877" height="211" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594762175796" />
|
||||
<state x="461" y="162" key="SettingsEditor" timestamp="1588876397734">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
|
@ -263,10 +273,10 @@
|
|||
<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">
|
||||
<state x="-1332" y="0" width="1348" height="788" key="dock-window-2" timestamp="1594756513862">
|
||||
<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="1594749231953" />
|
||||
<state x="-1332" y="0" width="1348" height="788" key="dock-window-2/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1594756513862" />
|
||||
<state x="656" y="252" width="607" height="536" key="find.popup" timestamp="1594704998390">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -39,8 +39,9 @@
|
|||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.1_\plugins\TamableFoxes-MC-v1.15.X-v1.16.X-v${project.version}.jar</outputFile>
|
||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar</outputFile>-->
|
||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.14.4_\plugins\TamableFoxes-MC-v1.14.X-v1.16.X_v${project.version}.jar</outputFile>-->
|
||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\TamableFoxes-MC-v1.14.X-v1.16.X_v${project.version}.jar</outputFile>-->
|
||||
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.1_\plugins\TamableFoxes-MC-v1.14.X-v1.16.X_v${project.version}.jar</outputFile>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.seanomik.tamablefoxes;
|
||||
|
||||
import net.seanomik.tamablefoxes.versions.NMSInterface;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.NMSInterface_1_14_R1;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_15_R1.NMSInterface_1_15_R1;
|
||||
import net.seanomik.tamablefoxes.io.LanguageConfig;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_16_R1.NMSInterface_1_16_R1;
|
||||
|
@ -12,7 +13,8 @@ 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.
|
||||
* This jar file will also work with Minecraft 1.14.X, 1.15.X, and 1.16.X.
|
||||
* Due to merging 1.14 support with all other versions, I also fixed SEVERAL issues that the versions for 1.14 had.
|
||||
* Foxes now sleep with their owner once again.
|
||||
*/
|
||||
public final class TamableFoxes extends JavaPlugin implements Listener {
|
||||
|
@ -29,7 +31,9 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
|
|||
LanguageConfig.getConfig().saveDefault();
|
||||
|
||||
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
if (version.equals("v1_15_R1")) {
|
||||
if (version.equals("v1_14_R1")) {
|
||||
nmsInterface = new NMSInterface_1_14_R1();
|
||||
} else if (version.equals("v1_15_R1")) {
|
||||
nmsInterface = new NMSInterface_1_15_R1();
|
||||
} else if (version.equals("v1_16_R1")) {
|
||||
nmsInterface = new NMSInterface_1_16_R1();
|
||||
|
|
|
@ -0,0 +1,513 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import net.seanomik.tamablefoxes.TamableFoxes;
|
||||
import net.seanomik.tamablefoxes.Utils;
|
||||
import net.seanomik.tamablefoxes.io.Config;
|
||||
import net.seanomik.tamablefoxes.io.LanguageConfig;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding.*;
|
||||
import net.wesjd.anvilgui.AnvilGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.libs.jline.internal.Nullable;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
List<PathfinderGoal> untamedGoals;
|
||||
private FoxPathfinderGoalSit goalSit;
|
||||
|
||||
public EntityTamableFox(EntityTypes<? extends EntityFox> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPathfinder() {
|
||||
try {
|
||||
this.goalSit = new FoxPathfinderGoalSit(this);
|
||||
this.goalSelector.a(1, goalSit);
|
||||
|
||||
// Wild animal attacking
|
||||
Field landTargetGoal = this.getClass().getSuperclass().getDeclaredField("bH");
|
||||
landTargetGoal.setAccessible(true);
|
||||
landTargetGoal.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityAnimal.class, 10, false, false, (entityliving) -> {
|
||||
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && (entityliving instanceof EntityChicken || entityliving instanceof EntityRabbit);
|
||||
}));
|
||||
landTargetGoal.setAccessible(false);
|
||||
|
||||
Field turtleEggTargetGoal = this.getClass().getSuperclass().getDeclaredField("bI");
|
||||
turtleEggTargetGoal.setAccessible(true);
|
||||
turtleEggTargetGoal.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityTurtle.class, 10, false, false, (entityLiving) -> {
|
||||
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && EntityTurtle.bz.test((EntityLiving) entityLiving);
|
||||
}));
|
||||
turtleEggTargetGoal.setAccessible(false);
|
||||
|
||||
Field fishTargetGoal = this.getClass().getSuperclass().getDeclaredField("bJ");
|
||||
fishTargetGoal.setAccessible(true);
|
||||
fishTargetGoal.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityFish.class, 20, false, false, (entityliving) -> {
|
||||
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && entityliving instanceof EntityFishSchool;
|
||||
}));
|
||||
fishTargetGoal.setAccessible(false);
|
||||
|
||||
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() && !((EntityLiving) entityliving).isSneaking() && IEntitySelector.e.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.0D, 10.0F, 2.0F));
|
||||
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(7, sleep);
|
||||
untamedGoals.add(sleep);
|
||||
|
||||
// PerchAndSearch (Random sitting?)
|
||||
PathfinderGoal perchAndSearch = getFoxInnerPathfinderGoal("r");
|
||||
this.goalSelector.a(13, perchAndSearch);
|
||||
untamedGoals.add(perchAndSearch);
|
||||
|
||||
// EatBerries (Pick berry bushes)
|
||||
PathfinderGoal eatBerries = new f(1.2000000476837158D, 12, 2);
|
||||
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(6, seekShelter); // SeekShelter
|
||||
untamedGoals.add(seekShelter);
|
||||
|
||||
PathfinderGoal strollThroughVillage = getFoxInnerPathfinderGoal("q", Arrays.asList(32, 200), Arrays.asList(int.class, int.class));
|
||||
this.goalSelector.a(9, strollThroughVillage); // StrollThroughVillage
|
||||
untamedGoals.add(strollThroughVillage);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initAttributes() {
|
||||
super.initAttributes();
|
||||
|
||||
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.33000001192092896D);
|
||||
if (!isTamed()) {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
||||
} else {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(24.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
try {
|
||||
field = clazz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
o = field.get(object);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
protected void initDatawatcher() {
|
||||
super.initDatawatcher();
|
||||
this.datawatcher.register(tamed, (byte) 0);
|
||||
this.datawatcher.register(ownerUUID, Optional.empty());
|
||||
}
|
||||
|
||||
// addAdditionalSaveData
|
||||
public void b(NBTTagCompound compound) {
|
||||
super.b(compound);
|
||||
if (this.getOwnerUUID() == null) {
|
||||
compound.setString("OwnerUUID", "");
|
||||
} else {
|
||||
compound.setString("OwnerUUID", this.getOwnerUUID().toString());
|
||||
}
|
||||
|
||||
compound.setBoolean("Sitting", this.isSitting());
|
||||
}
|
||||
|
||||
// readAdditionalSaveData
|
||||
public void a(NBTTagCompound compound) {
|
||||
super.a(compound);
|
||||
String ownerUuid;
|
||||
|
||||
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 {
|
||||
this.setOwnerUUID(UUID.fromString(ownerUuid));
|
||||
this.setTamed(true);
|
||||
} catch (Throwable throwable) {
|
||||
this.setTamed(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.goalSit != null) {
|
||||
this.goalSit.setSitting(compound.getBoolean("Sitting"));
|
||||
}
|
||||
|
||||
this.setSitting(compound.getBoolean("Sitting"));
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return ((Byte) this.datawatcher.get(tamed) & 4) != 0;
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed_) {
|
||||
byte isTamed = this.datawatcher.get(tamed);
|
||||
if (tamed_) {
|
||||
this.datawatcher.set(tamed, (byte) (isTamed | 4));
|
||||
} else {
|
||||
this.datawatcher.set(tamed, (byte) (isTamed & -5));
|
||||
}
|
||||
this.reassessTameGoals();
|
||||
|
||||
if (tamed_) {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(24.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D);
|
||||
this.setHealth(this.getMaxHealth());
|
||||
} else {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove untamed goals if its tamed.
|
||||
private void reassessTameGoals() {
|
||||
if (!isTamed()) return;
|
||||
|
||||
for (PathfinderGoal untamedGoal : untamedGoals) {
|
||||
this.goalSelector.a(untamedGoal);
|
||||
}
|
||||
}
|
||||
|
||||
// deobf: mobInteract
|
||||
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
return super.a(entityhuman, enumhand);
|
||||
} else {
|
||||
if (this.isTamed()) {
|
||||
|
||||
// Heal the fox if its health is below the max.
|
||||
if (item.isFood() && item.getFoodInfo().c() && this.getHealth() < this.getMaxHealth()) {
|
||||
// Only remove the item from the player if they're in survival mode.
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
this.heal((float)item.getFoodInfo().getNutrition(), EntityRegainHealthEvent.RegainReason.EATING);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isOwnedBy(entityhuman)) {
|
||||
// This super method checks if the fox can breed or not.
|
||||
boolean flag = super.a(entityhuman, enumhand);
|
||||
|
||||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
if (!entityhuman.isSneaking() && (!flag || this.isBaby())) {
|
||||
this.goalSit.setSitting(!this.isSitting());
|
||||
return flag;
|
||||
} else if (entityhuman.isSneaking()) { // Swap/Put/Take item from fox.
|
||||
// Ignore buckets since they can be easily duplicated.
|
||||
if (itemstack.getItem() == Items.BUCKET || itemstack.getItem() == Items.LAVA_BUCKET || itemstack.getItem() == Items.WATER_BUCKET) return true;
|
||||
|
||||
if (!this.getEquipment(EnumItemSlot.MAINHAND).isEmpty()) {
|
||||
getBukkitEntity().getWorld().dropItem(getBukkitEntity().getLocation(), CraftItemStack.asBukkitCopy(this.getEquipment(EnumItemSlot.MAINHAND)));
|
||||
this.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.AIR));
|
||||
}
|
||||
|
||||
// Run this task async to make sure to not slow the server down.
|
||||
// This is needed due to the item being remove as soon as its put in the foxes mouth.
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(TamableFoxes.getPlugin(), ()-> {
|
||||
// Put item in mouth
|
||||
if (item != Items.AIR) {
|
||||
ItemStack c = itemstack.cloneItemStack();
|
||||
c.setCount(1);
|
||||
|
||||
// Only remove the item from the player if they're in survival mode.
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
this.setSlot(EnumItemSlot.MAINHAND, c);
|
||||
}
|
||||
}, (long) 0.1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (item == Items.CHICKEN) {
|
||||
// Check if the player has permissions to tame the fox
|
||||
if (Config.canPlayerTameFox((Player) entityhuman.getBukkitEntity())) {
|
||||
// Only remove the item from the player if they're in survival mode.
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
// 0.33% chance to tame the fox, also check if the called tame entity event is cancelled or not.
|
||||
if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
||||
this.tame(entityhuman);
|
||||
|
||||
// Remove all navigation when tamed.
|
||||
this.navigation.o();
|
||||
this.setGoalTarget(null);
|
||||
this.goalSit.setSitting(true);
|
||||
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.HEART, getBukkitEntity().getLocation(), 6, 0.5D, 0.5D, 0.5D);
|
||||
|
||||
// Give player tamed message.
|
||||
((Player) entityhuman.getBukkitEntity()).sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamedMessage());
|
||||
|
||||
// Let the player choose the new fox's name if its enabled in config.
|
||||
if (Config.askForNameAfterTaming()) {
|
||||
Player player = (Player) entityhuman.getBukkitEntity();
|
||||
|
||||
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getTamingAskingName());
|
||||
new AnvilGUI.Builder()
|
||||
.onComplete((plr, input) -> { // Called when the inventory output slot is clicked
|
||||
if (!input.equals("")) {
|
||||
org.bukkit.entity.Entity tamableFox = this.getBukkitEntity();
|
||||
|
||||
// This will auto format the name for config settings.
|
||||
String foxName = LanguageConfig.getFoxNameFormat(input, player.getDisplayName());
|
||||
|
||||
tamableFox.setCustomName(foxName);
|
||||
tamableFox.setCustomNameVisible(true);
|
||||
plr.sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(TamableFoxes.getPlugin()) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.a(entityhuman, enumhand);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTamableFox createChild(EntityAgeable entityageable) {
|
||||
EntityTamableFox entityFox = (EntityTamableFox) EntityTypes.FOX.a(this.world);
|
||||
entityFox.setFoxType(this.getFoxType());
|
||||
|
||||
UUID uuid = this.getOwnerUUID();
|
||||
if (uuid != null) {
|
||||
entityFox.setOwnerUUID(uuid);
|
||||
entityFox.setTamed(true);
|
||||
}
|
||||
|
||||
return entityFox;
|
||||
}
|
||||
|
||||
public boolean mate(EntityAnimal entityanimal) {
|
||||
if (entityanimal == this) {
|
||||
return false;
|
||||
} else if (!(entityanimal instanceof EntityTamableFox)) {
|
||||
return false;
|
||||
} else {
|
||||
EntityTamableFox entityFox = (EntityTamableFox) entityanimal;
|
||||
return (!entityFox.isSitting() && (this.isInLove() && entityFox.isInLove()));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getOwnerUUID() {
|
||||
return (UUID) ((Optional) this.datawatcher.get(ownerUUID)).orElse(null);
|
||||
}
|
||||
|
||||
public void setOwnerUUID(@Nullable UUID ownerUuid) {
|
||||
this.datawatcher.set(ownerUUID, Optional.ofNullable(ownerUuid));
|
||||
}
|
||||
|
||||
public void tame(EntityHuman owner) {
|
||||
this.setTamed(true);
|
||||
this.setOwnerUUID(owner.getUniqueID());
|
||||
|
||||
// Give the player the taming advancement.
|
||||
if (owner instanceof EntityPlayer) {
|
||||
CriterionTriggers.x.a((EntityPlayer)owner, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityLiving getOwner() {
|
||||
try {
|
||||
UUID ownerUuid = this.getOwnerUUID();
|
||||
return ownerUuid == null ? null : this.world.b(ownerUuid);
|
||||
} catch (IllegalArgumentException var2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Only attack entity if its not attacking owner.
|
||||
public boolean c(EntityLiving entity) {
|
||||
return !this.isOwnedBy(entity) && super.c(entity);
|
||||
}
|
||||
|
||||
public boolean isOwnedBy(EntityLiving entity) {
|
||||
return entity == this.getOwner();
|
||||
}
|
||||
|
||||
/*
|
||||
deobf: wantsToAttack (Copied from EntityWolf)
|
||||
This code being from EntityWolf also means that wolves will want to attack foxes
|
||||
Our life would be so much easier if we could extend both EntityFox and EntityTameableAnimal
|
||||
*/
|
||||
public boolean a(EntityLiving entityliving, EntityLiving entityliving1) {
|
||||
if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) {
|
||||
if (entityliving instanceof EntityTamableFox) {
|
||||
EntityTamableFox entityFox = (EntityTamableFox) entityliving;
|
||||
return !entityFox.isTamed() || entityFox.getOwner() != entityliving1;
|
||||
} else {
|
||||
return (!(entityliving instanceof EntityHuman)
|
||||
|| !(entityliving1 instanceof EntityHuman) ||
|
||||
((EntityHuman) entityliving1).a((EntityHuman) entityliving)) && ((!(entityliving instanceof EntityHorseAbstract)
|
||||
|| !((EntityHorseAbstract) entityliving).isTamed()) && (!(entityliving instanceof EntityTameableAnimal)
|
||||
|| !((EntityTameableAnimal) entityliving).isTamed()));
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the scoreboard team to the same as the owner if its tamed.
|
||||
public ScoreboardTeamBase getScoreboardTeam() {
|
||||
if (this.isTamed()) {
|
||||
EntityLiving var0 = this.getOwner();
|
||||
if (var0 != null) {
|
||||
return var0.getScoreboardTeam();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getScoreboardTeam();
|
||||
}
|
||||
|
||||
// Override isAlliedTo (Entity::r(Entity))
|
||||
public boolean r(Entity entity) {
|
||||
if (this.isTamed()) {
|
||||
EntityLiving entityOwner = this.getOwner();
|
||||
if (entity == entityOwner) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entityOwner != null) {
|
||||
return entityOwner.r(entity);
|
||||
}
|
||||
}
|
||||
return super.r(entity);
|
||||
}
|
||||
|
||||
// When the fox dies, show a chat message.
|
||||
public void die(DamageSource damageSource) {
|
||||
if (!this.world.isClientSide && this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES) && this.getOwner() instanceof EntityPlayer) {
|
||||
this.getOwner().sendMessage(this.getCombatTracker().getDeathMessage());
|
||||
}
|
||||
|
||||
super.die(damageSource);
|
||||
}
|
||||
|
||||
|
||||
private PathfinderGoal getFoxInnerPathfinderGoal(String innerName, List<Object> args, List<Class<?>> argTypes) {
|
||||
return (PathfinderGoal) Utils.instantiatePrivateInnerClass(EntityFox.class, innerName, this, args, argTypes);
|
||||
}
|
||||
|
||||
private PathfinderGoal getFoxInnerPathfinderGoal(String innerName) {
|
||||
return (PathfinderGoal) Utils.instantiatePrivateInnerClass(EntityFox.class, innerName, this, Arrays.asList(), Arrays.asList());
|
||||
}
|
||||
|
||||
private void clearPathFinderGoals() {
|
||||
Set<?> goalSet = (Set<?>) getPrivateField("d", PathfinderGoalSelector.class, goalSelector);
|
||||
Set<?> targetSet = (Set<?>) getPrivateField("d", PathfinderGoalSelector.class, targetSelector);
|
||||
goalSet.clear();
|
||||
targetSet.clear();
|
||||
|
||||
Map<?, ?> goalMap = (Map<?, ?>) getPrivateField("c", PathfinderGoalSelector.class, goalSelector);
|
||||
Map<?, ?> targetMap = (Map<?, ?>) getPrivateField("c", PathfinderGoalSelector.class, targetSelector);
|
||||
goalMap.clear();
|
||||
targetMap.clear();
|
||||
|
||||
EnumSet<?> goalEnumSet = (EnumSet<?>) getPrivateField("f", PathfinderGoalSelector.class, goalSelector);
|
||||
EnumSet<?> targetEnumSet = (EnumSet<?>) getPrivateField("f", PathfinderGoalSelector.class, targetSelector);
|
||||
goalEnumSet.clear();
|
||||
targetEnumSet.clear();
|
||||
}
|
||||
|
||||
public FoxPathfinderGoalSit getGoalSit() {
|
||||
return goalSit;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.EntityFox;
|
||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||
import net.seanomik.tamablefoxes.Utils;
|
||||
import net.seanomik.tamablefoxes.io.LanguageConfig;
|
||||
import net.seanomik.tamablefoxes.versions.NMSInterface;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class NMSInterface_1_14_R1 implements NMSInterface {
|
||||
@Override
|
||||
public void registerCustomFoxEntity() {
|
||||
try { // Replace the fox entity
|
||||
Field field = EntityTypes.FOX.getClass().getDeclaredField("aZ");
|
||||
field.setAccessible(true);
|
||||
|
||||
// If the field is final, then make it non final
|
||||
if ((field.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
|
||||
Field fieldMutable = field.getClass().getDeclaredField("modifiers");
|
||||
fieldMutable.setAccessible(true);
|
||||
fieldMutable.set(field, fieldMutable.getInt(field) & ~Modifier.FINAL);
|
||||
fieldMutable.setAccessible(false);
|
||||
}
|
||||
|
||||
field.set(EntityTypes.FOX, (EntityTypes.b<EntityFox>) (type, world) -> new EntityTamableFox(type, world));
|
||||
|
||||
field.setAccessible(false);
|
||||
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||
} catch (Exception e) {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnTamableFox(Location loc, FoxType type) {
|
||||
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) loc.getWorld().spawnEntity(loc, EntityType.FOX)).getHandle();
|
||||
tamableFox.setFoxType( (type == FoxType.RED) ? EntityFox.Type.RED : EntityFox.Type.SNOW );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class FoxPathfinderGoalFollowOwner extends PathfinderGoal {
|
||||
protected final EntityTamableFox a;
|
||||
private EntityLiving c;
|
||||
protected final IWorldReader b;
|
||||
private final double d;
|
||||
private final NavigationAbstract e;
|
||||
private int f;
|
||||
private final float g;
|
||||
private final float h;
|
||||
private float i;
|
||||
|
||||
public FoxPathfinderGoalFollowOwner(EntityTamableFox tamableFox, double d0, float f, float f1) {
|
||||
this.a = tamableFox;
|
||||
this.b = tamableFox.world;
|
||||
this.d = d0;
|
||||
this.e = tamableFox.getNavigation();
|
||||
this.h = f;
|
||||
this.g = f1;
|
||||
this.a(EnumSet.of(Type.MOVE, Type.LOOK));
|
||||
if (!(tamableFox.getNavigation() instanceof Navigation) && !(tamableFox.getNavigation() instanceof NavigationFlying)) {
|
||||
throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
if (entityliving == null) {
|
||||
return false;
|
||||
} else if (entityliving instanceof EntityHuman && ((EntityHuman)entityliving).isSpectator()) {
|
||||
return false;
|
||||
} else if (this.a.isSitting()) {
|
||||
return false;
|
||||
} else if (this.a.h(entityliving) < (double)(this.h * this.h)) {
|
||||
return false;
|
||||
} else {
|
||||
this.c = entityliving;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return !this.e.n() && this.a.h(this.c) > (double)(this.g * this.g) && !this.a.isSitting();
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.f = 0;
|
||||
this.i = this.a.a(PathType.WATER);
|
||||
this.a.a(PathType.WATER, 0.0F);
|
||||
}
|
||||
|
||||
public void d() {
|
||||
this.c = null;
|
||||
this.e.o();
|
||||
this.a.a(PathType.WATER, this.i);
|
||||
}
|
||||
|
||||
public void e() {
|
||||
this.a.getControllerLook().a(this.c, 10.0F, (float)this.a.M());
|
||||
if (!this.a.isSitting() && --this.f <= 0) {
|
||||
this.f = 10;
|
||||
if (!this.e.a(this.c, this.d) && !this.a.isLeashed() && !this.a.isPassenger() && this.a.h(this.c) >= 144.0D) {
|
||||
int i = MathHelper.floor(this.c.locX) - 2;
|
||||
int j = MathHelper.floor(this.c.locZ) - 2;
|
||||
int k = MathHelper.floor(this.c.getBoundingBox().minY);
|
||||
|
||||
for(int l = 0; l <= 4; ++l) {
|
||||
for(int i1 = 0; i1 <= 4; ++i1) {
|
||||
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(new BlockPosition(i + l, k - 1, j + i1))) {
|
||||
CraftEntity entity = this.a.getBukkitEntity();
|
||||
Location to = new Location(entity.getWorld(), (double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.a.yaw, this.a.pitch);
|
||||
EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
|
||||
this.a.world.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
to = event.getTo();
|
||||
this.a.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
|
||||
this.e.o();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected boolean a(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.b.getType(blockposition);
|
||||
return iblockdata.a(this.b, blockposition, this.a.getEntityType()) && this.b.isEmpty(blockposition.up()) && this.b.isEmpty(blockposition.up(2));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class FoxPathfinderGoalHurtByTarget extends PathfinderGoalTarget {
|
||||
private static final PathfinderTargetCondition a = (new PathfinderTargetCondition()).c().e();
|
||||
private boolean b;
|
||||
private int c;
|
||||
private final Class<?>[] d;
|
||||
private Class<?>[] i;
|
||||
|
||||
public FoxPathfinderGoalHurtByTarget(EntityCreature entitycreature, Class<?>... aclass) {
|
||||
super(entitycreature, true);
|
||||
this.d = aclass;
|
||||
this.a(EnumSet.of(Type.TARGET));
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
int i = this.e.ct();
|
||||
EntityLiving entityliving = this.e.getLastDamager();
|
||||
if (i != this.c && entityliving != null) {
|
||||
Class[] aclass = this.d;
|
||||
int j = aclass.length;
|
||||
|
||||
for(int k = 0; k < j; ++k) {
|
||||
Class<?> oclass = aclass[k];
|
||||
if (oclass.isAssignableFrom(entityliving.getClass())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return this.a(entityliving, a);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public FoxPathfinderGoalHurtByTarget a(Class<?>... aclass) {
|
||||
this.b = true;
|
||||
this.i = aclass;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.e.setGoalTarget(this.e.getLastDamager(), TargetReason.TARGET_ATTACKED_ENTITY, true);
|
||||
this.g = this.e.getGoalTarget();
|
||||
this.c = this.e.ct();
|
||||
this.h = 300;
|
||||
if (this.b) {
|
||||
this.g();
|
||||
}
|
||||
|
||||
super.c();
|
||||
}
|
||||
|
||||
protected void g() {
|
||||
double d0 = this.k();
|
||||
List<EntityInsentient> list = this.e.world.b(this.e.getClass(), (new AxisAlignedBB(this.e.locX, this.e.locY, this.e.locZ, this.e.locX + 1.0D, this.e.locY + 1.0D, this.e.locZ + 1.0D)).grow(d0, 10.0D, d0));
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while(true) {
|
||||
EntityInsentient entityinsentient;
|
||||
boolean flag;
|
||||
do {
|
||||
do {
|
||||
do {
|
||||
do {
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
entityinsentient = (EntityInsentient)iterator.next();
|
||||
} while(this.e == entityinsentient);
|
||||
} while(entityinsentient.getGoalTarget() != null);
|
||||
} while(this.e instanceof EntityTameableAnimal && ((EntityTameableAnimal)this.e).getOwner() != ((EntityTameableAnimal)entityinsentient).getOwner());
|
||||
} while(entityinsentient.r(this.e.getLastDamager()));
|
||||
|
||||
if (this.i == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
flag = false;
|
||||
Class[] aclass = this.i;
|
||||
int i = aclass.length;
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
Class<?> oclass = aclass[j];
|
||||
if (entityinsentient.getClass() == oclass) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while(flag);
|
||||
|
||||
this.a(entityinsentient, this.e.getLastDamager());
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
entityinsentient.setGoalTarget(entityliving, TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
|
||||
import net.minecraft.server.v1_14_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoalTarget;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderTargetCondition;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class FoxPathfinderGoalOwnerHurtByTarget extends PathfinderGoalTarget {
|
||||
private final EntityTamableFox a;
|
||||
private EntityLiving b;
|
||||
private int c;
|
||||
|
||||
public FoxPathfinderGoalOwnerHurtByTarget(EntityTamableFox tamableFox) {
|
||||
super(tamableFox, false);
|
||||
this.a = tamableFox;
|
||||
this.a(EnumSet.of(Type.TARGET));
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
if (this.a.isTamed() && !this.a.isSitting()) {
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
if (entityliving == null) {
|
||||
return false;
|
||||
} else {
|
||||
this.b = entityliving.getLastDamager();
|
||||
int i = entityliving.ct();
|
||||
return i != this.c && this.a(this.b, PathfinderTargetCondition.a) && this.a.a(this.b, entityliving);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.e.setGoalTarget(this.b, TargetReason.TARGET_ATTACKED_OWNER, true);
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
if (entityliving != null) {
|
||||
this.c = entityliving.ct();
|
||||
}
|
||||
|
||||
super.c();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_14_R1.EntityTameableAnimal;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoalTarget;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderTargetCondition;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class FoxPathfinderGoalOwnerHurtTarget extends PathfinderGoalTarget {
|
||||
private final EntityTamableFox a;
|
||||
private EntityLiving b;
|
||||
private int c;
|
||||
|
||||
public FoxPathfinderGoalOwnerHurtTarget(EntityTamableFox tamableFox) {
|
||||
super(tamableFox, false);
|
||||
this.a = tamableFox;
|
||||
this.a(EnumSet.of(Type.TARGET));
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
if (this.a.isTamed() && !this.a.isSitting()) {
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
if (entityliving == null) {
|
||||
return false;
|
||||
} else {
|
||||
this.b = entityliving.cu();
|
||||
int i = entityliving.cv();
|
||||
return i != this.c && this.a(this.b, PathfinderTargetCondition.a) && this.a.a(this.b, entityliving);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.e.setGoalTarget(this.b, TargetReason.OWNER_ATTACKED_TARGET, true);
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
if (entityliving != null) {
|
||||
this.c = entityliving.cv();
|
||||
}
|
||||
|
||||
super.c();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.EntityFox;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoalPanic;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class FoxPathfinderGoalPanic extends PathfinderGoalPanic {
|
||||
EntityTamableFox tamableFox;
|
||||
|
||||
public FoxPathfinderGoalPanic(EntityTamableFox tamableFox, double d0) {
|
||||
super(tamableFox, d0);
|
||||
this.tamableFox = tamableFox;
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return !tamableFox.isTamed() && !tamableFox.isDefending() && super.a();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
|
||||
import net.minecraft.server.v1_14_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoal;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class FoxPathfinderGoalSit extends PathfinderGoal {
|
||||
private final EntityTamableFox entity;
|
||||
private boolean willSit;
|
||||
|
||||
public FoxPathfinderGoalSit(EntityTamableFox tamableFox) {
|
||||
this.entity = tamableFox;
|
||||
this.a(EnumSet.of(Type.JUMP, Type.MOVE));
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return this.willSit;
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
if (!this.entity.isTamed()) {
|
||||
return this.willSit && this.entity.getGoalTarget() == null;
|
||||
} else if (this.entity.av()) {
|
||||
return false;
|
||||
} else if (!this.entity.onGround) {
|
||||
return false;
|
||||
} else {
|
||||
EntityLiving entityliving = this.entity.getOwner();
|
||||
return entityliving == null || ((!(this.entity.h(entityliving) < 144.0D) || entityliving.getLastDamager() == null) && this.willSit);
|
||||
}
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.entity.getNavigation().o();
|
||||
this.entity.setSitting(true);
|
||||
}
|
||||
|
||||
public void d() {
|
||||
this.entity.setSitting(false);
|
||||
}
|
||||
|
||||
public void setSitting(boolean flag) {
|
||||
this.willSit = flag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import net.seanomik.tamablefoxes.TamableFoxes;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_14_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()) {
|
||||
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.eg()); // && !entityTamableFox.eh() <- isRelaxStateOne()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
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.getGoalSit().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.j(1.0F);
|
||||
if (this.b.dJ() >= 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.a(this.a);
|
||||
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.a(this.a);
|
||||
LootTable loottable = this.a.world.getMinecraftServer().getLootTableRegistry().getLootTable(LootTables.af);
|
||||
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)((float)blockposition_mutableblockposition.getX() - MathHelper.sin(this.a.aK * 0.017453292F)), (double)blockposition_mutableblockposition.getY(), (double)((float)blockposition_mutableblockposition.getZ() + MathHelper.cos(this.a.aK * 0.017453292F)), itemstack));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void e() {
|
||||
if (this.b != null && this.c != null) {
|
||||
this.a.getGoalSit().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.v(false); < setRelaxStateOne
|
||||
} else {
|
||||
this.a.a(this.b, 45.0F, 45.0F);
|
||||
//this.a.v(true); < setRelaxStateOne
|
||||
}
|
||||
} else {
|
||||
this.a.setSleeping(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -49,23 +49,26 @@ public class EntityTamableFox extends EntityFox {
|
|||
this.goalSelector.a(1, goalSit);
|
||||
|
||||
// Wild animal attacking
|
||||
Field bE = this.getClass().getSuperclass().getDeclaredField("bE");
|
||||
bE.setAccessible(true);
|
||||
bE.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityAnimal.class, 10, false, false, (entityliving) -> {
|
||||
Field landTargetGoal = this.getClass().getSuperclass().getDeclaredField("bE");
|
||||
landTargetGoal.setAccessible(true);
|
||||
landTargetGoal.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityAnimal.class, 10, false, false, (entityliving) -> {
|
||||
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && (entityliving instanceof EntityChicken || entityliving instanceof EntityRabbit);
|
||||
}));
|
||||
landTargetGoal.setAccessible(false);
|
||||
|
||||
Field bF = this.getClass().getSuperclass().getDeclaredField("bF");
|
||||
bF.setAccessible(true);
|
||||
bF.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityTurtle.class, 10, false, false, (entityLiving) -> {
|
||||
Field turtleEggTargetGoal = this.getClass().getSuperclass().getDeclaredField("bF");
|
||||
turtleEggTargetGoal.setAccessible(true);
|
||||
turtleEggTargetGoal.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityTurtle.class, 10, false, false, (entityLiving) -> {
|
||||
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && EntityTurtle.bw.test((EntityLiving) entityLiving);
|
||||
}));
|
||||
turtleEggTargetGoal.setAccessible(false);
|
||||
|
||||
Field bG = this.getClass().getSuperclass().getDeclaredField("bG");
|
||||
bG.setAccessible(true);
|
||||
bG.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityFish.class, 20, false, false, (entityliving) -> {
|
||||
Field fishTargetGoal = this.getClass().getSuperclass().getDeclaredField("bG");
|
||||
fishTargetGoal.setAccessible(true);
|
||||
fishTargetGoal.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityFish.class, 20, false, false, (entityliving) -> {
|
||||
return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && entityliving instanceof EntityFishSchool;
|
||||
}));
|
||||
fishTargetGoal.setAccessible(false);
|
||||
|
||||
this.goalSelector.a(0, getFoxInnerPathfinderGoal("g")); // FoxFloatGoal
|
||||
this.goalSelector.a(1, getFoxInnerPathfinderGoal("b")); // FaceplantGoal
|
||||
|
@ -126,22 +129,12 @@ public class EntityTamableFox extends EntityFox {
|
|||
|
||||
@Override
|
||||
protected void initAttributes() {
|
||||
this.getAttributeMap().b(GenericAttributes.MAX_HEALTH);
|
||||
this.getAttributeMap().b(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
this.getAttributeMap().b(GenericAttributes.MOVEMENT_SPEED);
|
||||
this.getAttributeMap().b(GenericAttributes.ARMOR);
|
||||
this.getAttributeMap().b(GenericAttributes.ARMOR_TOUGHNESS);
|
||||
|
||||
// Default value is 32, might want to make this configurable in the future
|
||||
this.getAttributeMap().b(GenericAttributes.FOLLOW_RANGE).setValue(32.0D);
|
||||
|
||||
this.getAttributeMap().b(GenericAttributes.ATTACK_KNOCKBACK);
|
||||
|
||||
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.30000001192092896D);
|
||||
super.initAttributes();
|
||||
|
||||
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.33000001192092896D);
|
||||
if (!isTamed()) {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
|
||||
this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
||||
} else {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(24.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D);
|
||||
|
|
|
@ -40,6 +40,16 @@ public class EntityTamableFox extends EntityFox {
|
|||
|
||||
public EntityTamableFox(EntityTypes<? extends EntityFox> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
|
||||
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.33000001192092896D);
|
||||
if (isTamed()) {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(24.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D);
|
||||
this.setHealth(this.getMaxHealth());
|
||||
} else {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,45 +134,11 @@ public class EntityTamableFox extends EntityFox {
|
|||
PathfinderGoal strollThroughVillage = getFoxInnerPathfinderGoal("q", Arrays.asList(32, 200), Arrays.asList(int.class, int.class));
|
||||
this.goalSelector.a(9, strollThroughVillage); // StrollThroughVillage
|
||||
untamedGoals.add(strollThroughVillage);
|
||||
|
||||
// This is DefendTrustedTargetGoal so I don't think its needed
|
||||
/*this.targetSelector.a(3, new EntityFox.a(EntityLiving.class, false, false, (entityliving) -> {
|
||||
return bA.test(entityliving) && !this.c(entityliving.getUniqueID());
|
||||
}));*/
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* I need to find out a new way to do this.
|
||||
* 1.16.1 introduced a new way that attributes are created. These methods are static methods
|
||||
* which makes it so I can't override them. Each entity also has a unique method name.
|
||||
*/
|
||||
/*protected void initAttributes() {
|
||||
this.getAttributeMap().b(GenericAttributes.MAX_HEALTH);
|
||||
this.getAttributeMap().b(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
this.getAttributeMap().b(GenericAttributes.MOVEMENT_SPEED);
|
||||
this.getAttributeMap().b(GenericAttributes.ARMOR);
|
||||
this.getAttributeMap().b(GenericAttributes.ARMOR_TOUGHNESS);
|
||||
|
||||
// Default value is 32, might want to make this configurable in the future
|
||||
this.getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);//.setValue(32.0D);
|
||||
EntityLiving.cK().a(GenericAttributes.FOLLOW_RANGE, 16.0D).
|
||||
//this.ck(GenericAttributes.FOLLOW_RANGE, 32.0D);
|
||||
|
||||
this.getAttributeMap().b(GenericAttributes.ATTACK_KNOCKBACK);
|
||||
|
||||
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.30000001192092896D);
|
||||
|
||||
if (!isTamed()) {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
|
||||
this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
||||
} else {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(24.0D);
|
||||
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D);
|
||||
}
|
||||
}*/
|
||||
|
||||
// deobf: getFlag
|
||||
private boolean t(int i) {
|
||||
return ((Byte)this.datawatcher.get(bw) & i) != 0;
|
||||
|
@ -173,19 +149,6 @@ public class EntityTamableFox extends EntityFox {
|
|||
return this.t(128);
|
||||
}
|
||||
|
||||
// deobf: setFlag
|
||||
/*public void d(int i, boolean flag) {
|
||||
if (flag) {
|
||||
this.datawatcher.set(bw, (byte)((Byte)this.datawatcher.get(bw) | i));
|
||||
} else {
|
||||
this.datawatcher.set(bw, (byte)((Byte)this.datawatcher.get(bw) & ~i));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*public void x(boolean flag) {
|
||||
this.datawatcher.set(bA, flag);
|
||||
}*/
|
||||
|
||||
public static Object getPrivateField(String fieldName, Class clazz, Object object) {
|
||||
Field field;
|
||||
Object o = null;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: Tamablefoxes
|
||||
version: ${project.version}
|
||||
main: net.seanomik.tamablefoxes.TamableFoxes
|
||||
api-version: 1.15
|
||||
api-version: 1.14
|
||||
load: STARTUP
|
||||
description: Adds tamable foxes to Minecraft!
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: Tamablefoxes
|
||||
version: 1.7-SNAPSHOT
|
||||
main: net.seanomik.tamablefoxes.TamableFoxes
|
||||
api-version: 1.15
|
||||
api-version: 1.14
|
||||
load: STARTUP
|
||||
description: Adds tamable foxes to Minecraft!
|
||||
|
||||
|
|
|
@ -7,19 +7,28 @@ net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoal
|
|||
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_14_R1\NMSInterface_1_14_R1.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalPanic.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalPanic.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
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\EntityTamableFox.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_16_R1\NMSInterface_1_16_R1.class
|
||||
net\seanomik\tamablefoxes\versions\NMSInterface$FoxType.class
|
||||
net\seanomik\tamablefoxes\TamableFoxes.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalSit.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalFollowOwner.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalSit.class
|
||||
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\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalSit.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalSleepWithOwner.class
|
||||
net\seanomik\tamablefoxes\Utils.class
|
||||
net\seanomik\tamablefoxes\io\Config.class
|
||||
net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalHurtByTarget.class
|
||||
|
|
|
@ -1,24 +1,33 @@
|
|||
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_16_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\EntityTamableFox.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
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\TamableFoxes.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalFollowOwner.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\NMSInterface_1_16_R1.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\NMSInterface.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalPanic.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\EntityTamableFox.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\Config.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalPanic.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalHurtByTarget.java
|
||||
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_14_R1\pathfinding\FoxPathfinderGoalSleepWithOwner.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.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
|
||||
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_16_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\TamableFoxes.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalHurtByTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalFollowOwner.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\NMSInterface_1_14_R1.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\Config.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_16_R1\pathfinding\FoxPathfinderGoalHurtByTarget.java
|
||||
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_14_R1\pathfinding\FoxPathfinderGoalFollowOwner.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_14_R1\pathfinding\FoxPathfinderGoalSit.java
|
||||
D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15_R1\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
|
||||
|
|
Loading…
Reference in New Issue