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();
}
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();
}
}
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);
}
};
}
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);
}
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();
}
Aggregations