Search in sources :

Example 41 with Entity

use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.

the class PlayerlistTrackerEntry method updateLastPlayer.

public void updateLastPlayer() {
    if (lastUpdatedPlayer == null)
        return;
    final Entity tracker = getTracker(this);
    final EntityPlayer entityplayer = lastUpdatedPlayer;
    NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
    lastUpdatedPlayer = null;
    if (!Setting.DISABLE_TABLIST.asBoolean())
        return;
    Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {

        @Override
        public void run() {
            NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
        }
    }, Setting.TABLIST_REMOVE_PACKET_DELAY.asInt());
}
Also used : Entity(net.minecraft.server.v1_12_R1.Entity) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer)

Example 42 with Entity

use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method removeFromWorld.

@Override
public void removeFromWorld(org.bukkit.entity.Entity entity) {
    Preconditions.checkNotNull(entity);
    Entity nmsEntity = ((CraftEntity) entity).getHandle();
    ((WorldServer) nmsEntity.world).removeEntity(nmsEntity);
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) WorldServer(net.minecraft.server.v1_16_R3.WorldServer)

Example 43 with Entity

use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method registerEntityClass.

@Override
public void registerEntityClass(Class<?> clazz) {
    if (ENTITY_REGISTRY == null)
        return;
    Class<?> search = clazz;
    while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
        EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
        MinecraftKey key = ENTITY_REGISTRY.getKey(type);
        if (key == null || type == null)
            continue;
        CITIZENS_ENTITY_TYPES.put(clazz, type);
        int code = ENTITY_REGISTRY.a(type);
        ENTITY_REGISTRY.put(code, key, type);
        return;
    }
    throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) MinecraftKey(net.minecraft.server.v1_16_R3.MinecraftKey) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Example 44 with Entity

use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method removeHookIfNecessary.

@Override
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity) {
    if (FISHING_HOOK_HOOKED == null)
        return;
    EntityFishingHook hook = (EntityFishingHook) NMSImpl.getHandle(entity);
    Entity hooked = null;
    try {
        hooked = (Entity) FISHING_HOOK_HOOKED.invoke(hook);
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (hooked == null)
        return;
    NPC npc = npcRegistry.getNPC(hooked.getBukkitEntity());
    if (npc == null)
        return;
    if (npc.isProtected()) {
        try {
            FISHING_HOOK_HOOKED_SETTER.invoke(hook, null);
        } catch (Throwable e) {
            e.printStackTrace();
        }
        hook.die();
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) EntityFishingHook(net.minecraft.server.v1_16_R3.EntityFishingHook)

Example 45 with Entity

use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method setNoGravity.

@Override
public void setNoGravity(org.bukkit.entity.Entity entity, boolean enabled) {
    Entity handle = getHandle(entity);
    handle.setNoGravity(enabled);
    if (!(handle instanceof EntityInsentient) || !(entity instanceof NPCHolder))
        return;
    EntityInsentient mob = (EntityInsentient) handle;
    NPC npc = ((NPCHolder) entity).getNPC();
    if (!(mob.getControllerMove() instanceof ControllerMoveFlying) || npc.data().has("flying-nogravity-float"))
        return;
    try {
        if (enabled) {
            boolean old = (boolean) FLYING_MOVECONTROL_FLOAT_GETTER.invoke(mob.getControllerMove());
            FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), true);
            npc.data().set("flying-nogravity-float", old);
        } else if (npc.data().has("flying-nogravity-float")) {
            FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), npc.data().get("flying-nogravity-float"));
            npc.data().remove("flying-nogravity-float");
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) Entity(net.minecraft.server.v1_16_R3.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) ControllerMoveFlying(net.minecraft.server.v1_16_R3.ControllerMoveFlying)

Aggregations

Entity (org.hypertrace.entity.data.service.v1.Entity)110 Test (org.junit.jupiter.api.Test)97 LivingEntity (org.bukkit.entity.LivingEntity)94 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)34 Entity (com.google.datastore.v1.Entity)33 ArrayList (java.util.ArrayList)32 net.minecraft.world.entity (net.minecraft.world.entity)32 org.bukkit.entity (org.bukkit.entity)32 Location (org.bukkit.Location)29 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Entity (net.minecraft.server.v1_16_R3.Entity)19 AttributeValue (org.hypertrace.entity.data.service.v1.AttributeValue)19 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 AnnotateVideoProgress (com.google.cloud.videointelligence.v1.AnnotateVideoProgress)17 AnnotateVideoRequest (com.google.cloud.videointelligence.v1.AnnotateVideoRequest)17 AnnotateVideoResponse (com.google.cloud.videointelligence.v1.AnnotateVideoResponse)17 Entity (com.google.cloud.videointelligence.v1.Entity)17