mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-03-12 06:44:14 +01:00
Add /npc fox --pouncing/faceplanted/interested
This commit is contained in:
parent
6368cb379e
commit
59531a9bc8
@ -459,6 +459,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
getServer().getPluginManager().callEvent(new CitizensPreReloadEvent());
|
||||
|
||||
templateRegistry = new TemplateRegistry(new File(this.getDataFolder(), "templates").toPath());
|
||||
|
||||
saves.reloadFromSource();
|
||||
saves.loadInto(npcRegistry);
|
||||
|
||||
|
@ -974,42 +974,6 @@ public class NPCCommands {
|
||||
throw new CommandException();
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "itemframe --visible [true|false] --fixed [true|false] --rotation [rotation] --item [item]",
|
||||
desc = "",
|
||||
modifiers = { "itemframe" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "",
|
||||
permission = "citizens.npc.itemframe")
|
||||
@Requirements(ownership = true, selected = true, types = EntityType.ITEM_FRAME)
|
||||
public void endercrystal(CommandContext args, CommandSender sender, NPC npc, @Flag("visible") Boolean visible,
|
||||
@Flag("fixed") Boolean fixed, @Flag("rotation") Rotation rotation, @Flag("item") ItemStack item)
|
||||
throws CommandException {
|
||||
ItemFrameTrait ift = npc.getOrAddTrait(ItemFrameTrait.class);
|
||||
String msg = "";
|
||||
if (visible != null) {
|
||||
ift.setVisible(visible);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_VISIBLE_SET, visible);
|
||||
}
|
||||
if (fixed != null) {
|
||||
ift.setFixed(fixed);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_FIXED_SET, fixed);
|
||||
}
|
||||
if (item != null) {
|
||||
ift.setItem(item);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_ITEM_SET, item);
|
||||
}
|
||||
if (rotation != null) {
|
||||
ift.setRotation(rotation);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_ROTATION_SET, rotation);
|
||||
}
|
||||
if (msg.isEmpty())
|
||||
throw new CommandUsageException();
|
||||
Messaging.send(sender, msg.trim());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "enderman -a(ngry)",
|
||||
@ -1452,6 +1416,42 @@ public class NPCCommands {
|
||||
Messaging.sendTr(sender, Messages.ITEM_SET, npc.getName(), Util.prettyEnum(stack.getType()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "itemframe --visible [true|false] --fixed [true|false] --rotation [rotation] --item [item]",
|
||||
desc = "",
|
||||
modifiers = { "itemframe" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "",
|
||||
permission = "citizens.npc.itemframe")
|
||||
@Requirements(ownership = true, selected = true, types = EntityType.ITEM_FRAME)
|
||||
public void itemframe(CommandContext args, CommandSender sender, NPC npc, @Flag("visible") Boolean visible,
|
||||
@Flag("fixed") Boolean fixed, @Flag("rotation") Rotation rotation, @Flag("item") ItemStack item)
|
||||
throws CommandException {
|
||||
ItemFrameTrait ift = npc.getOrAddTrait(ItemFrameTrait.class);
|
||||
String msg = "";
|
||||
if (visible != null) {
|
||||
ift.setVisible(visible);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_VISIBLE_SET, visible);
|
||||
}
|
||||
if (fixed != null) {
|
||||
ift.setFixed(fixed);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_FIXED_SET, fixed);
|
||||
}
|
||||
if (item != null) {
|
||||
ift.setItem(item);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_ITEM_SET, item);
|
||||
}
|
||||
if (rotation != null) {
|
||||
ift.setRotation(rotation);
|
||||
msg += " " + Messaging.tr(Messages.ITEMFRAME_ROTATION_SET, rotation);
|
||||
}
|
||||
if (msg.isEmpty())
|
||||
throw new CommandUsageException();
|
||||
Messaging.send(sender, msg.trim());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "jump",
|
||||
|
@ -23,6 +23,12 @@ public class FoxTrait extends Trait {
|
||||
@Persist
|
||||
private boolean crouching = false;
|
||||
@Persist
|
||||
private boolean faceplanted;
|
||||
@Persist
|
||||
private boolean interested;
|
||||
@Persist
|
||||
private boolean pouncing;
|
||||
@Persist
|
||||
private boolean sitting = false;
|
||||
@Persist
|
||||
private boolean sleeping = false;
|
||||
@ -41,6 +47,18 @@ public class FoxTrait extends Trait {
|
||||
return crouching;
|
||||
}
|
||||
|
||||
public boolean isFaceplanted() {
|
||||
return faceplanted;
|
||||
}
|
||||
|
||||
public boolean isInterested() {
|
||||
return interested;
|
||||
}
|
||||
|
||||
public boolean isPouncing() {
|
||||
return pouncing;
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return sitting;
|
||||
}
|
||||
@ -64,6 +82,18 @@ public class FoxTrait extends Trait {
|
||||
this.crouching = crouching;
|
||||
}
|
||||
|
||||
public void setFaceplanted(boolean faceplanted) {
|
||||
this.faceplanted = faceplanted;
|
||||
}
|
||||
|
||||
public void setInterested(boolean interested) {
|
||||
this.interested = interested;
|
||||
}
|
||||
|
||||
public void setPouncing(boolean pouncing) {
|
||||
this.pouncing = pouncing;
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting) {
|
||||
this.sitting = sitting;
|
||||
}
|
||||
@ -76,9 +106,15 @@ public class FoxTrait extends Trait {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public enum FoxModifier {
|
||||
FACEPLANTED,
|
||||
INTERESTED,
|
||||
POUNCING;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "fox --type type --sleeping [true|false] --sitting [true|false] --crouching [true|false]",
|
||||
usage = "fox --type type --sleeping [true|false] --sitting [true|false] --crouching [true|false] --interested [true|false] --pouncing [true|false] --faceplanted [true|false]",
|
||||
desc = "",
|
||||
modifiers = { "fox" },
|
||||
min = 1,
|
||||
@ -87,7 +123,8 @@ public class FoxTrait extends Trait {
|
||||
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
||||
public static void fox(CommandContext args, CommandSender sender, NPC npc, @Flag("sleeping") Boolean sleeping,
|
||||
@Flag("sitting") Boolean sitting, @Flag("crouching") Boolean crouching,
|
||||
@Flag(value = "type", completions = { "RED", "SNOW" }) String rawtype) throws CommandException {
|
||||
@Flag(value = "type", completions = { "RED", "SNOW" }) String rawtype, @Flag("pouncing") Boolean pouncing,
|
||||
@Flag("interested") Boolean interested, @Flag("faceplanted") Boolean faceplanted) throws CommandException {
|
||||
FoxTrait trait = npc.getOrAddTrait(FoxTrait.class);
|
||||
String output = "";
|
||||
if (rawtype != null) {
|
||||
@ -113,6 +150,21 @@ public class FoxTrait extends Trait {
|
||||
output += ' ' + Messaging.tr(crouching ? Messages.FOX_CROUCHING_SET : Messages.FOX_CROUCHING_UNSET,
|
||||
npc.getName());
|
||||
}
|
||||
if (interested != null) {
|
||||
trait.setInterested(interested);
|
||||
output += ' ' + Messaging.tr(interested ? Messages.FOX_INTERESTED_SET : Messages.FOX_INTERESTED_UNSET,
|
||||
npc.getName());
|
||||
}
|
||||
if (pouncing != null) {
|
||||
trait.setPouncing(pouncing);
|
||||
output += ' '
|
||||
+ Messaging.tr(pouncing ? Messages.FOX_POUNCING_SET : Messages.FOX_POUNCING_UNSET, npc.getName());
|
||||
}
|
||||
if (faceplanted != null) {
|
||||
trait.setFaceplanted(faceplanted);
|
||||
output += ' ' + Messaging.tr(faceplanted ? Messages.FOX_FACEPLANTED_SET : Messages.FOX_FACEPLANTED_UNSET,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output.trim());
|
||||
} else
|
||||
|
@ -124,6 +124,12 @@ public class Messages {
|
||||
public static final String FOLLOW_UNSET = "citizens.commands.npc.follow.unset";
|
||||
public static final String FOX_CROUCHING_SET = "citizens.commands.npc.fox.crouching-set";
|
||||
public static final String FOX_CROUCHING_UNSET = "citizens.commands.npc.fox.crouching-unset";
|
||||
public static final String FOX_FACEPLANTED_SET = "citizens.commands.npc.fox.faceplanted-set";
|
||||
public static final String FOX_FACEPLANTED_UNSET = "citizens.commands.npc.fox.faceplanted-unset";
|
||||
public static final String FOX_INTERESTED_SET = "citizens.commands.npc.fox.interested-set";
|
||||
public static final String FOX_INTERESTED_UNSET = "citizens.commands.npc.fox.interested-unset";
|
||||
public static final String FOX_POUNCING_SET = "citizens.commands.npc.fox.pouncing-set";
|
||||
public static final String FOX_POUNCING_UNSET = "citizens.commands.npc.fox.pouncing-unset";
|
||||
public static final String FOX_SITTING_SET = "citizens.commands.npc.fox.sitting-set";
|
||||
public static final String FOX_SITTING_UNSET = "citizens.commands.npc.fox.sitting-unset";
|
||||
public static final String FOX_SLEEPING_SET = "citizens.commands.npc.fox.sleeping-set";
|
||||
|
@ -11,7 +11,6 @@
|
||||
"citizens.commands.errors.unknown-registry" : "Unknown NPC registry [[{0}]].",
|
||||
"citizens.commands.help.command-missing" : "Command /{0} not found.",
|
||||
"citizens.commands.help.header" : "Help",
|
||||
"citizens.commands.npc.shop.deleted" : "Shop [[{0}]] deleted.",
|
||||
"citizens.commands.id-not-found" : "Couldn''t find any NPC with ID [[{0}]].",
|
||||
"citizens.commands.invalid-mobtype" : "[[{0}]] is not a valid mobtype.",
|
||||
"citizens.commands.invalid-number" : "That is not a valid number.",
|
||||
@ -83,17 +82,10 @@
|
||||
"citizens.commands.npc.chunkload.unset" : "[[{0}]] will no longer force chunks to be loaded.",
|
||||
"citizens.commands.npc.collidable.description" : "Toggles an NPC''s collidability",
|
||||
"citizens.commands.npc.collidable.help" : "",
|
||||
"citizens.commands.npc.itemframe.description" : "Sets itemframe modifiers",
|
||||
"citizens.commands.npc.itemframe.rotation-set" : "Rotation set to [[{0}]]",
|
||||
"citizens.commands.npc.itemframe.item-set" : "Item set to [[{0}]]",
|
||||
"citizens.commands.npc.itemframe.fixed-set" : "Fixed (whether the item can be rotated) set to [[{0}]]",
|
||||
"citizens.commands.npc.itemframe.visible-set" : "Visible set to [[{0}]]",
|
||||
"citizens.commands.npc.collidable.set" : "[[{0}]] will now collide with entities.",
|
||||
"citizens.commands.npc.collidable.unset" : "[[{0}]] will no longer collide with entities.",
|
||||
"citizens.commands.npc.command.all-players-forgotten" : "[[{0}]] forgot all player command history.",
|
||||
"citizens.commands.npc.command.all-errors-cleared" : "[[{0}]] cleared all [[{1}]] errors.",
|
||||
"citizens.commands.npc.command.invalid-player" : "[[{0}]] could not be found as a player.",
|
||||
"citizens.commands.npc.command.player-forgotten" : "Forgot player command history for [[{0}]].",
|
||||
"citizens.commands.npc.command.all-players-forgotten" : "[[{0}]] forgot all player command history.",
|
||||
"citizens.commands.npc.command.cleared" : "[[{0}]]''s commands cleared.",
|
||||
"citizens.commands.npc.command.command-added" : "Command [[{0}]] added with id [[{1}]].",
|
||||
"citizens.commands.npc.command.command-removed" : "Command [[{0}]] removed.",
|
||||
@ -111,10 +103,12 @@
|
||||
"citizens.commands.npc.command.individual-cost-set" : "Set cost per click to [[{0}]] for command id [[{1}]].",
|
||||
"citizens.commands.npc.command.individual-experience-cost-set" : "Set xp level cost per click to [[{0}]] for command id [[{1}]].",
|
||||
"citizens.commands.npc.command.invalid-error-message" : "Invalid error message. Valid messages are [[{0}]].",
|
||||
"citizens.commands.npc.command.invalid-player" : "[[{0}]] could not be found as a player.",
|
||||
"citizens.commands.npc.command.left-hand-header" : "Commands to run on [[left click]]:",
|
||||
"citizens.commands.npc.command.none-added" : "No commands have been added.",
|
||||
"citizens.commands.npc.command.persist-sequence-set" : "Command sequences will now be saved across server restarts.",
|
||||
"citizens.commands.npc.command.persist-sequence-unset" : "Command sequences will no longer be saved across server restarts.",
|
||||
"citizens.commands.npc.command.player-forgotten" : "Forgot player command history for [[{0}]].",
|
||||
"citizens.commands.npc.command.right-hand-header" : "Commands to run on [[right click]]:",
|
||||
"citizens.commands.npc.command.temporary-permissions-set" : "Temporary permissions set to [[{0}]].",
|
||||
"citizens.commands.npc.command.unknown-id" : "Unknown command id [[{0}]] for this NPC.",
|
||||
@ -176,9 +170,15 @@
|
||||
"citizens.commands.npc.fox.crouching-set" : "[[{0}]] is now crouching.",
|
||||
"citizens.commands.npc.fox.crouching-unset" : "[[{0}]] is no longer crouching.",
|
||||
"citizens.commands.npc.fox.description" : "Sets fox modifiers",
|
||||
"citizens.commands.npc.fox.faceplanted-set" : "[[{0}]] is now faceplanted.",
|
||||
"citizens.commands.npc.fox.faceplanted-unset" : "[[{0}]] is no longer faceplanted.",
|
||||
"citizens.commands.npc.fox.fox-type-set" : "Fox type set to [[{0}]].",
|
||||
"citizens.commands.npc.fox.help" : "",
|
||||
"citizens.commands.npc.fox.interested-set" : "[[{0}]] is now interested.",
|
||||
"citizens.commands.npc.fox.interested-unset" : "[[{0}]] is no longer interested.",
|
||||
"citizens.commands.npc.fox.invalid-fox-type" : "Invalid fox type specified. Valid types are [[{0}]].",
|
||||
"citizens.commands.npc.fox.pouncing-set" : "[[{0}]] is now pouncing.",
|
||||
"citizens.commands.npc.fox.pouncing-unset" : "[[{0}]] is no longer pouncing.",
|
||||
"citizens.commands.npc.fox.sitting-set" : "[[{0}]] is now sitting.",
|
||||
"citizens.commands.npc.fox.sitting-unset" : "[[{0}]] is no longer sitting.",
|
||||
"citizens.commands.npc.fox.sleeping-set" : "[[{0}]] is now sleeping.",
|
||||
@ -256,6 +256,11 @@
|
||||
"citizens.commands.npc.item.help" : "",
|
||||
"citizens.commands.npc.item.item-set" : "[[{0}]]''s item set to [[{1}]].",
|
||||
"citizens.commands.npc.item.unknown-material" : "Unknown material given.",
|
||||
"citizens.commands.npc.itemframe.description" : "Sets itemframe modifiers",
|
||||
"citizens.commands.npc.itemframe.fixed-set" : "Fixed (whether the item can be rotated) set to [[{0}]]",
|
||||
"citizens.commands.npc.itemframe.item-set" : "Item set to [[{0}]]",
|
||||
"citizens.commands.npc.itemframe.rotation-set" : "Rotation set to [[{0}]]",
|
||||
"citizens.commands.npc.itemframe.visible-set" : "Visible set to [[{0}]]",
|
||||
"citizens.commands.npc.jump.description": "Makes the NPC jump",
|
||||
"citizens.commands.npc.jump.help" : "",
|
||||
"citizens.commands.npc.knockback.description" : "Toggle NPC knockback",
|
||||
@ -470,6 +475,7 @@
|
||||
"citizens.commands.npc.sheep.description" : "Sets sheep modifiers",
|
||||
"citizens.commands.npc.sheep.help" : "",
|
||||
"citizens.commands.npc.sheep.invalid-color" : "Invalid sheep color given. Valid colors are: [[{0}]]. ",
|
||||
"citizens.commands.npc.shop.deleted" : "Shop [[{0}]] deleted.",
|
||||
"citizens.commands.npc.shop.description" : "NPC shop edit/show",
|
||||
"citizens.commands.npc.shop.help" : "",
|
||||
"citizens.commands.npc.shulker.color-set" : "[[{0}]]''s color set to [[{1}]].",
|
||||
@ -607,8 +613,6 @@
|
||||
"citizens.commands.requirements.too-few-arguments" : "Too few arguments.",
|
||||
"citizens.commands.requirements.too-many-arguments" : "Too many arguments. ",
|
||||
"citizens.commands.template.applied" : "Applied [[{0}]] to [[{1}]].",
|
||||
"citizens.commands.template.qualified-template-required" : "Duplicate template name [[{0}]]. Pick from the following options: [[{1}]].",
|
||||
"citizens.commands.template.namespace-already-exists" : "Namespace [[{0}]] already exists",
|
||||
"citizens.commands.template.apply.description" : "Applies a template to the selected NPC",
|
||||
"citizens.commands.template.apply.help" : "",
|
||||
"citizens.commands.template.conflict" : "A template by that name already exists.",
|
||||
@ -616,6 +620,10 @@
|
||||
"citizens.commands.template.list.header" : "]]Available templates:",
|
||||
"citizens.commands.template.list.help" : "",
|
||||
"citizens.commands.template.missing" : "Template not found.",
|
||||
"citizens.commands.template.namespace-already-exists" : "Namespace [[{0}]] already exists",
|
||||
"citizens.commands.template.qualified-template-required" : "Duplicate template name [[{0}]]. Pick from the following options: [[{1}]].",
|
||||
"citizens.commands.trait.*.description" : "Toggles traits on the NPC",
|
||||
"citizens.commands.trait.*.help" : "",
|
||||
"citizens.commands.trait.add.description" : "Adds traits to the NPC",
|
||||
"citizens.commands.trait.add.help" : "",
|
||||
"citizens.commands.trait.added" : "Added {0} successfully.",
|
||||
@ -624,8 +632,6 @@
|
||||
"citizens.commands.trait.remove.description" : "Removes traits on the NPC",
|
||||
"citizens.commands.trait.remove.help" : "",
|
||||
"citizens.commands.trait.removed" : "Removed {0} successfully.",
|
||||
"citizens.commands.trait.*.description" : "Toggles traits on the NPC",
|
||||
"citizens.commands.trait.*.help" : "",
|
||||
"citizens.commands.traitc.*.description" : "Configures a trait",
|
||||
"citizens.commands.traitc.*.help" : "",
|
||||
"citizens.commands.traitc.missing" : "Trait not found.",
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
@ -12,6 +14,7 @@ import net.citizensnpcs.nms.v1_14_R1.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
|
||||
@ -200,6 +203,16 @@ public class FoxController extends MobEntityController {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
u(ft.isInterested());
|
||||
s(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,6 +222,9 @@ public class FoxController extends MobEntityController {
|
||||
return !npc.isProtected();
|
||||
return super.n(entity);
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(EntityFox.class, "v", true,
|
||||
boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements NPCHolder {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
@ -13,6 +15,7 @@ import net.citizensnpcs.nms.v1_15_R1.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.AxisAlignedBB;
|
||||
@ -202,6 +205,16 @@ public class FoxController extends MobEntityController {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
u(ft.isInterested());
|
||||
s(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,6 +224,9 @@ public class FoxController extends MobEntityController {
|
||||
return !npc.isProtected();
|
||||
return super.n(entity);
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(EntityFox.class, "v", true,
|
||||
boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements ForwardingNPCHolder {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
|
||||
@ -13,6 +15,7 @@ import net.citizensnpcs.nms.v1_16_R3.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.AxisAlignedBB;
|
||||
@ -202,6 +205,16 @@ public class FoxController extends MobEntityController {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
w(ft.isInterested());
|
||||
u(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,6 +224,9 @@ public class FoxController extends MobEntityController {
|
||||
return !npc.isProtected();
|
||||
return super.n(entity);
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(EntityFox.class, "x", true,
|
||||
boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements ForwardingNPCHolder {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_17_R1.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
||||
@ -12,6 +14,7 @@ import net.citizensnpcs.nms.v1_17_R1.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@ -88,6 +91,16 @@ public class FoxController extends MobEntityController {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setIsInterested(ft.isInterested());
|
||||
setIsPouncing(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,6 +229,8 @@ public class FoxController extends MobEntityController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(Fox.class, "z", true, boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements ForwardingNPCHolder {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_18_R2.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
|
||||
@ -12,6 +14,7 @@ import net.citizensnpcs.nms.v1_18_R2.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_18_R2.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@ -89,6 +92,16 @@ public class FoxController extends MobEntityController {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setIsInterested(ft.isInterested());
|
||||
setIsPouncing(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,6 +237,8 @@ public class FoxController extends MobEntityController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(Fox.class, "z", true, boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements ForwardingNPCHolder {
|
||||
|
@ -469,7 +469,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
|
||||
private static final float EPSILON = 0.003F;
|
||||
|
||||
private static final MethodHandle GAMEMODE_SETTING = NMS.getFirstMethodHandle(ServerPlayerGameMode.class, true,
|
||||
GameType.class, GameType.class);
|
||||
private static final Location LOADED_LOCATION = new Location(null, 0, 0, 0);
|
||||
private static int MAX_LENGTH = 0;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_19_R3.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity;
|
||||
@ -12,6 +14,7 @@ import net.citizensnpcs.nms.v1_19_R3.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_19_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@ -90,6 +93,16 @@ public class FoxController extends MobEntityController {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setIsInterested(ft.isInterested());
|
||||
setIsPouncing(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,6 +238,8 @@ public class FoxController extends MobEntityController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(Fox.class, "A", true, boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements ForwardingNPCHolder {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_20_R3.entity;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
|
||||
@ -11,6 +13,7 @@ import net.citizensnpcs.nms.v1_20_R3.util.NMSBoundingBox;
|
||||
import net.citizensnpcs.nms.v1_20_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@ -88,6 +91,16 @@ public class FoxController extends MobEntityController {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
FoxTrait ft = npc.getTraitNullable(FoxTrait.class);
|
||||
if (ft != null) {
|
||||
try {
|
||||
SET_FACEPLANTED.invoke(this, ft.isFaceplanted());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setIsInterested(ft.isInterested());
|
||||
setIsPouncing(ft.isPouncing());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,6 +228,8 @@ public class FoxController extends MobEntityController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static final MethodHandle SET_FACEPLANTED = NMS.getMethodHandle(Fox.class, "A", true, boolean.class);
|
||||
}
|
||||
|
||||
public static class FoxNPC extends CraftFox implements ForwardingNPCHolder {
|
||||
|
Loading…
Reference in New Issue
Block a user