diff --git a/.gitignore b/.gitignore
index 79b82c9..de0e2c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,7 @@
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
+.idea
.idea/**
# User-specific stuff
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 6fb7c97..28ed9dc 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,6 +5,9 @@
+
+
+
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0f2d175..ac27c62 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,11 +1,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -14,6 +27,11 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -57,26 +83,26 @@
-
+
-
+
-
-
+
+
-
+
@@ -144,74 +170,162 @@
1579657428994
+
+
+
+ 1580168789486
+
+
+
+ 1580168789486
+
+
+ 1580233945505
+
+
+
+ 1580233945505
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+
-
-
+
+
-
+
+
+
-
-
+
+
-
+
+
+
-
-
+
+
-
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -220,11 +334,28 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -234,4 +365,25 @@
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
+ 219
+
+
+
+ file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
+ 220
+
+
+
+ file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/LanguageConfig.java
+ 110
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 94a32af..2999840 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.seanomik
tamablefoxes
- 1.5.2-SNAPSHOT
+ 1.6.0-SNAPSHOT
jar
Tamablefoxes
@@ -40,7 +40,7 @@
- D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar
+ C:\Users\Checkium\Desktop\vps\smp\SMP\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar
false
@@ -71,23 +71,18 @@
-
+
+
org.spigotmc
spigot
system
1.15.2
- ${project.basedir}/../spigot-1.15.2.jar
- -->
-
- com.github.WesJD.AnvilGUI
- anvilgui
- 478e0c1
+ C:/Users/Checkium/Desktop/Servers/SMP/cache/patched_1.15.2.jar
diff --git a/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
index c8a5a47..7a97acf 100644
--- a/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
+++ b/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
@@ -2,57 +2,131 @@ package net.seanomik.tamablefoxes;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.io.Config;
-import net.seanomik.tamablefoxes.io.LanguageConfig;
import net.seanomik.tamablefoxes.versions.version_1_15.pathfinding.*;
-import org.bukkit.NamespacedKey;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
+import org.apache.commons.lang.reflect.FieldUtils;
+import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.v1_15_R1.persistence.CraftPersistentDataContainer;
-import org.bukkit.entity.Item;
-import org.bukkit.persistence.PersistentDataContainer;
-import org.bukkit.persistence.PersistentDataType;
-import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
public class EntityTamableFox extends EntityFox {
- List untamedGoals = new ArrayList<>();
- private boolean tamed;
- private boolean sitting;
- private EntityLiving owner;
- private UUID ownerUUID;
+ protected static final DataWatcherObject tamed;
+ protected static final DataWatcherObject> ownerUUID;
+
+ static {
+ tamed = DataWatcher.a(EntityTamableFox.class, DataWatcherRegistry.a);
+ ownerUUID = DataWatcher.a(EntityTamableFox.class, DataWatcherRegistry.o);
+ }
+
+ List untamedGoals;
private FoxPathfinderGoalSit goalSit;
public EntityTamableFox(EntityTypes extends EntityFox> entitytypes, World world) {
super(entitytypes, world);
-
- clearPathFinderGoals();
- initPathfinderGoals();
+ // clearPathFinderGoals();
+ //initPathfinderGoals();
}
- public static Object getPrivateField(String fieldName, Class clazz, Object object) {
- Field field;
- Object o = null;
+ @Override
+ public void initPathfinder() {
try {
- field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- o = field.get(object);
- } catch (NoSuchFieldException | IllegalAccessException e) {
+ 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) -> !isTamed()));
+
+ // 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 EntityFox.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);
+ bE.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityAnimal.class, 10, false, false, (entityliving) -> {
+ return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && (entityliving instanceof EntityChicken || entityliving instanceof EntityRabbit);
+ }));
+
+ Field bF = this.getClass().getSuperclass().getDeclaredField("bF");
+ bF.setAccessible(true);
+ bF.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityTurtle.class, 10, false, false, (entityLiving) -> {
+ return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && EntityTurtle.bw.test((EntityLiving) entityLiving);
+ }));
+
+ Field bG = this.getClass().getSuperclass().getDeclaredField("bG");
+ bG.setAccessible(true);
+ bG.set(this, new PathfinderGoalNearestAttackableTarget(this, EntityFish.class, 20, false, false, (entityliving) -> {
+ return (!isTamed() || (Config.doesTamedAttackWildAnimals() && isTamed())) && entityliving instanceof EntityFishSchool;
+ }));
+
+
+
+ untamedGoals = new ArrayList<>();
+
+ // Sleep
+ PathfinderGoal sleep = getFoxInnerPathfinderGoal("t");
+ this.goalSelector.a(8, sleep);
+ untamedGoals.add(sleep);
+
+ // PerchAndSearch (Random sitting?)
+ PathfinderGoal perchAndSearch = getFoxInnerPathfinderGoal("r");
+ this.goalSelector.a(14, perchAndSearch);
+ untamedGoals.add(perchAndSearch);
+
+ // EatBerries (Pick berry bushes)
+ PathfinderGoal eatBerries = new EntityFox.f(1.2000000476837158D, 12, 2);
+ this.goalSelector.a(11, 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
+ untamedGoals.add(seekShelter);
+
+ PathfinderGoal strollThroughVillage = getFoxInnerPathfinderGoal("q", Arrays.asList(32, 200), Arrays.asList(int.class, int.class));
+ this.goalSelector.a(10, strollThroughVillage); // StrollThroughVillage
+ untamedGoals.add(strollThroughVillage);
+
+ } catch (Exception e) {
e.printStackTrace();
}
- return o;
- }
-
- private PathfinderGoal getFoxInnerPathfinderGoal(String innerName, List