mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-30 14:43:54 +01:00
Remove PlayerEntitySenses workaround
This commit is contained in:
parent
8ef0d56bb3
commit
c25a747500
@ -17,7 +17,6 @@ import net.citizensnpcs.util.Util;
|
||||
import net.citizensnpcs.util.nms.PlayerControllerJump;
|
||||
import net.citizensnpcs.util.nms.PlayerControllerLook;
|
||||
import net.citizensnpcs.util.nms.PlayerControllerMove;
|
||||
import net.citizensnpcs.util.nms.PlayerEntitySenses;
|
||||
import net.citizensnpcs.util.nms.PlayerNavigation;
|
||||
import net.minecraft.server.v1_6_R2.AttributeInstance;
|
||||
import net.minecraft.server.v1_6_R2.Connection;
|
||||
@ -39,7 +38,6 @@ import net.minecraft.server.v1_6_R2.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -49,14 +47,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
private PlayerControllerJump controllerJump;
|
||||
private PlayerControllerLook controllerLook;
|
||||
private PlayerControllerMove controllerMove;
|
||||
private PlayerEntitySenses entitySenses;
|
||||
private boolean gravity = true;
|
||||
private int jumpTicks = 0;
|
||||
private PlayerNavigation navigation;
|
||||
private final CitizensNPC npc;
|
||||
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
||||
private int packetUpdateCount;
|
||||
private int sensesUpdateCount = 0;
|
||||
private int useListName = -1;
|
||||
|
||||
public EntityHumanNPC(MinecraftServer minecraftServer, World world, String string,
|
||||
@ -75,9 +71,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
@ -153,7 +150,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
controllerJump = new PlayerControllerJump(this);
|
||||
controllerLook = new PlayerControllerLook(this);
|
||||
controllerMove = new PlayerControllerMove(this);
|
||||
entitySenses = new PlayerEntitySenses(this);
|
||||
navigation = new PlayerNavigation(this, world);
|
||||
}
|
||||
|
||||
@ -235,10 +231,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
}
|
||||
|
||||
public void updateAI() {
|
||||
if (++sensesUpdateCount == 5) {
|
||||
sensesUpdateCount = 0;
|
||||
entitySenses.a();
|
||||
}
|
||||
controllerMove.c();
|
||||
controllerLook.a();
|
||||
controllerJump.b();
|
||||
@ -298,11 +290,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLineOfSight(org.bukkit.entity.Entity other) {
|
||||
return getHandle().entitySenses.canSee(((CraftEntity) other).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return cserver.getEntityMetadata().hasMetadata(this, metadataKey);
|
||||
|
@ -1,38 +0,0 @@
|
||||
package net.citizensnpcs.util.nms;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.v1_6_R2.Entity;
|
||||
import net.minecraft.server.v1_6_R2.EntityLiving;
|
||||
|
||||
public class PlayerEntitySenses {
|
||||
private final EntityLiving entity;
|
||||
private final Set<Entity> seenEntities = new HashSet<Entity>();
|
||||
private final Set<Entity> unseenEntities = new HashSet<Entity>();
|
||||
|
||||
public PlayerEntitySenses(EntityLiving entityinsentient) {
|
||||
this.entity = entityinsentient;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.seenEntities.clear();
|
||||
this.unseenEntities.clear();
|
||||
}
|
||||
|
||||
public boolean canSee(Entity entity) {
|
||||
if (this.seenEntities.contains(entity)) {
|
||||
return true;
|
||||
} else if (this.unseenEntities.contains(entity)) {
|
||||
return false;
|
||||
} else {
|
||||
boolean flag = this.entity.o(entity);
|
||||
if (flag) {
|
||||
this.seenEntities.add(entity);
|
||||
} else {
|
||||
this.unseenEntities.add(entity);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user