Add most features back after the re-implementation removed them.

Changes:
 * Giving/taking foxes items.
 * Change taming food back to chicken.
 * Change taming food to only use sweet berries.
 * Child fox from breeding is now set to its parent fox type.
 * Added code commenting.
 * When you tame a fox it gives the player the taming advancement.

Still need to add naming.
This commit is contained in:
SeanOMik 2020-03-30 14:18:21 -05:00
parent 4bcb141a42
commit 2f0dc9c501
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
8 changed files with 127 additions and 135 deletions

View File

@ -15,7 +15,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8 (2)" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11.0.5" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -2,8 +2,20 @@
<project version="4">
<component name="ChangeListManager">
<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/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" 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/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/versions/version_1_15/command/CommandSpawnTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/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/pathfinding/FoxPathfinderGoalFollowOwner.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/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/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/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/config.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/plugin.yml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -65,27 +77,8 @@
</key>
</component>
<component name="RunManager" selected="JAR Application.Spigot-1.15.2">
<configuration name="Paper-1.15.1" type="JarApplication">
<option name="JAR_PATH" value="$USER_HOME$/_TEST_SERVER_PAPER_1.15.1_/paper-62.jar" />
<option name="WORKING_DIRECTORY" value="D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.15.1_" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
<configuration name="Paper-1.15.2" type="JarApplication">
<option name="JAR_PATH" value="$USER_HOME$/_TEST_SERVER_PAPER_1.15.2_/paper-77.jar" />
<option name="PROGRAM_PARAMETERS" value="nogui" />
<option name="WORKING_DIRECTORY" value="D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.15.2_" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
<configuration name="Spigot-1.15.1" type="JarApplication">
<option name="JAR_PATH" value="$USER_HOME$/Desktop/vps/smp/SMP/Paper.jar" />
<option name="WORKING_DIRECTORY" value="C:\Users\Checkium\Desktop\vps\smp\SMP\" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
<configuration name="Spigot-1.15.2" type="JarApplication">
<option name="JAR_PATH" value="$USER_HOME$/_TEST_SERVER_1.15.2_/spigot-1.15.2.jar" />
<option name="JAR_PATH" value="$PROJECT_DIR$/../../_TEST_SERVER_1.15.2_/spigot-1.15.2.jar" />
<option name="PROGRAM_PARAMETERS" value="nogui" />
<option name="WORKING_DIRECTORY" value="D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_" />
<option name="ALTERNATIVE_JRE_PATH" />
@ -124,10 +117,7 @@
<method v="2" />
</configuration>
<list>
<item itemvalue="JAR Application.Spigot-1.15.1" />
<item itemvalue="JAR Application.Spigot-1.15.2" />
<item itemvalue="JAR Application.Paper-1.15.1" />
<item itemvalue="JAR Application.Paper-1.15.2" />
<item itemvalue="Maven.TamableFoxesCustomEntity build" />
</list>
</component>
@ -190,10 +180,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="1580229888801">
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1585594670133">
<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="1580081956712" />
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585594670133" />
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580229888801" />
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1579710781130" />
<state x="765" y="230" key="#com.intellij.ide.util.MemberChooser" timestamp="1580580882620">
@ -201,6 +191,10 @@
</state>
<state x="765" y="230" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580580882620" />
<state x="765" y="230" key="#com.intellij.ide.util.MemberChooser/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1579708181770" />
<state x="808" y="409" key="#com.intellij.ide.util.projectWizard.JdkChooserPanel.MyDialog" timestamp="1585594689529">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="808" y="409" key="#com.intellij.ide.util.projectWizard.JdkChooserPanel.MyDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585594689529" />
<state x="2415" y="104" key="CommitChangelistDialog2" timestamp="1582326721037">
<screen x="1920" y="0" width="1920" height="1040" />
</state>
@ -219,31 +213,31 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="794" y="418" width="356" height="203" key="Github.CreateGistDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580081718270" />
<state width="1879" height="282" key="GridCell.Tab.0.bottom" timestamp="1582226910732">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.0.bottom" timestamp="1585595254677">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254677" />
<state width="939" height="355" key="GridCell.Tab.0.bottom/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020859" />
<state width="1879" height="282" key="GridCell.Tab.0.bottom/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.bottom/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668965" />
<state width="1879" height="282" key="GridCell.Tab.0.center" timestamp="1582226910732">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.0.center" timestamp="1585595254677">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254677" />
<state width="939" height="355" key="GridCell.Tab.0.center/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020858" />
<state width="1879" height="282" key="GridCell.Tab.0.center/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.center/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668964" />
<state width="1879" height="282" key="GridCell.Tab.0.left" timestamp="1582226910732">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.0.left" timestamp="1585595254676">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254676" />
<state width="939" height="355" key="GridCell.Tab.0.left/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020858" />
<state width="1879" height="282" key="GridCell.Tab.0.left/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.left/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668964" />
<state width="1879" height="282" key="GridCell.Tab.0.right" timestamp="1582226910732">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.0.right" timestamp="1585595254677">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254677" />
<state width="939" height="355" key="GridCell.Tab.0.right/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020858" />
<state width="1879" height="282" key="GridCell.Tab.0.right/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.right/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668964" />
@ -308,20 +302,20 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="552" y="254" key="Vcs.Push.Dialog.v2/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234030515" />
<state x="2576" y="343" key="com.intellij.ide.util.TipDialog" timestamp="1582324367326">
<screen x="1920" y="0" width="1920" height="1040" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog" timestamp="1585594713886">
<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="1580171129088" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585594713886" />
<state x="2576" y="343" key="com.intellij.ide.util.TipDialog/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582324367326" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580132930429" />
<state x="458" y="257" width="1003" height="602" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2" timestamp="1580233159142">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="458" y="257" width="1003" height="602" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580233159142" />
<state x="-781" y="188" width="1359" height="1028" key="dock-window-1" timestamp="1580017524734">
<state x="-1340" y="47" width="1356" height="802" maximized="true" key="dock-window-1" timestamp="1585595645245">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="-781" y="188" width="1359" height="1028" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580017524734" />
<state x="-1340" y="47" width="1356" height="802" maximized="true" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595645245" />
<state x="-809" y="141" width="1359" height="1028" key="dock-window-2" timestamp="1580018302720">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
@ -360,16 +354,6 @@
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java</url>
<line>219</line>
<option name="timeStamp" value="8" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java</url>
<line>220</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/LanguageConfig.java</url>
<line>110</line>

12
pom.xml
View File

@ -39,8 +39,8 @@
<goal>shade</goal>
</goals>
<configuration>
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.1_\plugins\TamableFoxes-MC-v1.15.1-v${project.version}.jar</outputFile>-->
<outputFile>C:\Users\Checkium\Desktop\vps\smp\SMP\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar</outputFile>
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\TamableFoxes-MC-v1.15.1-v${project.version}.jar</outputFile>
<!--<outputFile>C:\Users\Checkium\Desktop\vps\smp\SMP\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar</outputFile>-->
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
@ -71,18 +71,18 @@
</repositories>
<dependencies>
<!--<dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>-->
<dependency>
</dependency>
<!--<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<scope>system</scope>
<version>1.15.2</version>
<systemPath>C:/Users/Checkium/Desktop/Servers/SMP/cache/patched_1.15.2.jar</systemPath>
</dependency>
</dependency>-->
</dependencies>
</project>

View File

@ -1,10 +1,9 @@
package net.seanomik.tamablefoxes;
import com.google.common.collect.Lists;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.io.Config;
import net.seanomik.tamablefoxes.versions.version_1_15.pathfinding.*;
import org.apache.commons.lang.reflect.FieldUtils;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.event.entity.EntityRegainHealthEvent;
@ -33,8 +32,6 @@ public class EntityTamableFox extends EntityFox {
public EntityTamableFox(EntityTypes<? extends EntityFox> entitytypes, World world) {
super(entitytypes, world);
// clearPathFinderGoals();
//initPathfinderGoals();
}
@Override
@ -143,7 +140,7 @@ public class EntityTamableFox extends EntityFox {
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(16.0D);
this.getAttributeMap().b(GenericAttributes.FOLLOW_RANGE).setValue(32.0D);
this.getAttributeMap().b(GenericAttributes.ATTACK_KNOCKBACK);
@ -161,6 +158,7 @@ public class EntityTamableFox extends EntityFox {
public static Object getPrivateField(String fieldName, Class clazz, Object object) {
Field field;
Object o = null;
try {
field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
@ -168,6 +166,7 @@ public class EntityTamableFox extends EntityFox {
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
return o;
}
@ -193,12 +192,14 @@ public class EntityTamableFox extends EntityFox {
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));
@ -207,9 +208,11 @@ public class EntityTamableFox extends EntityFox {
this.setTamed(false);
}
}
if (this.goalSit != null) {
this.goalSit.setSitting(compound.getBoolean("Sitting"));
}
this.setSitting(compound.getBoolean("Sitting"));
}
@ -236,8 +239,10 @@ public class EntityTamableFox extends EntityFox {
}
}
// Remove untamed goals if its tamed.
private void reassessTameGoals() {
if (!isTamed()) return;
for (PathfinderGoal untamedGoal : untamedGoals) {
this.goalSelector.a(untamedGoal);
}
@ -247,50 +252,77 @@ public class EntityTamableFox extends EntityFox {
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()) {
} else if (entityhuman.isSneaking()) { // Swap/Put/Take item from fox.
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));
}
if (item != Items.AIR) {
ItemStack c = itemstack.cloneItemStack();
c.setCount(1);
itemstack.subtract(1);
this.setSlot(EnumItemSlot.MAINHAND, c);
}
// 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;
}
}
// TODO: take/give items
} else if (item == Items.SWEET_BERRIES) {
} else if (item == Items.CHICKEN) {
// 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);
} else {
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
}
return true;
}
@ -298,14 +330,11 @@ public class EntityTamableFox extends EntityFox {
}
}
// deobf: isFood (used for breeding)
public boolean i(ItemStack itemstack) {
Item item = itemstack.getItem();
return item.isFood() && item.getFoodInfo().c();
}
@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);
@ -321,8 +350,8 @@ public class EntityTamableFox extends EntityFox {
} else if (!(entityanimal instanceof EntityTamableFox)) {
return false;
} else {
EntityTamableFox entitywolf = (EntityTamableFox)entityanimal;
return (!entitywolf.isSitting() && (this.isInLove() && entitywolf.isInLove()));
EntityTamableFox entityFox = (EntityTamableFox) entityanimal;
return (!entityFox.isSitting() && (this.isInLove() && entityFox.isInLove()));
}
}
@ -338,12 +367,11 @@ public class EntityTamableFox extends EntityFox {
public void tame(EntityHuman owner) {
this.setTamed(true);
this.setOwnerUUID(owner.getUniqueID());
/*
* The following code appears to be for the taming advancement, will investigate how to change that in the future
// Give the player the taming advancement.
if (owner instanceof EntityPlayer) {
CriterionTriggers.x.a((EntityPlayer)owner, this);
}
*/
}
@Nullable
@ -356,7 +384,7 @@ public class EntityTamableFox extends EntityFox {
}
}
// deobf: canAttack
// Only attack entity if its not attacking owner.
public boolean c(EntityLiving entity) {
return !this.isOwnedBy(entity) && super.c(entity);
}
@ -366,7 +394,7 @@ public class EntityTamableFox extends EntityFox {
}
/*
deobf: wantsToAttack (copied from EntityWolf)
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
*/
@ -387,6 +415,7 @@ public class EntityTamableFox extends EntityFox {
}
}
// Set the scoreboard team to the same as the owner if its tamed.
public ScoreboardTeamBase getScoreboardTeam() {
if (this.isTamed()) {
EntityLiving var0 = this.getOwner();
@ -398,13 +427,14 @@ public class EntityTamableFox extends EntityFox {
return super.getScoreboardTeam();
}
// override isAlliedTo
// 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);
}
@ -412,6 +442,7 @@ public class EntityTamableFox extends EntityFox {
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());
@ -445,5 +476,4 @@ public class EntityTamableFox extends EntityFox {
goalEnumSet.clear();
targetEnumSet.clear();
}
}

View File

@ -2,36 +2,15 @@ package net.seanomik.tamablefoxes;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.versions.version_1_15.command.CommandSpawnTamableFox;
import net.seanomik.tamablefoxes.io.Config;
import net.seanomik.tamablefoxes.io.LanguageConfig;
import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
// @TODO:

View File

@ -1,7 +1,7 @@
# Config for Tamable Foxes
show-owner-in-fox-name: false
enable-taming-permission: true
ask-for-name-after-taming: false
tamed-behavior:
# Config for Tamable Foxes
show-owner-in-fox-name: false
enable-taming-permission: true
ask-for-name-after-taming: true
tamed-behavior:
attack-wild-animals: true

View File

@ -1,19 +1,19 @@
name: Tamablefoxes
version: 1.6.0-SNAPSHOT
main: net.seanomik.tamablefoxes.TamableFoxes
api-version: 1.15
load: STARTUP
description: Adds tamable foxes to Minecraft!
commands:
spawntamablefox:
aliases: [tamablefox, stf, spawntf]
usage: /spawntamablefox [type]
description: Spawn a tamable fox at the standing location. Type can be snow or red, or left empty for a red.
permissions:
tamablefoxes.spawn:
description: "Gives the player the ability to spawn tamable foxes."
default: false
tamablefoxes.tame:
description: "Gives the player the ability to tame a fox."
default: false
name: Tamablefoxes
version: 1.6.0-SNAPSHOT
main: net.seanomik.tamablefoxes.TamableFoxes
api-version: 1.15
load: STARTUP
description: Adds tamable foxes to Minecraft!
commands:
spawntamablefox:
aliases: [tamablefox, stf, spawntf]
usage: /spawntamablefox [type]
description: Spawn a tamable fox at the standing location. Type can be snow or red, or left empty for a red.
permissions:
tamablefoxes.spawn:
description: "Gives the player the ability to spawn tamable foxes."
default: false
tamablefoxes.tame:
description: "Gives the player the ability to tame a fox."
default: false

View File

@ -1,7 +1,6 @@
net\seanomik\tamablefoxes\EntityTamableFox.class
net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalMeleeAttack.class
net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalPanic.class
net\seanomik\tamablefoxes\EntityTamableFox$1.class
net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalHurtByTarget.class
net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalFollowOwner.class
net\seanomik\tamablefoxes\TamableFoxes.class