Skip to content

Commit

Permalink
Update custom mob renderer for 1.1.3b1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Jul 2, 2017
1 parent 70904d0 commit 9283f93
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ proguard/
scriptscramble.c
tools/readelfout.txt
tools/thesyms.txt
jni/glm
1 change: 1 addition & 0 deletions jni/mcpe/guidata.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ class GuiData {
public:
void displayClientMessage(std::string const&);
void showTipMessage(std::string const&);
mce::TexturePtr const& getGuiTex();
};
3 changes: 2 additions & 1 deletion jni/modscript_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -119,7 +120,7 @@ int bl_renderManager_createHumanoidRenderer() {
bl_HumanoidMobRenderer_HumanoidMobRenderer(renderer, *bl_EntityRenderDispatcher_instance, std::unique_ptr<HumanoidModel>(model),
std::unique_ptr<HumanoidModel>(model2),
std::unique_ptr<HumanoidModel>(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);
Expand Down
57 changes: 22 additions & 35 deletions jni/modscript_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 2 additions & 8 deletions src/net/zhuoweizhang/mcpelauncher/api/modpe/RendererManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down

0 comments on commit 9283f93

Please sign in to comment.