Skip to content

Commit 2f61d1c

Browse files
authored
Implement BedModel (#77)
1 parent 82b7b39 commit 2f61d1c

10 files changed

Lines changed: 156 additions & 16 deletions

File tree

data/mcswitch_functions.csv

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,7 @@ Address,Quality,Size,Name
25942594
0x000000710006f8e8,O,000300,_ZN7BowItemC1Ev
25952595
0x000000710006fa14,U,000048,_ZN33BowItem_Pull_ItemPropertyFunctionC1Ev
25962596
0x000000710006fa44,U,000048,_ZN36BowItem_Pulling_ItemPropertyFunctionC1Ev
2597-
0x000000710006fa74,U,000332,_ZN7BowItem14findProjectileERKNSt3__110shared_ptrI6PlayerEE
2597+
0x000000710006fa74,U,000332,_ZN7BowItem14findProjectileENSt3__110shared_ptrI6PlayerEE
25982598
0x000000710006fbc0,U,000092,
25992599
0x000000710006fc1c,O,000264,_ZN7BowItem12releaseUsingE12not_null_ptrI12ItemInstanceEP5LevelNSt3__110shared_ptrI12LivingEntityEEi
26002600
0x000000710006fd24,U,001344,
@@ -39697,8 +39697,8 @@ Address,Quality,Size,Name
3969739697
0x0000007100612ce4,U,002004,_ZN14BeaconRenderer16renderBeaconBeamEddddddii15arrayWithLengthIKfEdd
3969839698
0x00000071006134b8,U,000044,_ZN13BufferBuilder5colorEffff
3969939699
0x00000071006134e4,U,000008,
39700-
0x00000071006134ec,U,000836,_ZN8BedModelC_gen
39701-
0x0000007100613830,U,000108,
39700+
0x00000071006134ec,O,000836,_ZN8BedModelC1ERK15ModelDefinition
39701+
0x0000007100613830,O,000108,_ZN8BedModel6renderEb
3970239702
0x000000710061389c,U,000108,_ZN11BedRendererC_gen
3970339703
0x0000007100613908,U,000868,
3970439704
0x0000007100613c6c,U,000024,
@@ -40865,8 +40865,8 @@ Address,Quality,Size,Name
4086540865
0x000000710066b284,U,000036,_ZN12DripParticleD0Ev
4086640866
0x000000710066b2a8,U,000036,_ZN21ElderGuardianRendererD0Ev
4086740867
0x000000710066b2cc,U,000036,_ZN11ElytraModelD0Ev
40868-
0x000000710066b2f0,U,000036,_ZN8BedModelD0Ev
40869-
0x000000710066b314,U,000064,_ZN8BedModel7getNameEv
40868+
0x000000710066b2f0,O,000036,_ZN8BedModelD0Ev
40869+
0x000000710066b314,O,000064,_ZN8BedModel7getNameEv
4087040870
0x000000710066b354,U,000036,_ZN10ChestModelD0Ev
4087140871
0x000000710066b378,U,000036,_ZN8CowModelD0Ev
4087240872
0x000000710066b39c,U,000064,_ZN8CowModel7getNameEv
@@ -41352,7 +41352,7 @@ Address,Quality,Size,Name
4135241352
0x0000007100679878,U,000096,
4135341353
0x00000071006798d8,U,000820,
4135441354
0x0000007100679c0c,U,000260,
41355-
0x0000007100679d10,O,000004,_ZN5BoxedD1Ev
41355+
0x0000007100679d10,O,000004,_ZN5BoxedD2Ev
4135641356
0x0000007100679d14,U,000120,
4135741357
0x0000007100679d8c,U,000456,
4135841358
0x0000007100679f54,U,000084,
@@ -41616,9 +41616,9 @@ Address,Quality,Size,Name
4161641616
0x0000007100682a0c,O,000104,_ZN5ModelC1Ev
4161741617
0x0000007100682a74,U,000008,_ZN9ModelPart7texOffsEii
4161841618
0x0000007100682a7c,U,000220,
41619-
0x0000007100682b58,U,000016,
41619+
0x0000007100682b58,U,000016,_ZN5Model22compileSkinnedDrawlistEv
4162041620
0x0000007100682b68,U,000444,_ZN17EnderCrystalModel6renderERNSt3__110shared_ptrI6EntityEEffffffb
41621-
0x0000007100682d24,U,000008,
41621+
0x0000007100682d24,U,000008,_ZN5Model19callSkinnedDrawlistEv
4162241622
0x0000007100682d2c,U,000164,_ZN20EnderCrystalRendererC_gen
4162341623
0x0000007100682dd0,U,000036,_ZN14EntityRendererC1EP22EntityRenderDispatcher
4162441624
0x0000007100682df4,U,000580,
@@ -41678,7 +41678,7 @@ Address,Quality,Size,Name
4167841678
0x0000007100684a20,U,000848,_ZN13EndermanModelC_gen
4167941679
0x0000007100684d70,U,000156,_ZN13HumanoidModelC_gen
4168041680
0x0000007100684e0c,U,000008,_ZNK15ModelDefinition17DoesOverrideModelEv
41681-
0x0000007100684e14,U,000220,
41681+
0x0000007100684e14,U,000220,_ZN9ModelPart6addBoxEfffiiif
4168241682
0x0000007100684ef0,U,000020,_ZN9ModelPart6setPosEfff
4168341683
0x0000007100684f04,U,000776,_ZN13EndermanModel9setupAnimEffffffNSt3__110shared_ptrI6EntityEE16_SkinAdjustments
4168441684
0x000000710068520c,U,003720,_ZN13HumanoidModel9setupAnimEffffffNSt3__110shared_ptrI6EntityEE16_SkinAdjustments
@@ -42993,7 +42993,7 @@ Address,Quality,Size,Name
4299342993
0x00000071006e620c,O,000064,_ZN5Model7getNameEv
4299442994
0x00000071006e624c,U,000296,
4299542995
0x00000071006e6374,U,000024,
42996-
0x00000071006e638c,U,000028,
42996+
0x00000071006e638c,U,000028,_ZN15ModelDefinitionC1Ev
4299742997
0x00000071006e63a8,U,000184,
4299842998
0x00000071006e6460,U,000752,
4299942999
0x00000071006e6750,U,000380,
@@ -43012,7 +43012,7 @@ Address,Quality,Size,Name
4301243012
0x00000071006e6cb8,U,000060,
4301343013
0x00000071006e6cf4,U,000488,
4301443014
0x00000071006e6edc,U,000212,
43015-
0x00000071006e6fb0,U,000240,
43015+
0x00000071006e6fb0,U,000240,_ZN9ModelPart12addBoxMapTexEfffiiiiif
4301643016
0x00000071006e70a0,U,000244,
4301743017
0x00000071006e7194,U,000016,
4301843018
0x00000071006e71a4,U,001016,
@@ -43024,7 +43024,7 @@ Address,Quality,Size,Name
4302443024
0x00000071006e7830,U,000080,_ZN13ModelPartSkinC_gen2
4302543025
0x00000071006e7880,U,000080,_ZN13ModelPartSkinC1EP5Modelii
4302643026
0x00000071006e78d0,U,000080,_ZN13ModelPartSkinC_gen3
43027-
0x00000071006e7920,U,000100,_ZN13ModelPartSkinC_gen4
43027+
0x00000071006e7920,U,000100,_ZN13ModelPartSkinC1EP5ModelRKNSt3__112basic_stringIwNS2_11char_traitsIwEENS2_9allocatorIwEEEERK15ModelDefinitionP9ModelPartfP17ModelPartsSkinned
4302843028
0x00000071006e7984,U,000060,_ZN13ModelPartSkinD2Ev
4302943029
0x00000071006e79c0,U,000100,
4303043030
0x00000071006e7a24,U,000036,_ZN13ModelPartSkinD0Ev

src/Minecraft.Client/net/minecraft/client/model/Model.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class Model {
1818
public:
1919
Model();
2020

21+
void compileSkinnedDrawlist();
22+
void callSkinnedDrawlist();
23+
2124
virtual ~Model();
2225
virtual void render(std::shared_ptr<Entity>&, float, float, float, float, float, float, bool);
2326
virtual void setupAnim(float, float, float, float, float, float, std::shared_ptr<Entity>,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include "net/minecraft/client/model/ModelPartDefinition.h"
4+
#include <string>
5+
#include <unordered_map>
6+
7+
class ModelDefinition {
8+
public:
9+
ModelDefinition();
10+
11+
bool DoesOverrideModel() const;
12+
13+
bool mOverrideModel;
14+
int dword4;
15+
int dword8;
16+
std::unordered_map<std::wstring, ModelPartDefinition> mPartsDef;
17+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
class ModelPartDefinition {
4+
public:
5+
};

src/Minecraft.Client/net/minecraft/client/model/ModelPartsSkinned.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
#include <vector>
44

5-
#include "net/minecraft/client/model/geom/ModelPart.h"
6-
7-
class ModelPartSkin : public ModelPart {};
5+
#include "net/minecraft/client/model/geom/ModelPartSkin.h"
86

97
class ModelPartsSkinned {
108
public:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,57 @@
11
#pragma once
22

33
#include <string>
4+
#include <vector>
45

56
class Model;
7+
class Cube;
68

79
class ModelPart {
810
public:
911
void construct(Model*, const std::wstring&);
12+
void texOffs(int xTexOffs, int yTexOffs);
13+
void addBox(float, float, float, int, int, int, float);
14+
void addBox(float, float, float, int, int, int);
15+
void addBoxMapTex(float, float, float, int, int, int, int, int, float);
16+
void addChild(ModelPart*);
17+
18+
virtual ~ModelPart();
19+
virtual void render(float, bool shouldCallList, bool);
20+
virtual void renderRollable(float, bool);
21+
virtual void compile(float);
22+
23+
float mXTexSize;
24+
float mYTexSize;
25+
float mXPos;
26+
float mYPos;
27+
float mZPos;
28+
int dword1C;
29+
int dword20;
30+
int dword24;
31+
float mXRot;
32+
float mYRot;
33+
float mZRot;
34+
bool mMirror;
35+
bool mVisible;
36+
bool mNeverRender;
37+
std::vector<Cube*> mCubes;
38+
std::vector<ModelPart*> mChildrens;
39+
float mTranslateX;
40+
float mTranslateY;
41+
float mTranslateZ;
42+
int dword74;
43+
int dword78;
44+
int dword7C;
45+
int dword80;
46+
int dword84;
47+
int dword88;
48+
int dword8C;
49+
std::wstring mId;
50+
int mXTexOffs;
51+
int mYTexOffs;
52+
char mCompiled;
53+
int mList;
54+
ModelPart* mParent;
55+
float mYOffset;
56+
char byteC4;
1057
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include "net/minecraft/client/model/geom/ModelPart.h"
4+
5+
#include "net/minecraft/client/model/ModelDefinition.h"
6+
7+
class ModelPartsSkinned;
8+
9+
class ModelPartSkin : public ModelPart {
10+
public:
11+
ModelPartSkin(Model*, const std::wstring&, const ModelDefinition&, ModelPart*, float, ModelPartsSkinned*);
12+
ModelPartSkin(Model*, int xTexOffs, int yTexOffs);
13+
ModelPartSkin(Model*, int xTexOffs, int yTexOffs, ModelPartsSkinned*);
14+
15+
char fill[0x10];
16+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "net/minecraft/client/model/models/BedModel.h"
2+
3+
#include "net/minecraft/client/model/geom/ModelPartSkin.h"
4+
5+
BedModel::BedModel(const ModelDefinition& def) : Model() {
6+
if (def.DoesOverrideModel()) {
7+
this->mBedPart = new ModelPartSkin(this, L"bed", def, nullptr, 0.0f, nullptr);
8+
this->mLegPart = new ModelPartSkin(this, L"leg1", def, nullptr, 0.0f, nullptr);
9+
} else {
10+
this->mTexWidth = 64;
11+
this->mTexHeight = 128;
12+
13+
this->mBedPart = new ModelPartSkin(this, 0, 0);
14+
this->mLegPart = new ModelPartSkin(this, 0, 22);
15+
this->mLegPart->texOffs(0, 44);
16+
this->mBedPart->addBox(0.0f, 0.0f, 0.0f, 16, 32, 6, 0.0f);
17+
this->mBedPart->addBoxMapTex(3.0f, 31.0f, 6.0f, 10, 1, 3, 38, 2, 0.0f);
18+
this->mBedPart->addBoxMapTex(3.0f, 0.0f, 6.0f, 10, 1, 3, 38, 38, 0.0f);
19+
this->mBedPart->addBoxMapTex(15.0f, 3.0f, 6.0f, 1, 26, 3, 52, 6, 0.0f);
20+
this->mBedPart->addBoxMapTex(0.0f, 3.0f, 6.0f, 1, 26, 3, 44, 6, 0.0f);
21+
this->mLegPart->addBoxMapTex(0.0f, 0.0f, 6.0f, 3, 3, 3, 0, 38, 0.0f);
22+
this->mLegPart->addBoxMapTex(13.0f, 0.0f, 6.0f, 3, 3, 3, 12, 38, 0.0f);
23+
this->mLegPart->addBoxMapTex(0.0f, 29.0f, 6.0f, 3, 3, 3, 0, 44, 0.0f);
24+
this->mLegPart->addBoxMapTex(13.0f, 29.0f, 6.0f, 3, 3, 3, 12, 44, 0.0f);
25+
}
26+
27+
this->compileSkinnedDrawlist();
28+
}
29+
30+
void BedModel::render(bool shouldCallList) {
31+
this->mBedPart->render(0.0625f, shouldCallList, false);
32+
this->mLegPart->render(0.0625f, shouldCallList, false);
33+
this->callSkinnedDrawlist();
34+
}
35+
36+
std::wstring BedModel::getName() {
37+
return L"bed";
38+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include "net/minecraft/client/model/Model.h"
4+
#include "net/minecraft/client/model/ModelDefinition.h"
5+
6+
class BedModel : public Model {
7+
public:
8+
BedModel(const ModelDefinition&);
9+
10+
void render(bool); // this is what 4J done :)
11+
12+
std::wstring getName() override;
13+
14+
ModelPartSkin* mBedPart;
15+
ModelPartSkin* mLegPart;
16+
};

src/Minecraft.Client/net/minecraft/client/renderer/item/ItemInHandRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "net/minecraft/client/renderer/item/ItemInHandRenderer.h"
22

33
#include "NX/Render/RendererCore.h"
4-
#include "com/mojang/blaze3d/platform/GlStateManager.h"
54
#include "net/minecraft/client/Minecraft.h"
5+
#include "net/minecraft/client/renderer/platform/GlStateManager.h"
66
#include "net/minecraft/util/HumanoidArm.h"
77
#include "net/minecraft/util/Mth.h"
88
#include "net/minecraft/world/InteractionHand.h"

0 commit comments

Comments
 (0)