mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 14:11:16 -09:00
going insane
This commit is contained in:
parent
42a0f3e148
commit
23b42e66fb
@ -2,22 +2,28 @@
|
|||||||
ModAPI.meta.title("Cube Entity");
|
ModAPI.meta.title("Cube Entity");
|
||||||
ModAPI.meta.version("v0");
|
ModAPI.meta.version("v0");
|
||||||
ModAPI.meta.description("testing custom entities");
|
ModAPI.meta.description("testing custom entities");
|
||||||
ModAPI.meta.credits("By ZXMushroom64");
|
ModAPI.meta.credits("By ZXMushroom63");
|
||||||
|
|
||||||
function registerEntity() {
|
function registerEntity() {
|
||||||
// Utils
|
// Utils
|
||||||
const ResourceLocation = ModAPI.reflect.getClassByName("ResourceLocation").constructors.find(x => x.length === 1);
|
const ResourceLocation = ModAPI.reflect.getClassByName("ResourceLocation").constructors.find(x => x.length === 1);
|
||||||
const GlStateManager = Object.fromEntries(Object.values(ModAPI.reflect.getClassByName("GlStateManager").staticMethods).map(x => [x.methodNameShort, x.method]));
|
const GlStateManager = Object.fromEntries(Object.values(ModAPI.reflect.getClassByName("GlStateManager").staticMethods).map(x => [x.methodNameShort, x.method]));
|
||||||
|
const IAnimals = ModAPI.reflect.getClassById("net.minecraft.entity.passive.IAnimals");
|
||||||
|
|
||||||
// START CUSTOM ENTITY
|
// START CUSTOM ENTITY
|
||||||
var entityClass = ModAPI.reflect.getClassById("net.minecraft.entity.Entity");
|
var entityClass = ModAPI.reflect.getClassById("net.minecraft.entity.Entity");
|
||||||
var entitySuper = ModAPI.reflect.getSuper(entityClass, (x) => x.length === 2);
|
var entitySuper = ModAPI.reflect.getSuper(entityClass, (x) => x.length === 2);
|
||||||
var nme_EntityCube = function nme_EntityCube($worldIn) {
|
var nme_EntityCube = function nme_EntityCube($worldIn) {
|
||||||
entitySuper(this, $worldIn);
|
entitySuper(this, $worldIn);
|
||||||
//this.$preventEntitySpawning = 1;
|
this.$preventEntitySpawning = 1;
|
||||||
this.$setSize(1, 1);
|
this.$setSize(1, 1);
|
||||||
}
|
}
|
||||||
ModAPI.reflect.prototypeStack(entityClass, nme_EntityCube);
|
ModAPI.reflect.prototypeStack(entityClass, nme_EntityCube);
|
||||||
|
|
||||||
|
//Turns out that minecraft 1.8's networking code is really stupid. Notch hardcoded every entity except for ones that implement the IAnimals interface.
|
||||||
|
//I don't know why, and I don't really care either. As long as it works (been working on this for too long, losing sanity)
|
||||||
|
ModAPI.reflect.implements(nme_EntityCube, IAnimals);
|
||||||
|
|
||||||
nme_EntityCube.prototype.$canTriggerWalking = function () { return 0 };
|
nme_EntityCube.prototype.$canTriggerWalking = function () { return 0 };
|
||||||
nme_EntityCube.prototype.$canBePushed = function () { return 0 };
|
nme_EntityCube.prototype.$canBePushed = function () { return 0 };
|
||||||
nme_EntityCube.prototype.$getCollisionBox = function () { return this.$getEntityBoundingBox() };
|
nme_EntityCube.prototype.$getCollisionBox = function () { return this.$getEntityBoundingBox() };
|
||||||
@ -27,9 +33,10 @@
|
|||||||
};
|
};
|
||||||
nme_EntityCube.prototype.$writeEntityToNBT = function (nbtTagCompount) { // Needed, is an abstract method in parent class
|
nme_EntityCube.prototype.$writeEntityToNBT = function (nbtTagCompount) { // Needed, is an abstract method in parent class
|
||||||
nbtTagCompount = ModAPI.util.wrap(nbtTagCompount);
|
nbtTagCompount = ModAPI.util.wrap(nbtTagCompount);
|
||||||
};
|
};
|
||||||
nme_EntityCube.prototype.$getCollisionBoundingBox = function () { return this.$getEntityBoundingBox() }; // Needed, is an abstract method in parent class
|
nme_EntityCube.prototype.$entityInit = function () {
|
||||||
nme_EntityCube.prototype.$entityInit = function () { console.log("Cube entity created!") }; // Needed, is an abstract method in parent class
|
console.log("Cube entity created!");
|
||||||
|
};
|
||||||
// END CUSTOM ENTITY
|
// END CUSTOM ENTITY
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
globalThis.ModAPIVersion = "v2.6";
|
globalThis.ModAPIVersion = "v2.7";
|
||||||
globalThis.doEaglerforge = true;
|
globalThis.doEaglerforge = true;
|
||||||
document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
||||||
document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
||||||
|
15
postinit.js
15
postinit.js
@ -452,13 +452,14 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
var reloadDeprecationWarnings = 0;
|
var reloadDeprecationWarnings = 0;
|
||||||
const TeaVMArray_To_Recursive_BaseData_ProxyConf = {
|
const TeaVMArray_To_Recursive_BaseData_ProxyConf = {
|
||||||
get(target, prop, receiver) {
|
get(target, prop, receiver) {
|
||||||
|
var corrective = !!this._corrective;
|
||||||
if (prop === "getRef") {
|
if (prop === "getRef") {
|
||||||
return function () {
|
return function () {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var outputValue = Reflect.get(target, prop, receiver);
|
var outputValue = Reflect.get(target, prop, receiver);
|
||||||
var wrapped = ModAPI.util.wrap(outputValue, target, this._corrective, true);
|
var wrapped = ModAPI.util.wrap(outputValue, target, corrective, true);
|
||||||
if (wrapped) {
|
if (wrapped) {
|
||||||
return wrapped;
|
return wrapped;
|
||||||
}
|
}
|
||||||
@ -480,6 +481,7 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
return ("$" + prop) in target;
|
return ("$" + prop) in target;
|
||||||
},
|
},
|
||||||
get(target, prop, receiver) {
|
get(target, prop, receiver) {
|
||||||
|
var corrective = !!this._corrective;
|
||||||
if (prop === "getCorrective") {
|
if (prop === "getCorrective") {
|
||||||
return function () {
|
return function () {
|
||||||
return new Proxy(target, patchProxyConfToCorrective(TeaVM_to_Recursive_BaseData_ProxyConf));
|
return new Proxy(target, patchProxyConfToCorrective(TeaVM_to_Recursive_BaseData_ProxyConf));
|
||||||
@ -487,7 +489,7 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
}
|
}
|
||||||
if (prop === "isCorrective") {
|
if (prop === "isCorrective") {
|
||||||
return function () {
|
return function () {
|
||||||
return !!this._corrective;
|
return corrective;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prop === "getRef") {
|
if (prop === "getRef") {
|
||||||
@ -504,15 +506,15 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prop === "isModProxy") {
|
if (prop === "isModProxy") {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outProp = "$" + prop;
|
var outProp = "$" + prop;
|
||||||
if (this._corrective) {
|
if (corrective) {
|
||||||
outProp = ModAPI.util.getNearestProperty(target, outProp);
|
outProp = ModAPI.util.getNearestProperty(target, outProp);
|
||||||
}
|
}
|
||||||
var outputValue = Reflect.get(target, outProp, receiver);
|
var outputValue = Reflect.get(target, outProp, receiver);
|
||||||
var wrapped = ModAPI.util.wrap(outputValue, target, this._corrective, false);
|
var wrapped = ModAPI.util.wrap(outputValue, target, corrective, false);
|
||||||
if (wrapped) {
|
if (wrapped) {
|
||||||
return wrapped;
|
return wrapped;
|
||||||
}
|
}
|
||||||
@ -1076,7 +1078,8 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
return qhash(block, values);
|
return qhash(block, values);
|
||||||
}
|
}
|
||||||
ModAPI.keygen.entity = function (entity) {
|
ModAPI.keygen.entity = function (entity) {
|
||||||
var values = ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticVariables.idToClassMapping.$elementData.data.filter(x=>x).map(x=>x.$key.$value);
|
var hashMap = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticVariables.idToClassMapping).getCorrective();
|
||||||
|
var values = hashMap.keys.getRef().data.filter(x=>hashMap.get(x));
|
||||||
return qhash(entity, values);
|
return qhash(entity, values);
|
||||||
}
|
}
|
||||||
}).toString() + ")();";
|
}).toString() + ")();";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user