mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 14:11:16 -09:00
add entity ray trace demo
This commit is contained in:
parent
a7bc868bcb
commit
0dd5ed09bf
27
examplemods/entity_trace_test.js
Normal file
27
examplemods/entity_trace_test.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
(() => {
|
||||||
|
ModAPI.meta.title("/ray_trace_test");
|
||||||
|
ModAPI.meta.description("Mod to test server-side raycasting.");
|
||||||
|
ModAPI.meta.credits("By ZXMushroom63");
|
||||||
|
|
||||||
|
PluginAPI.dedicatedServer.appendCode(function () {
|
||||||
|
PluginAPI.addEventListener("processcommand", (event) => {
|
||||||
|
if (event.command.toLowerCase().startsWith("/ray_trace_test")) {
|
||||||
|
if (
|
||||||
|
ModAPI.reflect.getClassById("net.minecraft.entity.player.EntityPlayerMP").instanceOf(event.sender.getRef())
|
||||||
|
) {
|
||||||
|
//raytrace distance = 6
|
||||||
|
//the 0 on the end is for client side view bobbing (frame based). we are on the server so using 0 as default.
|
||||||
|
var movingObjectPosition = event.sender.rayTrace(6, 0).getCorrective();
|
||||||
|
console.log(movingObjectPosition);
|
||||||
|
|
||||||
|
var hitVec = movingObjectPosition.hitVec;
|
||||||
|
|
||||||
|
event.sender.addChatMessage(ModAPI.reflect.getClassById("net.minecraft.util.ChatComponentText").constructors[0](
|
||||||
|
movingObjectPosition.toString() //This is a java string, but that's ok since it goes into a java method.
|
||||||
|
));
|
||||||
|
}
|
||||||
|
event.preventDefault = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
Loading…
x
Reference in New Issue
Block a user