mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
cube entity working!
This commit is contained in:
parent
b6c5003426
commit
bf494e10d3
@ -58,6 +58,12 @@ ModAPI.meta.credits("By ZXMushroom63");
|
||||
return true;
|
||||
}
|
||||
|
||||
AsyncSink.hideFile = function hideFile(path) {
|
||||
AsyncSink.FSOverride.add(path);
|
||||
AsyncSink.FS.delete(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
AsyncSink.getFile = function getFile(path) {
|
||||
return AsyncSink.FS.get(path) || new ArrayBuffer(0);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
ModAPI.reflect.implements(nme_EntityCube, IAnimals);
|
||||
|
||||
nme_EntityCube.prototype.$canTriggerWalking = function () { return 0 };
|
||||
nme_EntityCube.prototype.$canBePushed = function () { return 0 };
|
||||
nme_EntityCube.prototype.$canBePushed = function () { return 1 };
|
||||
nme_EntityCube.prototype.$getCollisionBox = function () { return this.$getEntityBoundingBox() };
|
||||
nme_EntityCube.prototype.$getCollisionBoundingBox = function () { return this.$getEntityBoundingBox() };
|
||||
nme_EntityCube.prototype.$readEntityFromNBT = function (nbtTagCompount) { // Needed, is an abstract method in parent class
|
||||
@ -49,12 +49,12 @@
|
||||
this.$textureWidth = 64;
|
||||
this.$textureHeight = 64;
|
||||
this.$cubeRenderer = ModelRenderer(this).$setTextureOffset(0, 0);
|
||||
this.$cubeRenderer.$addBox0(0, 0, 0, 1, 1, 1);
|
||||
this.$cubeRenderer.$addBox0(0, 0, 0, 64, 64, 64);
|
||||
this.$cubeRenderer.$setRotationPoint(0, 0, 0);
|
||||
}
|
||||
ModAPI.reflect.prototypeStack(modelBaseClass, nmcm_ModelCube);
|
||||
nmcm_ModelCube.prototype.$render = function ($entity, useless1, useless2, partialTicks, useless3, useless4, f) {
|
||||
this.$cubeRenderer.$render(f);
|
||||
nmcm_ModelCube.prototype.$render = function ($entity, useless1, useless2, partialTicks, useless3, useless4, degToRad) {
|
||||
this.$cubeRenderer.$render(degToRad);
|
||||
}
|
||||
// END CUSTOM MODEL
|
||||
|
||||
@ -75,12 +75,13 @@
|
||||
const parentDoRender = nmcre_RenderCube.prototype.$doRender;
|
||||
nmcre_RenderCube.prototype.$doRender = function (entity, x, y, z, yaw, pitch) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y + 0.25, z);
|
||||
GlStateManager.rotate(180 - yaw, 0, 1, 0);
|
||||
this.$bindEntityTexture(entity);
|
||||
this.$modelCube.$render(entity, 0, 0, -0.1, 0, 0, 0.0625);
|
||||
GlStateManager.popMatrix();
|
||||
parentDoRender.apply(this, [entity, x, y, z, yaw, pitch]);
|
||||
GlStateManager.translate(x + 0.5, y, z + 0.5);
|
||||
GlStateManager.rotate(180 - yaw, 0, 1, 0);
|
||||
GlStateManager.scale(0.25, 0.25, 0.25);
|
||||
this.$bindEntityTexture(entity);
|
||||
this.$modelCube.$render(entity, 0, 0, -0.1, 0, 0, 0.0625);
|
||||
GlStateManager.popMatrix();
|
||||
parentDoRender.apply(this, [entity, x, y, z, yaw, pitch]);
|
||||
}
|
||||
const ID = ModAPI.keygen.entity("cube");
|
||||
ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticMethods.addMapping0.method(
|
||||
@ -95,6 +96,7 @@
|
||||
0x000000, //egg base
|
||||
0x00FF00 //egg spots
|
||||
);
|
||||
// Note that the spawn egg for this will not work, as spawn eggs only spawn entities that are a subclass of EntityLivingBase
|
||||
console.log(ID);
|
||||
|
||||
ModAPI.addEventListener("lib:asyncsink", async () => {
|
||||
@ -117,8 +119,17 @@
|
||||
AsyncSink.setFile("resourcepacks/AsyncSinkLib/assets/minecraft/textures/entity/cube.png", await (await fetch(
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAQBJREFUeF7l0BFzAmAAgOGvKxgMgiAYDIJgEARBEASDQTAIgiAYBEEQBN0NBkEQBEEQBIMgCAZBEAwGgyAIgiAIgiConxE88PJ790RCCNdYCOGeRe/4j4SYDvCgAzzqAHEdIKEDJHWAJx3gWQdI6QBpHeBFB8joAFkdIKcD5HWAgg5Q1AFedYA3HaCkA7zrAGUdoKIDVHWAmg7woQPUdYCGDtDUAVo6QFsH6OgAnzrAlw7Q1QF6OkBfBxjoAEMdYKQDjHWAiQ7wrQNMdYCZDjDXAX50gIUOsNQBVjrArw7wpwP86wBrHWCjA2x1gJ0OsNcBDjrAUQc46QBnHeBiA9wALSueIjTE4PwAAAAASUVORK5CYII="
|
||||
)).arrayBuffer());
|
||||
|
||||
AsyncSink.hideFile("resourcepacks/AsyncSinkLib/assets/minecraft/textures/entity/cube.png.mcmeta");
|
||||
ModAPI.mc.renderManager.entityRenderMap.put(ModAPI.util.asClass(data.EntityCube), new data.RenderCube(ModAPI.mc.renderManager.getRef()));
|
||||
ModAPI.promisify(ModAPI.mc.renderEngine.bindTexture)(data.cubeTexture).then(() => {
|
||||
console.log("Loaded cube texture into cache.");
|
||||
});
|
||||
});
|
||||
console.log(data);
|
||||
})();
|
||||
window.temp1 = data;
|
||||
})();
|
||||
//var cube_man = new temp1.EntityCube(ModAPI.mc.theWorld.getRef());
|
||||
//cube_man.$setPosition(-191, 74, 26);
|
||||
//AsyncSink.startDebugging();
|
||||
//AsyncSink.startDebuggingFS();
|
||||
//ModAPI.mc.theWorld.spawnEntityInWorld(cube_man);
|
12
postinit.js
12
postinit.js
@ -1041,9 +1041,9 @@ globalThis.modapi_postinit = "(" + (() => {
|
||||
ModAPI.util.getBlockFromItem = easyStaticMethod("net.minecraft.block.Block", "getBlockFromItem", true);
|
||||
ModAPI.util.getIdFromBlock = easyStaticMethod("net.minecraft.block.Block", "getIdFromBlock", true);
|
||||
|
||||
function qhash(txt, arr) {
|
||||
var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and other circumstances
|
||||
if (arr.length >= 4095) {
|
||||
function qhash(txt, arr, interval) {
|
||||
// var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and other circumstances
|
||||
if (arr.length >= interval) {
|
||||
console.error("[ModAPI.keygen] Ran out of IDs while generating for " + txt);
|
||||
return -1;
|
||||
}
|
||||
@ -1071,15 +1071,15 @@ globalThis.modapi_postinit = "(" + (() => {
|
||||
}
|
||||
ModAPI.keygen.item = function (item) {
|
||||
var values = [...ModAPI.reflect.getClassById("net.minecraft.item.Item").staticVariables.itemRegistry.$modapi_specmap.values()];
|
||||
return qhash(item, values);
|
||||
return qhash(item, values, 4095);
|
||||
}
|
||||
ModAPI.keygen.block = function (block) {
|
||||
var values = [...ModAPI.reflect.getClassById("net.minecraft.block.Block").staticVariables.blockRegistry.$modapi_specmap.values()];
|
||||
return qhash(block, values);
|
||||
return qhash(block, values, 4095);
|
||||
}
|
||||
ModAPI.keygen.entity = function (entity) {
|
||||
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, 127);
|
||||
}
|
||||
}).toString() + ")();";
|
||||
|
Loading…
x
Reference in New Issue
Block a user