Fix item frame NPCs

This commit is contained in:
fullwall 2015-06-09 01:08:29 +08:00
parent 0af9ab304a
commit f0ee7e7cfa

View File

@ -1,28 +1,41 @@
package net.citizensnpcs.npc.entity.nonliving;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.EntityItemFrame;
import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame;
import org.bukkit.entity.ItemFrame;
import org.bukkit.util.Vector;
public class ItemFrameController extends MobEntityController {
public ItemFrameController() {
super(EntityItemFrameNPC.class);
}
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
@Override
public ItemFrame getBukkitEntity() {
return (ItemFrame) super.getBukkitEntity();
@ -90,6 +103,11 @@ public class ItemFrameController extends MobEntityController {
return npc;
}
@Override
public boolean survives() {
return npc == null || !npc.isProtected() ? super.survives() : true;
}
@Override
public void t_() {
if (npc != null) {
@ -98,11 +116,6 @@ public class ItemFrameController extends MobEntityController {
super.t_();
}
}
@Override
public boolean survives() {
return npc == null || !npc.isProtected() ? super.survives() : true;
}
}
public static class ItemFrameNPC extends CraftItemFrame implements NPCHolder {