mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-19 22:03:12 +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.PlayerControllerJump;
|
||||||
import net.citizensnpcs.util.nms.PlayerControllerLook;
|
import net.citizensnpcs.util.nms.PlayerControllerLook;
|
||||||
import net.citizensnpcs.util.nms.PlayerControllerMove;
|
import net.citizensnpcs.util.nms.PlayerControllerMove;
|
||||||
import net.citizensnpcs.util.nms.PlayerEntitySenses;
|
|
||||||
import net.citizensnpcs.util.nms.PlayerNavigation;
|
import net.citizensnpcs.util.nms.PlayerNavigation;
|
||||||
import net.minecraft.server.v1_6_R2.AttributeInstance;
|
import net.minecraft.server.v1_6_R2.AttributeInstance;
|
||||||
import net.minecraft.server.v1_6_R2.Connection;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
|
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.craftbukkit.v1_6_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -49,14 +47,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
private PlayerControllerJump controllerJump;
|
private PlayerControllerJump controllerJump;
|
||||||
private PlayerControllerLook controllerLook;
|
private PlayerControllerLook controllerLook;
|
||||||
private PlayerControllerMove controllerMove;
|
private PlayerControllerMove controllerMove;
|
||||||
private PlayerEntitySenses entitySenses;
|
|
||||||
private boolean gravity = true;
|
private boolean gravity = true;
|
||||||
private int jumpTicks = 0;
|
private int jumpTicks = 0;
|
||||||
private PlayerNavigation navigation;
|
private PlayerNavigation navigation;
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
||||||
private int packetUpdateCount;
|
private int packetUpdateCount;
|
||||||
private int sensesUpdateCount = 0;
|
|
||||||
private int useListName = -1;
|
private int useListName = -1;
|
||||||
|
|
||||||
public EntityHumanNPC(MinecraftServer minecraftServer, World world, String string,
|
public EntityHumanNPC(MinecraftServer minecraftServer, World world, String string,
|
||||||
@ -75,8 +71,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
// this method is called by both the entities involved - cancelling
|
// this method is called by both the entities involved - cancelling
|
||||||
// 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.getBukkitEntity());
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -153,7 +150,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
controllerJump = new PlayerControllerJump(this);
|
controllerJump = new PlayerControllerJump(this);
|
||||||
controllerLook = new PlayerControllerLook(this);
|
controllerLook = new PlayerControllerLook(this);
|
||||||
controllerMove = new PlayerControllerMove(this);
|
controllerMove = new PlayerControllerMove(this);
|
||||||
entitySenses = new PlayerEntitySenses(this);
|
|
||||||
navigation = new PlayerNavigation(this, world);
|
navigation = new PlayerNavigation(this, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,10 +231,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateAI() {
|
public void updateAI() {
|
||||||
if (++sensesUpdateCount == 5) {
|
|
||||||
sensesUpdateCount = 0;
|
|
||||||
entitySenses.a();
|
|
||||||
}
|
|
||||||
controllerMove.c();
|
controllerMove.c();
|
||||||
controllerLook.a();
|
controllerLook.a();
|
||||||
controllerJump.b();
|
controllerJump.b();
|
||||||
@ -298,11 +290,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasLineOfSight(org.bukkit.entity.Entity other) {
|
|
||||||
return getHandle().entitySenses.canSee(((CraftEntity) other).getHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMetadata(String metadataKey) {
|
public boolean hasMetadata(String metadataKey) {
|
||||||
return cserver.getEntityMetadata().hasMetadata(this, 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