This commit is contained in:
parent
5ec2b578e0
commit
9e8b06c9c0
|
@ -244,6 +244,27 @@ public class EntityTamableFox extends EntityFox {
|
|||
}
|
||||
}
|
||||
|
||||
public void rename(org.bukkit.entity.Player player) {
|
||||
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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
|
||||
// deobf: mobInteract
|
||||
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
@ -271,6 +292,13 @@ public class EntityTamableFox extends EntityFox {
|
|||
|
||||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
if (!entityhuman.isSneaking() && (!flag || this.isBaby())) {
|
||||
// Show the rename menu again when trying to use a nametag on the fox.
|
||||
if (itemstack.getItem() instanceof ItemNameTag) {
|
||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) entityhuman.getBukkitEntity();
|
||||
rename(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.setSleeping(false);
|
||||
this.goalSit.setSitting(!this.isSitting());
|
||||
return flag;
|
||||
|
@ -356,24 +384,7 @@ public class EntityTamableFox extends EntityFox {
|
|||
Player player = (Player) entityhuman.getBukkitEntity();
|
||||
|
||||
player.sendMessage(Config.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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
rename(player);
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class FoxPathfinderGoalFollowOwner extends PathfinderGoal {
|
|||
return false;
|
||||
} else if (entityliving instanceof EntityHuman && ((EntityHuman)entityliving).isSpectator()) {
|
||||
return false;
|
||||
} else if (this.a.isSitting()) {
|
||||
} else if (this.a.isSitting() || this.a.isSleeping()) {
|
||||
return false;
|
||||
} else if (this.a.h(entityliving) < (double)(this.h * this.h)) {
|
||||
return false;
|
||||
|
|
|
@ -244,6 +244,27 @@ public class EntityTamableFox extends EntityFox {
|
|||
}
|
||||
}
|
||||
|
||||
public void rename(org.bukkit.entity.Player player) {
|
||||
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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
|
||||
// deobf: mobInteract
|
||||
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
@ -271,6 +292,13 @@ public class EntityTamableFox extends EntityFox {
|
|||
|
||||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
if (!entityhuman.isSneaking() && (!flag || this.isBaby())) {
|
||||
// Show the rename menu again when trying to use a nametag on the fox.
|
||||
if (itemstack.getItem() instanceof ItemNameTag) {
|
||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) entityhuman.getBukkitEntity();
|
||||
rename(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.setSleeping(false);
|
||||
this.goalSit.setSitting(!this.isSitting());
|
||||
return flag;
|
||||
|
@ -356,24 +384,7 @@ public class EntityTamableFox extends EntityFox {
|
|||
Player player = (Player) entityhuman.getBukkitEntity();
|
||||
|
||||
player.sendMessage(Config.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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
rename(player);
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class FoxPathfinderGoalFollowOwner extends PathfinderGoal {
|
|||
return false;
|
||||
} else if (entityliving.isSpectator()) {
|
||||
return false;
|
||||
} else if (this.a.isSitting()) {
|
||||
} else if (this.a.isSitting() || this.a.isSleeping()) {
|
||||
return false;
|
||||
} else if (this.a.h(entityliving) < (double)(this.h * this.h)) {
|
||||
return false;
|
||||
|
|
|
@ -242,6 +242,27 @@ public class EntityTamableFox extends EntityFox {
|
|||
}
|
||||
}
|
||||
|
||||
public void rename(org.bukkit.entity.Player player) {
|
||||
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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
|
||||
// deobf: mobInteract
|
||||
@Override
|
||||
public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
|
@ -271,6 +292,13 @@ public class EntityTamableFox extends EntityFox {
|
|||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
// @TODO: Do I need to use this.eQ() instead of flag != EnumInteractionResult.SUCCESS?
|
||||
if (!entityhuman.isSneaking() && (flag != EnumInteractionResult.SUCCESS || this.isBaby())) {
|
||||
// Show the rename menu again when trying to use a nametag on the fox.
|
||||
if (itemstack.getItem() instanceof ItemNameTag) {
|
||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) entityhuman.getBukkitEntity();
|
||||
rename(player);
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
this.setSleeping(false);
|
||||
this.goalSit.setSitting(!this.isSitting());
|
||||
return flag;
|
||||
|
@ -357,24 +385,7 @@ public class EntityTamableFox extends EntityFox {
|
|||
Player player = (Player) entityhuman.getBukkitEntity();
|
||||
|
||||
player.sendMessage(Config.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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
rename(player);
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class FoxPathfinderGoalFollowOwner extends PathfinderGoal {
|
|||
return false;
|
||||
} else if (entityliving.isSpectator()) {
|
||||
return false;
|
||||
} else if (this.a.isSitting()) { // this.a.isWillSit()
|
||||
} else if (this.a.isSitting() || this.a.isSleeping()) { // this.a.isWillSit()
|
||||
return false;
|
||||
} else if (this.a.h(entityliving) < (double)(this.h * this.h)) {
|
||||
return false;
|
||||
|
|
|
@ -240,6 +240,27 @@ public class EntityTamableFox extends EntityFox {
|
|||
}
|
||||
}
|
||||
|
||||
public void rename(org.bukkit.entity.Player player) {
|
||||
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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
|
||||
// deobf: mobInteract
|
||||
public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
@ -268,6 +289,13 @@ public class EntityTamableFox extends EntityFox {
|
|||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
// @TODO: Do I need to use this.eQ() instead of flag != EnumInteractionResult.SUCCESS?
|
||||
if (!entityhuman.isSneaking() && (flag != EnumInteractionResult.SUCCESS || this.isBaby())) {
|
||||
// Show the rename menu again when trying to use a nametag on the fox.
|
||||
if (itemstack.getItem() instanceof ItemNameTag) {
|
||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) entityhuman.getBukkitEntity();
|
||||
rename(player);
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
this.setSleeping(false);
|
||||
this.goalSit.setSitting(!this.isSitting());
|
||||
return flag;
|
||||
|
@ -349,24 +377,7 @@ public class EntityTamableFox extends EntityFox {
|
|||
Player player = (Player) entityhuman.getBukkitEntity();
|
||||
|
||||
player.sendMessage(Config.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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
rename(player);
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class FoxPathfinderGoalFollowOwner extends PathfinderGoal {
|
|||
return false;
|
||||
} else if (entityliving.isSpectator()) {
|
||||
return false;
|
||||
} else if (this.a.isSitting()) { // this.a.isWillSit()
|
||||
} else if (this.a.isSitting() || this.a.isSleeping()) { // this.a.isWillSit()
|
||||
return false;
|
||||
} else if (this.a.h(entityliving) < (double)(this.h * this.h)) {
|
||||
return false;
|
||||
|
|
|
@ -240,6 +240,27 @@ public class EntityTamableFox extends EntityFox {
|
|||
}
|
||||
}
|
||||
|
||||
public void rename(org.bukkit.entity.Player player) {
|
||||
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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
|
||||
// deobf: mobInteract
|
||||
public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
@ -268,6 +289,13 @@ public class EntityTamableFox extends EntityFox {
|
|||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
// @TODO: Do I need to use this.eQ() instead of flag != EnumInteractionResult.SUCCESS?
|
||||
if (!entityhuman.isSneaking() && (flag != EnumInteractionResult.SUCCESS || this.isBaby())) {
|
||||
// Show the rename menu again when trying to use a nametag on the fox.
|
||||
if (itemstack.getItem() instanceof ItemNameTag) {
|
||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) entityhuman.getBukkitEntity();
|
||||
rename(player);
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
this.setSleeping(false);
|
||||
this.goalSit.setSitting(!this.isSitting());
|
||||
return flag;
|
||||
|
@ -349,24 +377,7 @@ public class EntityTamableFox extends EntityFox {
|
|||
Player player = (Player) entityhuman.getBukkitEntity();
|
||||
|
||||
player.sendMessage(Config.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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
rename(player);
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class FoxPathfinderGoalFollowOwner extends PathfinderGoal {
|
|||
return false;
|
||||
} else if (entityliving.isSpectator()) {
|
||||
return false;
|
||||
} else if (this.a.isSitting()) { // this.a.isWillSit()
|
||||
} else if (this.a.isSitting() || this.a.isSleeping()) { // this.a.isWillSit()
|
||||
return false;
|
||||
} else if (this.a.h(entityliving) < (double)(this.h * this.h)) {
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_17_R1;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.*;
|
||||
|
@ -45,14 +46,14 @@ import java.util.function.Predicate;
|
|||
|
||||
public class EntityTamableFox extends Fox {
|
||||
|
||||
protected static final EntityDataAccessor<Byte> tamed;
|
||||
protected static final EntityDataAccessor<Boolean> tamed;
|
||||
protected static final EntityDataAccessor<Optional<UUID>> ownerUUID;
|
||||
|
||||
//private static final EntityDataAccessor<Byte> bw; // DATA_FLAGS_ID
|
||||
private static final Predicate<Entity> AVOID_PLAYERS; // AVOID_PLAYERS
|
||||
|
||||
static {
|
||||
tamed = SynchedEntityData.defineId(EntityTamableFox.class, EntityDataSerializers.BYTE);
|
||||
tamed = SynchedEntityData.defineId(EntityTamableFox.class, EntityDataSerializers.BOOLEAN);
|
||||
ownerUUID = SynchedEntityData.defineId(EntityTamableFox.class, EntityDataSerializers.OPTIONAL_UUID);
|
||||
|
||||
AVOID_PLAYERS = (entity) -> !entity.isCrouching();// && EntitySelector.test(entity);
|
||||
|
@ -74,6 +75,8 @@ public class EntityTamableFox extends Fox {
|
|||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(10.0D);
|
||||
this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D);
|
||||
}
|
||||
|
||||
this.setTamed(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +106,7 @@ public class EntityTamableFox extends Fox {
|
|||
|
||||
this.goalSelector.addGoal(0, getFoxInnerPathfinderGoal("g")); // FoxFloatGoal
|
||||
this.goalSelector.addGoal(1, getFoxInnerPathfinderGoal("b")); // FaceplantGoal
|
||||
this.goalSelector.addGoal(2, getFoxInnerPathfinderGoal("n", Arrays.asList(2.2D), Arrays.asList(double.class))); // FoxPanicGoal
|
||||
this.goalSelector.addGoal(2, new FoxPathfinderGoalPanic(this, 2.2D)); // FoxPanicGoal
|
||||
this.goalSelector.addGoal(2, new FoxPathfinderGoalSleepWithOwner(this));
|
||||
this.goalSelector.addGoal(3, getFoxInnerPathfinderGoal("e", Arrays.asList(1.0D), Arrays.asList(double.class))); // FoxBreedGoal
|
||||
|
||||
|
@ -178,10 +181,21 @@ public class EntityTamableFox extends Fox {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void setDefending(boolean defending) {
|
||||
try {
|
||||
Method method = Fox.class.getDeclaredMethod("A", boolean.class); // setDefending
|
||||
method.setAccessible(true);
|
||||
method.invoke((Fox) this, defending);
|
||||
method.setAccessible(false);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(tamed, (byte) 0);
|
||||
this.entityData.define(tamed, false);
|
||||
this.entityData.define(ownerUUID, Optional.empty());
|
||||
}
|
||||
|
||||
|
@ -216,9 +230,11 @@ public class EntityTamableFox extends Fox {
|
|||
}
|
||||
}
|
||||
|
||||
if (ownerUuid != null) {
|
||||
if (ownerUuid != null && !ownerUuid.equals(new UUID(0, 0))) {
|
||||
this.setOwnerUUID(ownerUuid);
|
||||
this.setTamed(true);
|
||||
} else {
|
||||
this.setTamed(false);
|
||||
}
|
||||
|
||||
if (this.goalSitWhenOrdered != null) {
|
||||
|
@ -236,19 +252,15 @@ public class EntityTamableFox extends Fox {
|
|||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return ((Byte) this.entityData.get(tamed) & 4) != 0;
|
||||
UUID ownerUuid = getOwnerUUID();
|
||||
return this.entityData.get(tamed) && (ownerUuid != null && !ownerUuid.equals(new UUID(0, 0)));
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed_) {
|
||||
byte isTamed = this.entityData.get(tamed);
|
||||
if (tamed_) {
|
||||
this.entityData.set(tamed, (byte) (isTamed | 4));
|
||||
} else {
|
||||
this.entityData.set(tamed, (byte) (isTamed & -5));
|
||||
}
|
||||
public void setTamed(boolean tamed) {
|
||||
this.entityData.set(EntityTamableFox.tamed, tamed);
|
||||
this.reassessTameGoals();
|
||||
|
||||
if (tamed_) {
|
||||
if (tamed) {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(24.0D);
|
||||
this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(3.0D);
|
||||
} else {
|
||||
|
@ -267,6 +279,28 @@ public class EntityTamableFox extends Fox {
|
|||
}
|
||||
}
|
||||
|
||||
public void rename(org.bukkit.entity.Player player) {
|
||||
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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.preventClose()
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
@ -296,6 +330,13 @@ public class EntityTamableFox extends Fox {
|
|||
// If the player is not sneaking and the fox cannot breed, then make the fox sit.
|
||||
// @TODO: Do I need to use this.eQ() instead of flag != EnumInteractionResult.SUCCESS?
|
||||
if (!entityhuman.isCrouching() && (flag != InteractionResult.SUCCESS || this.isBaby())) {
|
||||
// Show the rename menu again when trying to use a nametag on the fox.
|
||||
if (itemstack.getItem() instanceof NameTagItem) {
|
||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) entityhuman.getBukkitEntity();
|
||||
rename(player);
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
this.goalSleepWhenOrdered.setOrderedToSleep(false);
|
||||
this.goalSitWhenOrdered.setOrderedToSit(!this.isOrderedToSit());
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@ -374,24 +415,7 @@ public class EntityTamableFox extends Fox {
|
|||
// Let the player choose the new fox's name if its enabled in config.
|
||||
if (Config.askForNameAfterTaming()) {
|
||||
player.sendMessage(Config.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(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
|
||||
}
|
||||
|
||||
return AnvilGUI.Response.close();
|
||||
})
|
||||
.text("Fox name") // Sets the text the GUI should start with
|
||||
.plugin(Utils.tamableFoxesPlugin) // Set the plugin instance
|
||||
.open(player); // Opens the GUI for the player provided
|
||||
rename(player);
|
||||
}
|
||||
} else {
|
||||
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
|
||||
|
|
|
@ -42,6 +42,15 @@ public class FoxPathfinderGoalOwnerHurtByTarget extends TargetGoal {
|
|||
this.timestamp = entityliving.getLastHurtByMobTimestamp();
|
||||
}
|
||||
|
||||
tameAnimal.setDefending(false);
|
||||
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
tameAnimal.setDefending(false);
|
||||
|
||||
super.stop();
|
||||
}
|
||||
}
|
|
@ -42,6 +42,16 @@ public class FoxPathfinderGoalOwnerHurtTarget extends TargetGoal {
|
|||
this.timestamp = entityliving.getLastHurtMobTimestamp();
|
||||
}
|
||||
|
||||
tameAnimal.setDefending(true);
|
||||
|
||||
super.start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
tameAnimal.setDefending(false);
|
||||
|
||||
super.stop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.seanomik.tamablefoxes.versions.version_1_17_R1.pathfinding;
|
||||
|
||||
import net.minecraft.world.entity.ai.goal.PanicGoal;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_17_R1.EntityTamableFox;
|
||||
|
||||
public class FoxPathfinderGoalPanic extends PanicGoal {
|
||||
EntityTamableFox tamableFox;
|
||||
|
||||
public FoxPathfinderGoalPanic(EntityTamableFox tamableFox, double d0) {
|
||||
super(tamableFox, d0);
|
||||
this.tamableFox = tamableFox;
|
||||
}
|
||||
|
||||
public boolean canUse() {
|
||||
if (tamableFox.isTamed()) {
|
||||
return tamableFox.getHealth() < 2.0f && super.canUse();
|
||||
}
|
||||
|
||||
return tamableFox.isDefending() && super.canUse();
|
||||
}
|
||||
}
|
|
@ -22,15 +22,28 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<!--<plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<!-- Replace this with your package! -->
|
||||
<shadedPattern>net.seanomik.tamablefoxes.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>-->
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
|
@ -41,7 +54,7 @@
|
|||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>D:\Code\java\spigotPlugins\servers\${server.version}\plugins\TamableFoxes_v${project.parent.version}.jar</outputFile>
|
||||
<!--<outputFile>D:\Code\java\spigotPlugins\servers\${server.version}\plugins\TamableFoxes_v${project.parent.version}.jar</outputFile>-->
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -118,6 +131,12 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of entity implementations -->
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.seanomik</groupId>
|
||||
<artifactId>tamablefoxes-util</artifactId>
|
||||
|
|
|
@ -11,12 +11,15 @@ import net.seanomik.tamablefoxes.versions.version_1_16_R2.NMSInterface_1_16_R2;
|
|||
import net.seanomik.tamablefoxes.versions.version_1_16_R3.NMSInterface_1_16_R3;
|
||||
import net.seanomik.tamablefoxes.versions.version_1_17_R1.NMSInterface_1_17_R1;
|
||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SingleLineChart;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class TamableFoxes extends JavaPlugin implements Listener {
|
||||
private static TamableFoxes plugin;
|
||||
public static final int BSTATS_PLUGIN_ID = 11944;
|
||||
|
||||
private boolean versionSupported = true;
|
||||
|
||||
|
@ -65,6 +68,9 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
|
|||
if (Config.getMaxPlayerFoxTames() != 0) {
|
||||
SQLiteHelper.getInstance(this).createTablesIfNotExist();
|
||||
}
|
||||
|
||||
Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
||||
//metrics.addCustomChart(new SingleLineChart("servers", () -> 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue