mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 02:25:57 +01:00
Fix NPCs constantly trying to swim, relicense to LGPL
This commit is contained in:
parent
cb6f8be7fc
commit
248e9de2e6
63
LICENSE
63
LICENSE
@ -1,41 +1,58 @@
|
||||
Citizens is licensed under the Open Software License version 3.0
|
||||
Citizens is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3.0
|
||||
|
||||
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
a) to reproduce the Original Work in copies, either alone or as part of a collective work;
|
||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
c) to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
d) to perform the Original Work publicly; and
|
||||
0. Additional Definitions.
|
||||
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
||||
|
||||
e) to display the Original Work publicly.
|
||||
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
|
||||
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
|
||||
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
||||
|
||||
4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
|
||||
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
|
||||
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
|
||||
2. Conveying Modified Versions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
4. Combined Works.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
d) Do one of the following:
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
5. Combined Libraries.
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
|
||||
|
||||
14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
@ -388,6 +388,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
locationLookup = null;
|
||||
enabled = false;
|
||||
saveOnDisable = true;
|
||||
ProfileFetcher.shutdown();
|
||||
Skin.clearCache();
|
||||
Template.shutdown();
|
||||
NMS.shutdown();
|
||||
CitizensAPI.shutdown();
|
||||
@ -429,7 +431,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
|
||||
speechFactory = new CitizensSpeechFactory();
|
||||
npcRegistry = new CitizensNPCRegistry(saves, "citizens");
|
||||
traitFactory = new CitizensTraitFactory();
|
||||
traitFactory = new CitizensTraitFactory(this);
|
||||
traitFactory.registerTrait(TraitInfo.create(ShopTrait.class).withSupplier(() -> {
|
||||
return new ShopTrait(shops);
|
||||
}));
|
||||
@ -507,6 +509,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
despawnNPCs(false);
|
||||
ProfileFetcher.reset();
|
||||
Skin.clearCache();
|
||||
|
||||
getServer().getPluginManager().callEvent(new CitizensPreReloadEvent());
|
||||
|
||||
saves.reloadFromSource();
|
||||
|
@ -155,7 +155,7 @@ public class Settings {
|
||||
NPC_SKIN_ROTATION_UPDATE_DEGREES("npc.skins.rotation-update-degrees", 90f),
|
||||
NPC_SKIN_USE_LATEST("npc.skins.use-latest-by-default", false),
|
||||
NPC_SKIN_VIEW_DISTANCE("npc.skins.view-distance", 100D),
|
||||
NPC_WATER_SPEED_MODIFIER("npc.movement.water-speed-modifier", 1.25F),
|
||||
NPC_WATER_SPEED_MODIFIER("npc.movement.water-speed-modifier", 1.15F),
|
||||
PACKET_UPDATE_DELAY("npc.packets.update-delay", 30),
|
||||
PLACEHOLDER_SKIN_UPDATE_FREQUENCY("npc.skins.placeholder-update-frequency-ticks", 5 * 60 * 20),
|
||||
PLAYER_TELEPORT_DELAY("npc.teleport-delay", "npc.delay-player-teleport-ticks", -1),
|
||||
|
@ -98,6 +98,7 @@ import net.citizensnpcs.commands.history.RemoveNPCHistoryItem;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.NPCSelector;
|
||||
import net.citizensnpcs.npc.Template;
|
||||
import net.citizensnpcs.npc.ai.FallingExaminer;
|
||||
import net.citizensnpcs.trait.Age;
|
||||
import net.citizensnpcs.trait.Anchors;
|
||||
import net.citizensnpcs.trait.ArmorStandTrait;
|
||||
@ -641,7 +642,7 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "create [name] ((-b(aby),u(nspawned),s(ilent),t(emporary),c(enter),p(acket)) --at [x:y:z:world] --type [type] --item (item) --trait ['trait1, trait2...'] --nameplate [true|false|hover] --temporaryticks [ticks] --registry [registry name])",
|
||||
usage = "create [name] ((-b(aby),u(nspawned),s(ilent),t(emporary),c(enter),p(acket)) --at [x:y:z:world] --type [type] --item (item) --trait ['trait1, trait2...'] --nameplate [true|false|hover] --temporaryticks [ticks] --registry [registry name]",
|
||||
desc = "Create a new NPC",
|
||||
flags = "bustpc",
|
||||
modifiers = { "create" },
|
||||
@ -1872,7 +1873,10 @@ public class NPCCommands {
|
||||
@Requirements(selected = true, ownership = true)
|
||||
public void packet(CommandContext args, CommandSender sender, NPC npc, @Flag("enabled") Boolean explicit)
|
||||
throws CommandException {
|
||||
if (explicit != null) {
|
||||
if (explicit == null) {
|
||||
explicit = !npc.hasTrait(PacketNPC.class);
|
||||
}
|
||||
|
||||
if (explicit) {
|
||||
npc.getOrAddTrait(PacketNPC.class);
|
||||
Messaging.sendTr(sender, Messages.NPC_PACKET_ENABLED, npc.getName());
|
||||
@ -1881,7 +1885,6 @@ public class NPCCommands {
|
||||
Messaging.sendTr(sender, Messages.NPC_PACKET_DISABLED, npc.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
@ -1900,7 +1903,7 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "pathopt --avoid-water|aw [true|false] --stationary-ticks [ticks] --attack-range [range] --distance-margin [margin] --path-distance-margin [margin] --use-new-finder [true|false]",
|
||||
usage = "pathopt --avoid-water|aw [true|false] --stationary-ticks [ticks] --attack-range [range] --distance-margin [margin] --path-distance-margin [margin] --use-new-finder [true|false] --falling-distance [distance]",
|
||||
desc = "Sets an NPC's pathfinding options",
|
||||
modifiers = { "pathopt", "po", "patho" },
|
||||
min = 1,
|
||||
@ -1909,8 +1912,8 @@ public class NPCCommands {
|
||||
public void pathfindingOptions(CommandContext args, CommandSender sender, NPC npc,
|
||||
@Flag({ "avoid-water" }) Boolean avoidwater, @Flag("stationary-ticks") Integer stationaryTicks,
|
||||
@Flag("distance-margin") Double distanceMargin, @Flag("path-distance-margin") Double pathDistanceMargin,
|
||||
@Flag("attack-range") Double attackRange, @Flag("use-new-finder") Boolean useNewFinder)
|
||||
throws CommandException {
|
||||
@Flag("attack-range") Double attackRange, @Flag("use-new-finder") Boolean useNewFinder,
|
||||
@Flag("falling-distance") Integer fallingDistance) throws CommandException {
|
||||
String output = "";
|
||||
if (avoidwater != null) {
|
||||
npc.getNavigator().getDefaultParameters().avoidWater(avoidwater);
|
||||
@ -1947,6 +1950,10 @@ public class NPCCommands {
|
||||
npc.getNavigator().getDefaultParameters().useNewPathfinder(useNewFinder);
|
||||
output += Messaging.tr(Messages.PATHFINDING_OPTIONS_USE_NEW_FINDER, npc.getName(), useNewFinder);
|
||||
}
|
||||
if (fallingDistance != null) {
|
||||
npc.getNavigator().getDefaultParameters().examiner(new FallingExaminer(fallingDistance));
|
||||
output += Messaging.tr(Messages.PATHFINDING_OPTIONS_FALLING_DISTANCE_SET, npc.getName(), fallingDistance);
|
||||
}
|
||||
if (output.isEmpty()) {
|
||||
throw new CommandUsageException();
|
||||
} else {
|
||||
|
@ -27,6 +27,7 @@ import net.citizensnpcs.NPCNeedsRespawnEvent;
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.ai.Navigator;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.SwimmingExaminer;
|
||||
import net.citizensnpcs.api.event.DespawnReason;
|
||||
import net.citizensnpcs.api.event.NPCDespawnEvent;
|
||||
@ -478,8 +479,10 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
}
|
||||
|
||||
boolean canSwim = data().get(NPC.Metadata.SWIMMING, SwimmingExaminer.isWaterMob(getEntity()));
|
||||
boolean inLiquid = MinecraftBlockExaminer.isLiquid(getEntity().getLocation().getBlock().getType());
|
||||
if (navigator.isNavigating()) {
|
||||
if (data().get(NPC.Metadata.SWIMMING, true)) {
|
||||
if (canSwim && inLiquid) {
|
||||
getEntity().setVelocity(getEntity().getVelocity().multiply(
|
||||
data().get(NPC.Metadata.WATER_SPEED_MODIFIER, Setting.NPC_WATER_SPEED_MODIFIER.asFloat())));
|
||||
Location currentDest = navigator.getPathStrategy().getCurrentDestination();
|
||||
@ -487,7 +490,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
NMS.trySwim(getEntity());
|
||||
}
|
||||
}
|
||||
} else if (data().<Boolean> get(NPC.Metadata.SWIMMING, !SwimmingExaminer.isWaterMob(getEntity()))) {
|
||||
} else if (canSwim && inLiquid) {
|
||||
Gravity trait = getTraitNullable(Gravity.class);
|
||||
if (trait == null || trait.hasGravity()) {
|
||||
NMS.trySwim(getEntity());
|
||||
@ -538,14 +541,14 @@ public class CitizensNPC extends AbstractNPC {
|
||||
SUPPORT_PICKUP_ITEMS = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isLiving && getEntity() instanceof Player) {
|
||||
if (getEntity() instanceof Player) {
|
||||
updateUsingItemState((Player) getEntity());
|
||||
if (data().has(NPC.Metadata.SNEAKING) && !hasTrait(SneakTrait.class)) {
|
||||
addTrait(SneakTrait.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
navigator.run();
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.Citizens;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitFactory;
|
||||
@ -66,7 +67,7 @@ public class CitizensTraitFactory implements TraitFactory {
|
||||
private final List<TraitInfo> defaultTraits = Lists.newArrayList();
|
||||
private final Map<String, TraitInfo> registered = Maps.newHashMap();
|
||||
|
||||
public CitizensTraitFactory() {
|
||||
public CitizensTraitFactory(Citizens plugin) {
|
||||
registerTrait(TraitInfo.create(Age.class));
|
||||
registerTrait(TraitInfo.create(ArmorStandTrait.class));
|
||||
registerTrait(TraitInfo.create(Anchors.class));
|
||||
|
@ -1,22 +1,21 @@
|
||||
package net.citizensnpcs.npc.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.NeighbourGeneratorBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.PathPoint;
|
||||
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
|
||||
public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
|
||||
private final Map<PathPoint, Integer> fallen = Maps.newHashMap();
|
||||
public class FallingExaminer implements BlockExaminer {
|
||||
private final Map<PathPoint, Integer> fall = Maps.newHashMap();
|
||||
private final int maxFallDistance;
|
||||
private final MinecraftBlockExaminer mc = new MinecraftBlockExaminer();
|
||||
|
||||
public FallingExaminer(int maxFallDistance) {
|
||||
this.maxFallDistance = maxFallDistance;
|
||||
@ -24,36 +23,31 @@ public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
|
||||
|
||||
@Override
|
||||
public float getCost(BlockSource source, PathPoint point) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PathPoint> getNeighbours(BlockSource source, PathPoint point) {
|
||||
Vector pos = point.getVector();
|
||||
List<PathPoint> neighbours = ((VectorNode) point).getNeighbours(source, point);
|
||||
if (!SpigotUtil.checkYSafe(pos.getBlockY() + 1, source.getWorld()))
|
||||
return neighbours;
|
||||
|
||||
if (!MinecraftBlockExaminer
|
||||
.canStandOn(source.getBlockAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ()))) {
|
||||
Integer dist = fallen.get(point);
|
||||
if (dist == null) {
|
||||
neighbours.add(point);
|
||||
fallen.put(point, dist = 0);
|
||||
} else if (dist < maxFallDistance) {
|
||||
fallen.put(point, dist + 1);
|
||||
neighbours.add(point.createAtOffset(new Vector(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ())));
|
||||
}
|
||||
} else {
|
||||
fallen.remove(point);
|
||||
}
|
||||
return neighbours;
|
||||
return fall.containsKey(point) ? 0.25f : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PassableState isPassable(BlockSource source, PathPoint point) {
|
||||
if (fallen.containsKey(point)) {
|
||||
Vector pos = point.getVector();
|
||||
if (!SpigotUtil.checkYSafe(pos.getBlockY() - 1, source.getWorld()))
|
||||
return PassableState.IGNORE;
|
||||
|
||||
if (fall.containsKey(point))
|
||||
return PassableState.PASSABLE;
|
||||
|
||||
if (!MinecraftBlockExaminer
|
||||
.canStandOn(source.getBlockAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ()))) {
|
||||
Integer dist = fall.get(point.getParentPoint());
|
||||
if (dist == null && mc.isPassable(source, point.getParentPoint()) == PassableState.PASSABLE) {
|
||||
// start a fall
|
||||
fall.put(point, 0);
|
||||
return PassableState.PASSABLE;
|
||||
} else if (dist != null && pos.getBlockY() < point.getParentPoint().getVector().getBlockY()
|
||||
&& pos.getBlockX() == point.getParentPoint().getVector().getBlockX()
|
||||
&& pos.getBlockZ() == point.getParentPoint().getVector().getBlockZ() && dist < maxFallDistance) {
|
||||
fall.put(point, dist + 1);
|
||||
return PassableState.PASSABLE;
|
||||
}
|
||||
}
|
||||
return PassableState.IGNORE;
|
||||
}
|
||||
|
@ -60,6 +60,13 @@ public class ProfileFetcher {
|
||||
initThread();
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
if (THREAD_TASK != null) {
|
||||
THREAD_TASK.cancel();
|
||||
THREAD_TASK = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static ProfileFetchThread PROFILE_THREAD;
|
||||
private static BukkitTask THREAD_TASK;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.trait;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -15,12 +13,13 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
import net.citizensnpcs.npc.EntityController;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.PlayerUpdateTask;
|
||||
|
||||
@TraitName("packet")
|
||||
public class PacketNPC extends Trait {
|
||||
private EntityPacketTracker playerTracker;
|
||||
private EntityPacketTracker packetTracker;
|
||||
private boolean spawned = false;
|
||||
|
||||
public PacketNPC() {
|
||||
@ -36,7 +35,7 @@ public class PacketNPC extends Trait {
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
playerTracker = NMS.getPlayerTracker(npc.getEntity());
|
||||
packetTracker = NMS.createPacketTracker(npc.getEntity());
|
||||
spawned = true;
|
||||
}
|
||||
|
||||
@ -45,13 +44,13 @@ public class PacketNPC extends Trait {
|
||||
if (!spawned)
|
||||
return;
|
||||
PerPlayerMetadata<Boolean> ppm = CitizensAPI.getLocationLookup().registerMetadata("packetnpc", null);
|
||||
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(npc.getStoredLocation(), 64)) {
|
||||
for (Player nearby : CitizensAPI.getLocationLookup().getNearbyPlayers(npc)) {
|
||||
if (!ppm.has(nearby.getUniqueId(), npc.getUniqueId().toString())) {
|
||||
playerTracker.link(nearby);
|
||||
packetTracker.link(nearby);
|
||||
ppm.set(nearby.getUniqueId(), npc.getUniqueId().toString(), true);
|
||||
}
|
||||
}
|
||||
playerTracker.run();
|
||||
packetTracker.run();
|
||||
}
|
||||
|
||||
public EntityController wrap(EntityController controller) {
|
||||
@ -61,14 +60,6 @@ public class PacketNPC extends Trait {
|
||||
return controller;
|
||||
}
|
||||
|
||||
public static interface EntityPacketTracker extends Runnable {
|
||||
public void link(Player player);
|
||||
|
||||
public void unlink(Player player);
|
||||
|
||||
public void unlinkAll(Consumer<Player> callback);
|
||||
}
|
||||
|
||||
private class PacketController implements EntityController {
|
||||
private final EntityController base;
|
||||
|
||||
@ -88,7 +79,7 @@ public class PacketNPC extends Trait {
|
||||
return;
|
||||
PlayerUpdateTask.deregisterPlayer(getBukkitEntity());
|
||||
PerPlayerMetadata<Boolean> ppm = CitizensAPI.getLocationLookup().registerMetadata("packetnpc", null);
|
||||
playerTracker.unlinkAll(player -> ppm.remove(player.getUniqueId(), npc.getUniqueId().toString()));
|
||||
packetTracker.unlinkAll(player -> ppm.remove(player.getUniqueId(), npc.getUniqueId().toString()));
|
||||
spawned = false;
|
||||
}
|
||||
|
||||
@ -103,14 +94,14 @@ public class PacketNPC extends Trait {
|
||||
return;
|
||||
PlayerUpdateTask.deregisterPlayer(getBukkitEntity());
|
||||
PerPlayerMetadata<Boolean> ppm = CitizensAPI.getLocationLookup().registerMetadata("packetnpc", null);
|
||||
playerTracker.unlinkAll(player -> ppm.remove(player.getUniqueId(), npc.getUniqueId().toString()));
|
||||
packetTracker.unlinkAll(player -> ppm.remove(player.getUniqueId(), npc.getUniqueId().toString()));
|
||||
base.remove();
|
||||
spawned = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location at) {
|
||||
base.getBukkitEntity().teleport(at);
|
||||
NMS.setLocationDirectly(base.getBukkitEntity(), at);
|
||||
PlayerUpdateTask.registerPlayer(getBukkitEntity());
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package net.citizensnpcs.util;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface EntityPacketTracker extends Runnable {
|
||||
public void link(Player player);
|
||||
|
||||
public void unlink(Player player);
|
||||
|
||||
public void unlinkAll(Consumer<Player> callback);
|
||||
}
|
@ -303,6 +303,7 @@ public class Messages {
|
||||
public static final String PATHFINDING_OPTIONS_AVOID_WATER_SET = "citizens.commands.npc.pathopt.avoid-water-set";
|
||||
public static final String PATHFINDING_OPTIONS_AVOID_WATER_UNSET = "citizens.commands.npc.pathopt.avoid-water-unset";
|
||||
public static final String PATHFINDING_OPTIONS_DISTANCE_MARGIN_SET = "citizens.commands.npc.pathopt.distance-margin-set";
|
||||
public static final String PATHFINDING_OPTIONS_FALLING_DISTANCE_SET = "citizens.commands.npc.pathopt.falling-distance-set";
|
||||
public static final String PATHFINDING_OPTIONS_PATH_DISTANCE_MARGIN_SET = "citizens.commands.npc.pathopt.path-distance-margin-set";
|
||||
public static final String PATHFINDING_OPTIONS_STATIONARY_TICKS_SET = "citizens.commands.npc.pathopt.stationary-ticks-set";
|
||||
public static final String PATHFINDING_OPTIONS_USE_NEW_FINDER = "citizens.commands.npc.pathopt.use-new-finder";
|
||||
|
@ -51,7 +51,6 @@ import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose;
|
||||
|
||||
public class NMS {
|
||||
@ -375,7 +374,7 @@ public class NMS {
|
||||
return BRIDGE.getPassengers(entity);
|
||||
}
|
||||
|
||||
public static EntityPacketTracker getPlayerTracker(Entity entity) {
|
||||
public static EntityPacketTracker createPacketTracker(Entity entity) {
|
||||
return BRIDGE.createPacketTracker(entity);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ import net.citizensnpcs.api.util.EntityDim;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose;
|
||||
|
||||
public interface NMSBridge {
|
||||
|
@ -213,6 +213,7 @@ citizens.commands.npc.pathopt.distance-margin-set=[[{0}]]''s pathfinding distanc
|
||||
citizens.commands.npc.pathopt.path-distance-margin-set=[[{0}]]''s pathfinding path distance margin set to [[{1}]].
|
||||
citizens.commands.npc.pathopt.attack-range-set=[[{0}]]''s attack range set to [[{1}]].
|
||||
citizens.commands.npc.pathopt.use-new-finder=[[{0}]]''s use new finder set to [[{1}]].
|
||||
citizens.commands.npc.pathopt.falling-distance-set=[[{0}]]''s falling distance set to [[{1}]].
|
||||
citizens.commands.npc.pausepathfinding.pause-range-set=[{0}]] will now pause pathfinding when a player is within [[{1}]] blocks.
|
||||
citizens.commands.npc.pausepathfinding.pause-ticks-set=[[{0}]] will now pause pathfinding for [[{1}]] ticks at a time.
|
||||
citizens.commands.npc.pausepathfinding.rightclick-set=[[{0}]] will now pause pathfinding on right click.
|
||||
|
@ -34,10 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
NMSImpl.clearGoals(((EntityInsentient) entity).goalSelector, ((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -51,6 +50,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
|
||||
@ -180,6 +179,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
|
@ -34,10 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
NMSImpl.clearGoals(((EntityInsentient) entity).goalSelector, ((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -51,6 +50,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
|
||||
@ -197,6 +196,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
|
@ -34,10 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
NMSImpl.clearGoals(((EntityInsentient) entity).goalSelector, ((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -51,6 +50,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
|
||||
@ -200,6 +199,7 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
|
@ -34,10 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
NMSImpl.clearGoals(((EntityInsentient) entity).goalSelector, ((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -51,6 +50,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
|
||||
@ -214,6 +213,7 @@ import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1700,6 +1700,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
double mx = entity.motX;
|
||||
double my = entity.motY;
|
||||
double mz = entity.motZ;
|
||||
|
@ -36,10 +36,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
NMSImpl.clearGoals(((EntityInsentient) entity).goalSelector, ((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -53,6 +52,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
||||
@ -224,6 +223,7 @@ import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1778,6 +1778,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
Vec3D old = entity.getMot().add(0, 0, 0);
|
||||
boolean res = func.get();
|
||||
if (!npc.isPushableByFluids()) {
|
||||
|
@ -37,10 +37,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
NMSImpl.clearGoals(npc, ((EntityInsentient) entity).goalSelector,
|
||||
((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -54,6 +53,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
@ -226,6 +225,7 @@ import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1833,6 +1833,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
Vec3D old = entity.getMot().add(0, 0, 0);
|
||||
boolean res = func.get();
|
||||
if (!npc.isPushableByFluids()) {
|
||||
|
@ -37,10 +37,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
NMSImpl.clearGoals(npc, ((EntityInsentient) entity).goalSelector,
|
||||
((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -54,6 +53,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
@ -233,6 +232,7 @@ import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1857,6 +1857,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
Vec3D old = entity.getMot().add(0, 0, 0);
|
||||
boolean res = func.get();
|
||||
if (!npc.isPushableByFluids()) {
|
||||
|
@ -32,6 +32,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
net.minecraft.world.entity.Entity entity = createEntityFromClass(type, ((CraftWorld) at.getWorld()).getHandle(),
|
||||
npc);
|
||||
entity.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
if (entity instanceof Mob) {
|
||||
NMSImpl.clearGoals(npc, ((Mob) entity).goalSelector, ((Mob) entity).targetSelector);
|
||||
}
|
||||
@ -45,6 +46,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.AxolotlTrait;
|
||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
||||
@ -236,6 +235,7 @@ import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1851,6 +1851,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
Vec3 old = entity.getDeltaMovement().add(0, 0, 0);
|
||||
boolean res = func.get();
|
||||
if (!npc.isPushableByFluids()) {
|
||||
|
@ -34,9 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof Mob) {
|
||||
NMSImpl.clearGoals(npc, ((Mob) entity).goalSelector, ((Mob) entity).targetSelector);
|
||||
}
|
||||
entity.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround isn't updated
|
||||
// right away - we approximate
|
||||
// here so
|
||||
entity.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updatedright away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -46,6 +46,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.AxolotlTrait;
|
||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
||||
@ -237,6 +236,7 @@ import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1856,6 +1856,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
Vec3 old = entity.getDeltaMovement().add(0, 0, 0);
|
||||
boolean res = func.get();
|
||||
if (!npc.isPushableByFluids()) {
|
||||
|
@ -34,9 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof Mob) {
|
||||
NMSImpl.clearGoals(npc, ((Mob) entity).goalSelector, ((Mob) entity).targetSelector);
|
||||
}
|
||||
entity.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround isn't updated
|
||||
// right away - we approximate
|
||||
// here so
|
||||
entity.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -46,6 +46,8 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,6 @@ import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.MirrorTrait;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.trait.versioned.AllayTrait;
|
||||
import net.citizensnpcs.trait.versioned.AxolotlTrait;
|
||||
@ -252,6 +251,7 @@ import net.citizensnpcs.trait.versioned.SpellcasterTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -1985,6 +1985,9 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
public static boolean fluidPush(NPC npc, Entity entity, Supplier<Boolean> func) {
|
||||
if (npc == null) {
|
||||
return func.get();
|
||||
}
|
||||
Vec3 old = entity.getDeltaMovement().add(0, 0, 0);
|
||||
boolean res = func.get();
|
||||
if (!npc.isPushableByFluids()) {
|
||||
|
@ -4,10 +4,12 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_8_R3.util.NMSImpl;
|
||||
@ -32,10 +34,9 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
NMSImpl.clearGoals(((EntityInsentient) entity).goalSelector, ((EntityInsentient) entity).targetSelector);
|
||||
}
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); // entity.onGround
|
||||
// isn't updated right
|
||||
// away - we
|
||||
// approximate here so
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
if (npc != null) {
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isSolid()) {
|
||||
@ -49,6 +50,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -51,6 +52,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.plugin.PluginLoadOrder;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -65,6 +67,7 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.LocationLookup.PerPlayerMetadata;
|
||||
@ -159,9 +162,9 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.PacketNPC.EntityPacketTracker;
|
||||
import net.citizensnpcs.trait.RotationTrait;
|
||||
import net.citizensnpcs.util.EmptyChannel;
|
||||
import net.citizensnpcs.util.EntityPacketTracker;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
|
Loading…
Reference in New Issue
Block a user