mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 03:25:13 +01:00
Remove some usage of NMS, talk-item for text trait should default to the setting always and not save if unmodified
This commit is contained in:
parent
6ee3c65614
commit
910f806763
@ -2,6 +2,7 @@ package net.citizensnpcs;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.citizensnpcs.Settings.Setting;
|
import net.citizensnpcs.Settings.Setting;
|
||||||
@ -51,6 +52,8 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
import com.google.common.io.InputSupplier;
|
||||||
|
|
||||||
public class Citizens extends JavaPlugin implements CitizensPlugin {
|
public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||||
private final CommandManager commands = new CommandManager();
|
private final CommandManager commands = new CommandManager();
|
||||||
@ -67,9 +70,9 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
NPC npc = itr.next();
|
NPC npc = itr.next();
|
||||||
try {
|
try {
|
||||||
npc.despawn();
|
npc.despawn();
|
||||||
for (Trait t : npc.getTraits())
|
for (Trait trait : npc.getTraits())
|
||||||
t.onRemove();
|
trait.onRemove();
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// ensure that all entities are despawned
|
// ensure that all entities are despawned
|
||||||
}
|
}
|
||||||
@ -77,6 +80,23 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
getDataFolder().mkdirs();
|
||||||
|
final InputStream dllResource = getResource("path/to/dll");
|
||||||
|
try {
|
||||||
|
Files.copy(new InputSupplier<InputStream>() {
|
||||||
|
@Override
|
||||||
|
public InputStream getInput() throws IOException {
|
||||||
|
return dllResource;
|
||||||
|
}
|
||||||
|
}, new File(getDataFolder(), "name.dll"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// code here
|
||||||
|
new File(getDataFolder(), "name.dll").delete();
|
||||||
|
}
|
||||||
|
|
||||||
private void enableSubPlugins() {
|
private void enableSubPlugins() {
|
||||||
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
|
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
|
||||||
if (!root.exists() || !root.isDirectory())
|
if (!root.exists() || !root.isDirectory())
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_4_5.CraftServer;
|
import org.bukkit.craftbukkit.v1_4_5.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_4_5.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_4_5.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -105,7 +106,7 @@ public class EventListen implements Listener {
|
|||||||
return;
|
return;
|
||||||
if (event.getFrom().getWorld() == event.getTo().getWorld() || !npcRegistry.isNPC(event.getEntity()))
|
if (event.getFrom().getWorld() == event.getTo().getWorld() || !npcRegistry.isNPC(event.getEntity()))
|
||||||
return;
|
return;
|
||||||
NMS.updateNavigationWorld(event.getEntity(), event.getTo().getWorld());
|
NMS.updateNavigationWorld((LivingEntity) event.getEntity(), event.getTo().getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,10 +8,11 @@ import net.citizensnpcs.api.npc.NPCRegistry;
|
|||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.ByIdArray;
|
import net.citizensnpcs.util.ByIdArray;
|
||||||
|
import net.citizensnpcs.util.NMS;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
public class CitizensNPCRegistry implements NPCRegistry {
|
public class CitizensNPCRegistry implements NPCRegistry {
|
||||||
private final ByIdArray<NPC> npcs = new ByIdArray<NPC>();
|
private final ByIdArray<NPC> npcs = new ByIdArray<NPC>();
|
||||||
@ -80,7 +81,9 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
|||||||
return null;
|
return null;
|
||||||
if (entity instanceof NPCHolder)
|
if (entity instanceof NPCHolder)
|
||||||
return ((NPCHolder) entity).getNPC();
|
return ((NPCHolder) entity).getNPC();
|
||||||
net.minecraft.server.v1_4_5.Entity handle = ((CraftEntity) entity).getHandle();
|
if (!(entity instanceof LivingEntity))
|
||||||
|
return null;
|
||||||
|
Object handle = NMS.getHandle((LivingEntity) entity);
|
||||||
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
|
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,14 @@ import net.citizensnpcs.api.astar.pathfinder.Path;
|
|||||||
import net.citizensnpcs.api.astar.pathfinder.VectorGoal;
|
import net.citizensnpcs.api.astar.pathfinder.VectorGoal;
|
||||||
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
|
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
|
import net.citizensnpcs.util.Messaging;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.minecraft.server.v1_4_5.EntityLiving;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class AStarNavigationStrategy extends AbstractPathStrategy {
|
public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||||
@ -57,15 +61,24 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
if (plan.isComplete())
|
if (plan.isComplete())
|
||||||
return true;
|
return true;
|
||||||
vector = plan.getCurrentVector();
|
vector = plan.getCurrentVector();
|
||||||
npc.getBukkitEntity()
|
World world = npc.getBukkitEntity().getWorld();
|
||||||
.getWorld()
|
world.playEffect(vector.toLocation(world), Effect.STEP_SOUND, Material.STONE.getId());
|
||||||
.playEffect(vector.toLocation(npc.getBukkitEntity().getWorld()), Effect.STEP_SOUND,
|
|
||||||
org.bukkit.Material.STONE.getId());
|
|
||||||
}
|
}
|
||||||
|
EntityLiving handle = NMS.getHandle(npc.getBukkitEntity());
|
||||||
|
double dX = vector.getBlockX() - handle.locX;
|
||||||
|
double dZ = vector.getBlockZ() - handle.locZ;
|
||||||
|
double dY = vector.getY() - Math.floor(handle.boundingBox.b + 0.5D);
|
||||||
|
double dXdZ = dX * dX + dZ * dZ;
|
||||||
|
double distance = dXdZ + dY * dY;
|
||||||
|
|
||||||
|
if (distance >= 0.00001 && (dY > 0 && dXdZ <= 2.75))
|
||||||
|
NMS.setShouldJump(npc.getBukkitEntity());
|
||||||
|
else
|
||||||
|
Messaging.log(distance >= 0.0001, dY > 0, dXdZ < 1, dXdZ);
|
||||||
NMS.setDestination(npc.getBukkitEntity(), vector.getX(), vector.getY(), vector.getZ(), params.speed());
|
NMS.setDestination(npc.getBukkitEntity(), vector.getX(), vector.getY(), vector.getZ(), params.speed());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final AStarMachine ASTAR = AStarMachine.createWithDefaultStorage();
|
private static final AStarMachine<VectorNode, Path> ASTAR = AStarMachine.createWithDefaultStorage();
|
||||||
private static final Location NPC_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location NPC_LOCATION = new Location(null, 0, 0, 0);
|
||||||
}
|
}
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -73,7 +73,7 @@ public class BatController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -71,7 +71,7 @@ public class BlazeController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -80,7 +80,7 @@ public class CaveSpiderController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -70,7 +70,7 @@ public class ChickenController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -70,7 +70,7 @@ public class CowController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -77,7 +77,7 @@ public class CreeperController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -77,7 +77,7 @@ public class EnderDragonController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -90,7 +90,7 @@ public class EndermanController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,10 +16,12 @@ import net.citizensnpcs.util.Util;
|
|||||||
import net.minecraft.server.v1_4_5.EntityPlayer;
|
import net.minecraft.server.v1_4_5.EntityPlayer;
|
||||||
import net.minecraft.server.v1_4_5.EnumGamemode;
|
import net.minecraft.server.v1_4_5.EnumGamemode;
|
||||||
import net.minecraft.server.v1_4_5.ItemInWorldManager;
|
import net.minecraft.server.v1_4_5.ItemInWorldManager;
|
||||||
|
import net.minecraft.server.v1_4_5.MathHelper;
|
||||||
import net.minecraft.server.v1_4_5.MinecraftServer;
|
import net.minecraft.server.v1_4_5.MinecraftServer;
|
||||||
import net.minecraft.server.v1_4_5.Navigation;
|
import net.minecraft.server.v1_4_5.Navigation;
|
||||||
import net.minecraft.server.v1_4_5.NetHandler;
|
import net.minecraft.server.v1_4_5.NetHandler;
|
||||||
import net.minecraft.server.v1_4_5.NetworkManager;
|
import net.minecraft.server.v1_4_5.NetworkManager;
|
||||||
|
import net.minecraft.server.v1_4_5.Packet32EntityLook;
|
||||||
import net.minecraft.server.v1_4_5.Packet5EntityEquipment;
|
import net.minecraft.server.v1_4_5.Packet5EntityEquipment;
|
||||||
import net.minecraft.server.v1_4_5.World;
|
import net.minecraft.server.v1_4_5.World;
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,13 +129,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (getBukkitEntity() != null && Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
if (getBukkitEntity() != null && Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
if (!npc.getNavigator().isNavigating() && !NMS.inWater(this))
|
if (!npc.getNavigator().isNavigating() && !NMS.inWater(getBukkitEntity()))
|
||||||
move(0, -0.2, 0);
|
move(0, -0.2, 0);
|
||||||
// gravity. also works around an entity.onGround not updating issue
|
// gravity. also works around an entity.onGround not updating issue
|
||||||
// (onGround is normally updated by the client)
|
// (onGround is normally updated by the client)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEquipment();
|
updateEquipment();
|
||||||
|
NMS.sendPacketNearby(
|
||||||
|
getBukkitEntity().getLocation(),
|
||||||
|
new Packet32EntityLook(id, (byte) MathHelper.d(yaw * 256.0F / 360.0F), (byte) MathHelper
|
||||||
|
.d(pitch * 256.0F / 360.0F)));
|
||||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON)
|
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON)
|
||||||
motX = motY = motZ = 0;
|
motX = motY = motZ = 0;
|
||||||
|
|
||||||
@ -183,7 +189,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
net.minecraft.server.v1_4_5.ItemStack previous = previousEquipment[i];
|
net.minecraft.server.v1_4_5.ItemStack previous = previousEquipment[i];
|
||||||
net.minecraft.server.v1_4_5.ItemStack current = getEquipment(i);
|
net.minecraft.server.v1_4_5.ItemStack current = getEquipment(i);
|
||||||
if (previous != current) {
|
if (previous != current) {
|
||||||
Util.sendPacketNearby(getBukkitEntity().getLocation(), new Packet5EntityEquipment(id, i,
|
NMS.sendPacketNearby(getBukkitEntity().getLocation(), new Packet5EntityEquipment(id, i,
|
||||||
current));
|
current));
|
||||||
previousEquipment[i] = current;
|
previousEquipment[i] = current;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -57,7 +57,7 @@ public class GhastController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -57,7 +57,7 @@ public class GiantController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -55,7 +55,7 @@ public class IronGolemController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -67,7 +67,7 @@ public class MagmaCubeController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -57,7 +57,7 @@ public class MushroomCowController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class OcelotController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -63,7 +63,7 @@ public class PigController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -67,7 +67,7 @@ public class PigZombieController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class SheepController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -66,7 +66,7 @@ public class SilverfishController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class SkeletonController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -68,7 +68,7 @@ public class SlimeController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class SnowmanController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -66,7 +66,7 @@ public class SpiderController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -57,7 +57,7 @@ public class SquidController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -64,7 +64,7 @@ public class VillagerController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class WitchController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -62,7 +62,7 @@ public class WitherController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class WolfController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.npc.MobEntityController;
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
|
import net.citizensnpcs.npc.MobEntityController;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -56,7 +56,7 @@ public class ZombieController extends MobEntityController {
|
|||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null)
|
||||||
Util.callCollisionEvent(npc, entity);
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
public class Text extends Trait implements Runnable, Toggleable, Listener, ConversationAbandonedListener {
|
public class Text extends Trait implements Runnable, Toggleable, Listener, ConversationAbandonedListener {
|
||||||
private final Map<String, Date> cooldowns = new HashMap<String, Date>();
|
private final Map<String, Date> cooldowns = new HashMap<String, Date>();
|
||||||
private int currentIndex;
|
private int currentIndex;
|
||||||
private String itemInHandPattern = Setting.TALK_ITEM.asString();
|
private String itemInHandPattern = "default";
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
private boolean randomTalker = Setting.DEFAULT_RANDOM_TALKER.asBoolean();
|
private boolean randomTalker = Setting.DEFAULT_RANDOM_TALKER.asBoolean();
|
||||||
private double range = Setting.DEFAULT_TALK_CLOSE_RANGE.asDouble();
|
private double range = Setting.DEFAULT_TALK_CLOSE_RANGE.asDouble();
|
||||||
@ -108,7 +108,9 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
|||||||
public void onRightClick(NPCRightClickEvent event) {
|
public void onRightClick(NPCRightClickEvent event) {
|
||||||
if (!event.getNPC().equals(npc))
|
if (!event.getNPC().equals(npc))
|
||||||
return;
|
return;
|
||||||
if (Util.matchesItemInHand(event.getClicker(), itemInHandPattern) && !shouldTalkClose())
|
String localPattern = itemInHandPattern.equals("default") ? Setting.TALK_ITEM.asString()
|
||||||
|
: itemInHandPattern;
|
||||||
|
if (Util.matchesItemInHand(event.getClicker(), localPattern) && !shouldTalkClose())
|
||||||
sendText(event.getClicker());
|
sendText(event.getClicker());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
|
import net.minecraft.server.v1_4_5.ControllerJump;
|
||||||
import net.minecraft.server.v1_4_5.ControllerLook;
|
import net.minecraft.server.v1_4_5.ControllerLook;
|
||||||
import net.minecraft.server.v1_4_5.DamageSource;
|
import net.minecraft.server.v1_4_5.DamageSource;
|
||||||
import net.minecraft.server.v1_4_5.EnchantmentManager;
|
import net.minecraft.server.v1_4_5.EnchantmentManager;
|
||||||
@ -24,6 +25,7 @@ import net.minecraft.server.v1_4_5.Packet;
|
|||||||
import net.minecraft.server.v1_4_5.PathfinderGoalSelector;
|
import net.minecraft.server.v1_4_5.PathfinderGoalSelector;
|
||||||
import net.minecraft.server.v1_4_5.World;
|
import net.minecraft.server.v1_4_5.World;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -48,6 +50,35 @@ public class NMS {
|
|||||||
// util class
|
// util class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendToOnline(Packet... packets) {
|
||||||
|
Validate.notNull(packets, "packets cannot be null");
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (player == null || !player.isOnline())
|
||||||
|
continue;
|
||||||
|
for (Packet packet : packets) {
|
||||||
|
sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPacketNearby(Location location, Packet packet, double radius) {
|
||||||
|
radius *= radius;
|
||||||
|
final org.bukkit.World world = location.getWorld();
|
||||||
|
for (Player ply : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
if (ply == null || world != ply.getWorld()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (location.distanceSquared(ply.getLocation()) > radius) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sendPacket(ply, packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPacketNearby(Location location, Packet packet) {
|
||||||
|
NMS.sendPacketNearby(location, packet, 64);
|
||||||
|
}
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 0.4F;
|
private static final float DEFAULT_SPEED = 0.4F;
|
||||||
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
||||||
private static final Map<Class<?>, Constructor<?>> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap<Class<?>, Constructor<?>>();
|
private static final Map<Class<?>, Constructor<?>> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap<Class<?>, Constructor<?>>();
|
||||||
@ -67,7 +98,7 @@ public class NMS {
|
|||||||
public static void addOrRemoveFromPlayerList(LivingEntity bukkitEntity, boolean remove) {
|
public static void addOrRemoveFromPlayerList(LivingEntity bukkitEntity, boolean remove) {
|
||||||
if (bukkitEntity == null)
|
if (bukkitEntity == null)
|
||||||
return;
|
return;
|
||||||
EntityLiving handle = ((CraftLivingEntity) bukkitEntity).getHandle();
|
EntityLiving handle = getHandle(bukkitEntity);
|
||||||
if (handle.world == null)
|
if (handle.world == null)
|
||||||
return;
|
return;
|
||||||
if (remove) {
|
if (remove) {
|
||||||
@ -149,6 +180,10 @@ public class NMS {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityLiving getHandle(LivingEntity entity) {
|
||||||
|
return ((CraftLivingEntity) entity).getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
public static float getSpeedFor(NPC npc) {
|
public static float getSpeedFor(NPC npc) {
|
||||||
EntityType entityType = npc.getBukkitEntity().getType();
|
EntityType entityType = npc.getBukkitEntity().getType();
|
||||||
Float cached = MOVEMENT_SPEEDS.get(entityType);
|
Float cached = MOVEMENT_SPEEDS.get(entityType);
|
||||||
@ -168,7 +203,8 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean inWater(Entity mcEntity) {
|
public static boolean inWater(LivingEntity entity) {
|
||||||
|
EntityLiving mcEntity = getHandle(entity);
|
||||||
return mcEntity.I() || mcEntity.J();
|
return mcEntity.I() || mcEntity.J();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +216,8 @@ public class NMS {
|
|||||||
controllerLook.a(target, 10.0F, handle.bp());
|
controllerLook.a(target, 10.0F, handle.bp());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void look(EntityLiving handle, float yaw, float pitch) {
|
public static void look(LivingEntity bukkitEntity, float yaw, float pitch) {
|
||||||
|
EntityLiving handle = getHandle(bukkitEntity);
|
||||||
handle.yaw = handle.ay = yaw;
|
handle.yaw = handle.ay = yaw;
|
||||||
handle.pitch = pitch;
|
handle.pitch = pitch;
|
||||||
}
|
}
|
||||||
@ -222,6 +259,11 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setShouldJump(LivingEntity entity) {
|
||||||
|
ControllerJump controller = getHandle(entity).getControllerJump();
|
||||||
|
controller.a();
|
||||||
|
}
|
||||||
|
|
||||||
public static org.bukkit.entity.Entity spawnCustomEntity(org.bukkit.World world, Location at,
|
public static org.bukkit.entity.Entity spawnCustomEntity(org.bukkit.World world, Location at,
|
||||||
Class<? extends Entity> clazz, EntityType type) {
|
Class<? extends Entity> clazz, EntityType type) {
|
||||||
World handle = ((CraftWorld) world).getHandle();
|
World handle = ((CraftWorld) world).getHandle();
|
||||||
@ -248,14 +290,15 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void trySwim(Entity handle, float power) {
|
public static void trySwim(LivingEntity handle) {
|
||||||
if (RANDOM.nextFloat() < 0.8F && inWater(handle)) {
|
trySwim(handle, 0.04F);
|
||||||
handle.motY += power;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void trySwim(org.bukkit.entity.Entity handle) {
|
public static void trySwim(LivingEntity entity, float power) {
|
||||||
trySwim(((CraftEntity) handle).getHandle(), 0.04F);
|
Entity handle = getHandle(entity);
|
||||||
|
if (RANDOM.nextFloat() < 0.8F && inWater(entity)) {
|
||||||
|
handle.motY += power;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateAI(EntityLiving entity) {
|
public static void updateAI(EntityLiving entity) {
|
||||||
@ -266,8 +309,8 @@ public class NMS {
|
|||||||
entity.getControllerJump().b();
|
entity.getControllerJump().b();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateNavigationWorld(org.bukkit.entity.Entity entity, org.bukkit.World world) {
|
public static void updateNavigationWorld(LivingEntity entity, org.bukkit.World world) {
|
||||||
if (NAVIGATION_WORLD_FIELD == null || !(entity instanceof LivingEntity))
|
if (NAVIGATION_WORLD_FIELD == null)
|
||||||
return;
|
return;
|
||||||
EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
|
EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
|
||||||
World worldHandle = ((CraftWorld) world).getHandle();
|
World worldHandle = ((CraftWorld) world).getHandle();
|
||||||
|
@ -81,6 +81,6 @@ public enum PlayerAnimation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void sendPacketNearby(Packet packet, EntityPlayer player, int radius) {
|
protected void sendPacketNearby(Packet packet, EntityPlayer player, int radius) {
|
||||||
Util.sendPacketNearby(player.getBukkitEntity().getLocation(), packet, radius);
|
NMS.sendPacketNearby(player.getBukkitEntity().getLocation(), packet, radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,13 @@ import java.util.Random;
|
|||||||
import net.citizensnpcs.api.event.NPCCollisionEvent;
|
import net.citizensnpcs.api.event.NPCCollisionEvent;
|
||||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.minecraft.server.v1_4_5.EntityLiving;
|
|
||||||
import net.minecraft.server.v1_4_5.Packet;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_4_5.entity.CraftLivingEntity;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -32,15 +28,15 @@ public class Util {
|
|||||||
|
|
||||||
private static Class<?> RNG_CLASS = null;
|
private static Class<?> RNG_CLASS = null;
|
||||||
|
|
||||||
public static void assumePose(org.bukkit.entity.Entity entity, float yaw, float pitch) {
|
public static void assumePose(LivingEntity entity, float yaw, float pitch) {
|
||||||
EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
|
NMS.look(entity, yaw, pitch);
|
||||||
NMS.look(handle, yaw, pitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callCollisionEvent(NPC npc, net.minecraft.server.v1_4_5.Entity entity) {
|
public static void callCollisionEvent(NPC npc, Entity entity) {
|
||||||
if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length > 0)
|
if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length > 0)
|
||||||
Bukkit.getPluginManager().callEvent(new NPCCollisionEvent(npc, entity.getBukkitEntity()));
|
Bukkit.getPluginManager().callEvent(new NPCCollisionEvent(npc, entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NPCPushEvent callPushEvent(NPC npc, Vector vector) {
|
public static NPCPushEvent callPushEvent(NPC npc, Vector vector) {
|
||||||
NPCPushEvent event = new NPCPushEvent(npc, vector);
|
NPCPushEvent event = new NPCPushEvent(npc, vector);
|
||||||
event.setCancelled(npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
|
event.setCancelled(npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
|
||||||
@ -48,7 +44,7 @@ public class Util {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void faceEntity(Entity from, Entity at) {
|
public static void faceEntity(LivingEntity from, LivingEntity at) {
|
||||||
if (from.getWorld() != at.getWorld())
|
if (from.getWorld() != at.getWorld())
|
||||||
return;
|
return;
|
||||||
double xDiff, yDiff, zDiff;
|
double xDiff, yDiff, zDiff;
|
||||||
@ -66,8 +62,7 @@ public class Util {
|
|||||||
if (zDiff < 0.0)
|
if (zDiff < 0.0)
|
||||||
yaw += Math.abs(180 - yaw) * 2;
|
yaw += Math.abs(180 - yaw) * 2;
|
||||||
|
|
||||||
EntityLiving handle = ((CraftLivingEntity) from).getHandle();
|
NMS.look(from, (float) yaw - 90, (float) pitch);
|
||||||
NMS.look(handle, (float) yaw - 90, (float) pitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Random getFastRandom() {
|
public static Random getFastRandom() {
|
||||||
@ -130,35 +125,6 @@ public class Util {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPacketNearby(Location location, Packet packet) {
|
|
||||||
sendPacketNearby(location, packet, 64);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPacketNearby(Location location, Packet packet, double radius) {
|
|
||||||
radius *= radius;
|
|
||||||
final World world = location.getWorld();
|
|
||||||
for (Player ply : Bukkit.getServer().getOnlinePlayers()) {
|
|
||||||
if (ply == null || world != ply.getWorld()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (location.distanceSquared(ply.getLocation()) > radius) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
NMS.sendPacket(ply, packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendToOnline(Packet... packets) {
|
|
||||||
Validate.notNull(packets, "packets cannot be null");
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
if (player == null || !player.isOnline())
|
|
||||||
continue;
|
|
||||||
for (Packet packet : packets) {
|
|
||||||
NMS.sendPacket(player, packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
RNG_CLASS = Class.forName("org.uncommons.maths.random.XORShiftRNG");
|
RNG_CLASS = Class.forName("org.uncommons.maths.random.XORShiftRNG");
|
||||||
|
Loading…
Reference in New Issue
Block a user