From 9283f93ae198cf471245241d25d7ff7168964f0b Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Sun, 2 Jul 2017 00:25:53 -0400 Subject: [PATCH] Update custom mob renderer for 1.1.3b1 --- .gitignore | 1 + jni/mcpe/guidata.h | 1 + jni/modscript_renderer.cpp | 3 +- jni/modscript_structs.h | 57 +++++++------------ .../api/modpe/RendererManager.java | 10 +--- 5 files changed, 28 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 37ebe814..a0f5f2fb 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ proguard/ scriptscramble.c tools/readelfout.txt tools/thesyms.txt +jni/glm diff --git a/jni/mcpe/guidata.h b/jni/mcpe/guidata.h index 2c32a9f6..235243e3 100644 --- a/jni/mcpe/guidata.h +++ b/jni/mcpe/guidata.h @@ -4,4 +4,5 @@ class GuiData { public: void displayClientMessage(std::string const&); void showTipMessage(std::string const&); + mce::TexturePtr const& getGuiTex(); }; diff --git a/jni/modscript_renderer.cpp b/jni/modscript_renderer.cpp index 433ab439..62d2e4fc 100644 --- a/jni/modscript_renderer.cpp +++ b/jni/modscript_renderer.cpp @@ -14,6 +14,7 @@ #include "modscript_shared.h" #include "mcpe/mce/textureptr.h" #include "mcpe/itemspriterenderer.h" +#include "mcpe/guidata.h" #include "logutil.h" // search for HumanoidMobRenderer::HumanoidMobRenderer @@ -119,7 +120,7 @@ int bl_renderManager_createHumanoidRenderer() { bl_HumanoidMobRenderer_HumanoidMobRenderer(renderer, *bl_EntityRenderDispatcher_instance, std::unique_ptr(model), std::unique_ptr(model2), std::unique_ptr(model3), - mce::TexturePtr::NONE.clone(), 0); + bl_minecraft->getGuiData()->getGuiTex().clone(), 0); BL_LOG("Adding renderer"); int retval = bl_renderManager_addRenderer((EntityRenderer*) renderer); BL_LOG("Created renderer %d", retval); diff --git a/jni/modscript_structs.h b/jni/modscript_structs.h index d4d9fa59..4f29ee6b 100644 --- a/jni/modscript_structs.h +++ b/jni/modscript_structs.h @@ -275,26 +275,26 @@ class ModelPart { float offsetZ; //8 float rotateAngleX; // 12 float rotateAngleY; // 16 - char filler0[37-20]; // 20 - bool showModel; // 37 from HumanoidMobRenderer::prepareArmor - char filler1[64-38]; //38 - float textureWidth; //64 - float textureHeight; //68 - MaterialPtr* material; //72 from ModelPart::draw - int textureOffsetX; // 76 - int textureOffsetY; // 80 - char filler2[204-84]; // 84 + char filler0[53-20]; // 20 + bool showModel; // 53 from HumanoidMobRenderer::prepareArmor + char filler1[80-54]; //54 + float textureWidth; //80 + float textureHeight; //84 + MaterialPtr* material; //88 from ModelPart::draw + int textureOffsetX; // 92 + int textureOffsetY; // 96 + char filler2[220-100]; // 100 void addBox(Vec3 const&, Vec3 const&, float); -}; // 204 bytes -static_assert(sizeof(ModelPart) == 204, "modelpart size wrong"); +}; // 220 bytes +static_assert(sizeof(ModelPart) == 220, "modelpart size wrong"); namespace mce { class TexturePtr; }; // from HumanoidModel::render -// last updated 1.1.0.8 +// last updated 1.1.3.1 class HumanoidModel { public: void** vtable; //0 @@ -308,34 +308,21 @@ class HumanoidModel { MaterialPtr materialAlphaBlend; // 60 MaterialPtr materialStatic; // 72 MaterialPtr materialEmissive; // 84 - MaterialPtr materialEmissiveAlpha; // 96 - MaterialPtr materialChangeColor; // 108 - MaterialPtr materialGlint; // 120 - MaterialPtr materialAlphaTestGlint; // 132 - MaterialPtr materialChargedCreeper; // 144 - MaterialPtr materialAlphaTestChangeColor; // 156 - MaterialPtr materialAlphaTestChangeColorGlint; // 168 - MaterialPtr materialMultitexture; // 180 - MaterialPtr materialMultitextureColorMask; // 192 - MaterialPtr materialMultitextureAlphaTest; // 204 - MaterialPtr materialMultitextureAlphaTestColorMask; // 216 - MaterialPtr materialGuardianGhost; // 228 - char filler2[264-240]; // 240 - ModelPart bipedHead;//264 - ModelPart bipedHeadwear;//468 - ModelPart bipedBody;//672 - ModelPart bipedRightArm;//876 - ModelPart bipedLeftArm;//1080 - ModelPart bipedRightLeg;//1284 - ModelPart bipedLeftLeg;//1488 - char filler3[3960-1692]; // 1692 - more model parts + ModelPart bipedHead;//96 + ModelPart bipedHeadwear;//316 + ModelPart bipedBody;//536 + ModelPart bipedRightArm;//756 + ModelPart bipedLeftArm;//976 + ModelPart bipedRightLeg;//1196 + ModelPart bipedLeftLeg;//1416 + char filler3[4308-1636]; // 1636 - more model parts HumanoidModel(float, float, int, int); }; -static_assert(sizeof(HumanoidModel) == 3960, "HumanoidModel size"); +static_assert(sizeof(HumanoidModel) == 4308, "HumanoidModel size"); static_assert(offsetof(HumanoidModel, activeTexture) == 32, "active texture"); static_assert(offsetof(HumanoidModel, materialAlphaTest) == 48, "material alpha test"); -static_assert(offsetof(HumanoidModel, bipedHead) == 264, "HumanoidModel bipedHead"); +static_assert(offsetof(HumanoidModel, bipedHead) == 96, "HumanoidModel bipedHead"); typedef struct { Item* item; //0 diff --git a/src/net/zhuoweizhang/mcpelauncher/api/modpe/RendererManager.java b/src/net/zhuoweizhang/mcpelauncher/api/modpe/RendererManager.java index 243a7d12..6eab9362 100644 --- a/src/net/zhuoweizhang/mcpelauncher/api/modpe/RendererManager.java +++ b/src/net/zhuoweizhang/mcpelauncher/api/modpe/RendererManager.java @@ -48,7 +48,7 @@ public static NativeRenderer getByName(String name) { @JSStaticFunction public static NativeRenderer createHumanoidRenderer() { - int id = 0x1000;//nativeCreateHumanoidRenderer(); + int id = nativeCreateHumanoidRenderer(); return new NativeRenderer(id); } @@ -92,7 +92,7 @@ private NativeModel(int rendererId) { this.rendererId = rendererId; } public NativeModelPart getPart(String name) { - boolean partExists = true;//nativeModelPartExists(rendererId, name); + boolean partExists = nativeModelPartExists(rendererId, name); if (!partExists) throw new RuntimeException("The model part " + name + " does not exist."); return new NativeModelPart(rendererId, name); } @@ -125,18 +125,14 @@ public void addBox(float xOffset, float yOffset, float zOffset, int width, int h } public void addBox(float xOffset, float yOffset, float zOffset, int width, int height, int depth, float scale) { -/* nativeModelAddBox(rendererId, modelPartName, xOffset, yOffset, zOffset, width, height, depth, scale, this.textureX, this.textureY, this.transparent, this.textureWidth, this.textureHeight); -*/ } public NativeModelPart clear() { -/* nativeModelClear(rendererId, modelPartName); -*/ return this; } @@ -147,9 +143,7 @@ public NativeModelPart setTextureSize(float width, float height) { } public NativeModelPart setRotationPoint(float x, float y, float z) { -/* nativeModelSetRotationPoint(rendererId, modelPartName, x, y, z); -*/ return this; } }