Search in sources :

Example 1 with Navigation

use of net.minecraft.server.v1_8_R3.Navigation in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class NavigationIT method setup.

protected void setup() throws ClientException {
    // level 1
    page1path = authorClient.createPage("page_1", "page_1", rootPage, defaultPageTemplate).getSlingPath();
    HashMap<String, String> data = new HashMap<String, String>();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1");
    Commons.editNodeProperties(adminClient, page1path, data);
    // level 2
    String page11path = authorClient.createPage("page_1_1", "page_1_1", page1path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1.1");
    data.put("./jcr:content/sling:vanityPath", "/page_1_1_vanity");
    Commons.editNodeProperties(adminClient, page11path, data);
    // level 2 1
    String page111path = authorClient.createPage("page_1_1_1", "page_1_1_1", page11path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1.1.1");
    Commons.editNodeProperties(adminClient, page111path, data);
    // level 2 2
    String page112path = authorClient.createPage("page_1_1_2", "page_1_1_2", page11path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/hideInNav", "true");
    Commons.editNodeProperties(adminClient, page112path, data);
    // level 2 3
    String page113path = authorClient.createPage("page_1_1_3", "page_1_1_3", page11path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1.1.3");
    Commons.editNodeProperties(adminClient, page113path, data);
    // create a proxy component
    proxyPath = Commons.createProxyComponent(adminClient, navigationRT, Commons.proxyPath, null, null);
    // add the component to test page
    compPath = Commons.addComponent(adminClient, proxyPath, page11path + Commons.relParentCompPath, "navigation", null);
    // open test page in page editor
    editorPage = new PageEditorPage(page11path);
    editorPage.open();
    navigation = new Navigation();
}
Also used : Navigation(com.adobe.cq.wcm.core.components.it.seljup.util.components.navigation.v1.Navigation) HashMap(java.util.HashMap) PageEditorPage(com.adobe.cq.testing.selenium.pageobject.PageEditorPage)

Example 2 with Navigation

use of net.minecraft.server.v1_8_R3.Navigation in project Citizens2 by CitizensDev.

the class NMSImpl method updatePathfindingRange.

@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
    if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
        return;
    EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
    if (!(en instanceof EntityInsentient)) {
        if (en instanceof EntityHumanNPC) {
            ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
        }
        return;
    }
    if (PATHFINDING_RANGE == null)
        return;
    EntityInsentient handle = (EntityInsentient) en;
    NavigationAbstract navigation = handle.getNavigation();
    try {
        AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
        inst.setValue(pathfindingRange);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_8_R3.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 3 with Navigation

use of net.minecraft.server.v1_8_R3.Navigation in project Citizens2 by CitizensDev.

the class NMSImpl method getTargetNavigator.

private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, final Function<NavigationAbstract, Boolean> function) {
    net.minecraft.server.v1_8_R3.Entity raw = getHandle(entity);
    raw.onGround = true;
    // not sure of a better way around this - if onGround is false, then
    // navigation won't execute, and calling entity.move doesn't
    // entirely fix the problem.
    final NavigationAbstract navigation = NMSImpl.getNavigation(entity);
    final boolean oldAvoidsWater = navigation instanceof Navigation ? ((Navigation) navigation).e() : false;
    if (navigation instanceof Navigation) {
        ((Navigation) navigation).a(params.avoidWater());
    }
    return new MCNavigator() {

        float lastSpeed;

        CancelReason reason;

        @Override
        public CancelReason getCancelReason() {
            return reason;
        }

        @Override
        public Iterable<Vector> getPath() {
            return new NavigationIterable(navigation);
        }

        @Override
        public void stop() {
            if (navigation instanceof Navigation) {
                ((Navigation) navigation).a(oldAvoidsWater);
            }
            stopNavigation(navigation);
        }

        @Override
        public boolean update() {
            if (params.speed() != lastSpeed) {
                if (Messaging.isDebugging() && lastSpeed > 0) {
                    Messaging.debug("Repathfinding " + ((NPCHolder) entity).getNPC().getId() + " due to speed change");
                }
                Entity handle = getHandle(entity);
                float oldWidth = handle.width;
                if (handle instanceof EntityHorse) {
                    handle.width = Math.min(0.99f, oldWidth);
                }
                if (!function.apply(navigation)) {
                    reason = CancelReason.STUCK;
                }
                // minecraft requires that an entity fit onto both blocks if width >= 1f,
                handle.width = oldWidth;
                // but we'd prefer to make it just fit on 1 so hack around it a bit.
                lastSpeed = params.speed();
            }
            navigation.a(params.speed());
            return NMSImpl.isNavigationFinished(navigation);
        }
    };
}
Also used : PathEntity(net.minecraft.server.v1_8_R3.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_8_R3.Entity) CraftEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Navigation(net.minecraft.server.v1_8_R3.Navigation) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) NavigationAbstract(net.minecraft.server.v1_8_R3.NavigationAbstract) MCNavigator(net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator) EntityHorse(net.minecraft.server.v1_8_R3.EntityHorse) CancelReason(net.citizensnpcs.api.ai.event.CancelReason) Vector(org.bukkit.util.Vector) Entity(net.minecraft.server.v1_8_R3.Entity)

Example 4 with Navigation

use of net.minecraft.server.v1_8_R3.Navigation in project Citizens2 by CitizensDev.

the class EntityHumanNPC method initialise.

private void initialise(MinecraftServer minecraftServer) {
    Socket socket = new EmptySocket();
    NetworkManager conn = null;
    try {
        conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
        playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
        conn.a(playerConnection);
        socket.close();
    } catch (IOException e) {
    // swallow
    }
    AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(this);
    controllerLook = new PlayerControllerLook(this);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    invulnerableTicks = 0;
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_8_R3.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_8_R3.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerJump) IOException(java.io.IOException) EmptyNetworkManager(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_8_R3.NetworkManager) EmptySocket(net.citizensnpcs.nms.v1_8_R3.network.EmptySocket) Socket(java.net.Socket)

Example 5 with Navigation

use of net.minecraft.server.v1_8_R3.Navigation in project aem-core-wcm-components by adobe.

the class NavigationIT method setup.

protected void setup() throws ClientException {
    // level 1
    page1path = authorClient.createPage("page_1", "page_1", rootPage, defaultPageTemplate).getSlingPath();
    HashMap<String, String> data = new HashMap<String, String>();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1");
    Commons.editNodeProperties(adminClient, page1path, data);
    // level 2
    String page11path = authorClient.createPage("page_1_1", "page_1_1", page1path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1.1");
    data.put("./jcr:content/sling:vanityPath", "/page_1_1_vanity");
    Commons.editNodeProperties(adminClient, page11path, data);
    // level 2 1
    String page111path = authorClient.createPage("page_1_1_1", "page_1_1_1", page11path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1.1.1");
    Commons.editNodeProperties(adminClient, page111path, data);
    // level 2 2
    String page112path = authorClient.createPage("page_1_1_2", "page_1_1_2", page11path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/hideInNav", "true");
    Commons.editNodeProperties(adminClient, page112path, data);
    // level 2 3
    String page113path = authorClient.createPage("page_1_1_3", "page_1_1_3", page11path, defaultPageTemplate).getSlingPath();
    data.clear();
    data.put("_charset_", "UTF-8");
    data.put("./jcr:content/navTitle", "Page 1.1.3");
    Commons.editNodeProperties(adminClient, page113path, data);
    // create a proxy component
    proxyPath = Commons.createProxyComponent(adminClient, navigationRT, Commons.proxyPath, null, null);
    // add the component to test page
    compPath = Commons.addComponent(adminClient, proxyPath, page11path + Commons.relParentCompPath, "navigation", null);
    // open test page in page editor
    editorPage = new PageEditorPage(page11path);
    editorPage.open();
    navigation = new Navigation();
}
Also used : Navigation(com.adobe.cq.wcm.core.components.it.seljup.util.components.navigation.v1.Navigation) HashMap(java.util.HashMap) PageEditorPage(com.adobe.cq.testing.selenium.pageobject.PageEditorPage)

Aggregations

PageEditorPage (com.adobe.cq.testing.selenium.pageobject.PageEditorPage)2 Navigation (com.adobe.cq.wcm.core.components.it.seljup.util.components.navigation.v1.Navigation)2 HashMap (java.util.HashMap)2 AttributeInstance (net.minecraft.server.v1_8_R3.AttributeInstance)2 NavigationAbstract (net.minecraft.server.v1_8_R3.NavigationAbstract)2 IOException (java.io.IOException)1 Socket (java.net.Socket)1 CancelReason (net.citizensnpcs.api.ai.event.CancelReason)1 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)1 EmptyNetHandler (net.citizensnpcs.nms.v1_8_R3.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_8_R3.network.EmptySocket)1 PlayerControllerJump (net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerJump)1 PlayerControllerLook (net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerLook)1 PlayerControllerMove (net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_8_R3.util.PlayerNavigation)1 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)1 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)1 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)1 Entity (net.minecraft.server.v1_8_R3.Entity)1