Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Kolyah35
2026-03-14 14:51:25 +03:00
82 changed files with 1998 additions and 221 deletions

View File

@@ -137,12 +137,6 @@ void Chunk::rebuild()
Tile* tile = Tile::tiles[tileId];
int renderLayer = tile->getRenderLayer();
// if (renderLayer == l)
// rendered |= tileRenderer.tesselateInWorld(tile, x, y, z);
// else {
// _layerChunks[_layerChunkCount[renderLayer]++] = cindex;
// }
if (renderLayer > l) {
renderNextLayer = true;
doRenderLayer[renderLayer] = true;

View File

@@ -373,7 +373,7 @@ void GameRenderer::renderLevel(float a) {
// glDisable2(GL_FOG);
setupFog(1);
if (zoom == 1) {
if (zoom == 1 && !mc->options.F1) {
TIMER_POP_PUSH("hand");
glClear(GL_DEPTH_BUFFER_BIT);
renderItemInHand(a, i);

View File

@@ -354,7 +354,7 @@ void ItemInHandRenderer::render( float a )
glRotatef2(-swing3 * 20, 0, 0, 1);
// glRotatef2(-swing2 * 80, 1, 0, 0);
mc->textures->loadAndBindTexture("mob/char.png");
mc->textures->loadAndBindTexture(player->getTexture());
glTranslatef2(-1.0f, +3.6f, +3.5f);
glRotatef2(120, 0, 0, 1);
glRotatef2(180 + 20, 1, 0, 0);

View File

@@ -16,7 +16,7 @@ typedef struct TextureData {
TextureData()
: w(0),
h(0),
data(NULL),
data(nullptr),
numBytes(0),
transparent(true),
memoryHandledExternally(false),

View File

@@ -5,6 +5,7 @@
#include "../Options.h"
#include "../../platform/time.h"
#include "../../AppPlatform.h"
#include "../../util/StringUtils.h"
/*static*/ int Textures::textureChanges = 0;
/*static*/ bool Textures::MIPMAP = false;
@@ -64,7 +65,8 @@ TextureId Textures::loadTexture( const std::string& resourceName, bool inTexture
if (it != idMap.end())
return it->second;
TextureData texdata = platform->loadTexture(resourceName, inTextureFolder);
bool isUrl = Util::startsWith(resourceName, "http://") || Util::startsWith(resourceName, "https://");
TextureData texdata = platform->loadTexture(resourceName, isUrl ? false : inTextureFolder);
if (texdata.data)
return assignTexture(resourceName, texdata);
else if (texdata.identifier != InvalidId) {

View File

@@ -1,4 +1,5 @@
#include "TileRenderer.h"
#include "Chunk.h"
#include "../Minecraft.h"
#include "Tesselator.h"
@@ -56,6 +57,7 @@ bool TileRenderer::tesselateBlockInWorld( Tile* tt, int x, int y, int z, float r
float c2 = 0.8f;
float c3 = 0.6f;
float r11 = c11 * r;
float g11 = c11 * g;
float b11 = c11 * b;
@@ -128,6 +130,7 @@ bool TileRenderer::tesselateBlockInWorld( Tile* tt, int x, int y, int z, float r
return changed;
}
void TileRenderer::tesselateInWorld( Tile* tile, int x, int y, int z, int fixedTexture )
{
this->fixedTexture = fixedTexture;

View File

@@ -51,7 +51,7 @@ EntityRenderDispatcher::EntityRenderDispatcher()
assign( ER_SPIDER_RENDERER, new SpiderRenderer());
assign( ER_TNT_RENDERER, new TntRenderer());
assign( ER_ARROW_RENDERER, new ArrowRenderer());
assign( ER_PLAYER_RENDERER, new PlayerRenderer(new HumanoidModel(), 0));
assign( ER_PLAYER_RENDERER, new PlayerRenderer(new HumanoidModel(0, 0, 64, 64), 0));
assign( ER_THROWNEGG_RENDERER, new ItemSpriteRenderer(Item::egg->getIcon(0)));
assign( ER_SNOWBALL_RENDERER, new ItemSpriteRenderer(Item::snowBall->getIcon(0)));
assign( ER_PAINTING_RENDERER, new PaintingRenderer());

View File

@@ -2,6 +2,7 @@
#include "EntityRenderDispatcher.h"
#include "../ItemInHandRenderer.h"
#include "../TileRenderer.h"
#include "../Tesselator.h"
#include "../../model/HumanoidModel.h"
#include "../../../world/level/tile/Tile.h"
#include "../../../world/entity/player/Player.h"
@@ -12,7 +13,9 @@
HumanoidMobRenderer::HumanoidMobRenderer(HumanoidModel* humanoidModel, float shadow)
: super(humanoidModel, shadow),
humanoidModel(humanoidModel)
humanoidModel(humanoidModel),
lastCapeXRot(0),
lastCapeZRot(0)
{
}
@@ -68,6 +71,143 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float a) {
entityRenderDispatcher->itemInHandRenderer->renderItem(mob, item);
glPopMatrix2();
}
// Render player cape if available
{
Player* player = Player::asPlayer(mob);
if (player) {
const std::string capeTex = player->getCapeTexture();
if (!capeTex.empty()) {
bindTexture(capeTex);
glPushMatrix2();
// Attach to player body
humanoidModel->body.translateTo(1 / 16.0f);
// Convert model units (pixels) to world units
glScalef2(1.0f / 16.0f, 1.0f / 16.0f, 1.0f / 16.0f);
// Position cape slightly down and behind the shoulders
glTranslatef2(0.0f, 1.0f, 2.0f);
// Java-like cape physics (interpolated inertia + body motion)
float pt = a;
double capeX = player->getCapePrevX() + (player->getCapeX() - player->getCapePrevX()) * pt;
double capeY = player->getCapePrevY() + (player->getCapeY() - player->getCapePrevY()) * pt;
double capeZ = player->getCapePrevZ() + (player->getCapeZ() - player->getCapePrevZ()) * pt;
double px = player->xo + (player->x - player->xo) * pt;
double py = player->yo + (player->y - player->yo) * pt;
double pz = player->zo + (player->z - player->zo) * pt;
double dx = capeX - px;
double dy = capeY - py;
double dz = capeZ - pz;
float bodyYaw = player->yBodyRotO + (player->yBodyRot - player->yBodyRotO) * pt;
float rad = bodyYaw * Mth::PI / 180.0f;
double sinYaw = Mth::sin(rad);
double cosYaw = -Mth::cos(rad);
float forward = (float)(dx * sinYaw + dz * cosYaw) * 100.0f;
float sideways = (float)(dx * cosYaw - dz * sinYaw) * 100.0f;
if (forward < 0.0f) forward = 0.0f;
float lift = (float)dy * 10.0f;
if (lift < -6.0f) lift = -6.0f;
if (lift > 32.0f) lift = 32.0f;
float walk =
Mth::sin((player->walkAnimPos + player->walkAnimSpeed) * 6.0f) *
32.0f *
player->walkAnimSpeed;
float capeXRot = 6.0f + forward / 2.0f + lift + walk;
float capeZRot = sideways / 2.0f;
// Smooth out jitter by lerping from the previous frame
const float smooth = 0.3f;
capeXRot = lastCapeXRot + (capeXRot - lastCapeXRot) * smooth;
capeZRot = lastCapeZRot + (capeZRot - lastCapeZRot) * smooth;
lastCapeXRot = capeXRot;
lastCapeZRot = capeZRot;
glRotatef2(capeXRot, 1.0f, 0.0f, 0.0f);
glRotatef2(capeZRot, 0.0f, 0.0f, 1.0f);
Tesselator& t = Tesselator::instance;
t.begin();
// UV coordinates (64x32 skin layout)
const float u0 = 1.0f / 64.0f;
const float u1 = 11.0f / 64.0f;
const float u2 = 12.0f / 64.0f;
const float u3 = 22.0f / 64.0f;
const float uL0 = 0.0f / 64.0f;
const float uL1 = 1.0f / 64.0f;
const float uR0 = 11.0f / 64.0f;
const float uR1 = 12.0f / 64.0f;
const float v0 = 0.0f / 32.0f;
const float v1 = 1.0f / 32.0f;
const float vTop = 1.0f / 32.0f;
const float vBottom = 17.0f / 32.0f;
// Cape size (10x16x1 pixels)
const float halfW = 5.0f;
const float height = 16.0f;
const float depth = 1.0f;
// Front
t.tex(u0, vTop); t.vertex(-halfW, 0.0f, 0.0f);
t.tex(u1, vTop); t.vertex(halfW, 0.0f, 0.0f);
t.tex(u1, vBottom); t.vertex(halfW, height, 0.0f);
t.tex(u0, vBottom); t.vertex(-halfW, height, 0.0f);
// Back
t.tex(u2, vTop); t.vertex(halfW, 0.0f, depth);
t.tex(u3, vTop); t.vertex(-halfW, 0.0f, depth);
t.tex(u3, vBottom); t.vertex(-halfW, height, depth);
t.tex(u2, vBottom); t.vertex(halfW, height, depth);
// Left
t.tex(uL0, vTop); t.vertex(-halfW, 0.0f, depth);
t.tex(uL1, vTop); t.vertex(-halfW, 0.0f, 0.0f);
t.tex(uL1, vBottom); t.vertex(-halfW, height, 0.0f);
t.tex(uL0, vBottom); t.vertex(-halfW, height, depth);
// Right
t.tex(uR0, vTop); t.vertex(halfW, 0.0f, 0.0f);
t.tex(uR1, vTop); t.vertex(halfW, 0.0f, depth);
t.tex(uR1, vBottom); t.vertex(halfW, height, depth);
t.tex(uR0, vBottom); t.vertex(halfW, height, 0.0f);
// Top
t.tex(u0, v0); t.vertex(-halfW, 0.0f, depth);
t.tex(u1, v0); t.vertex(halfW, 0.0f, depth);
t.tex(u1, v1); t.vertex(halfW, 0.0f, 0.0f);
t.tex(u0, v1); t.vertex(-halfW, 0.0f, 0.0f);
// Bottom
t.tex(u2, v0); t.vertex(halfW, height, 0.0f);
t.tex(u3, v0); t.vertex(-halfW, height, 0.0f);
t.tex(u3, v1); t.vertex(-halfW, height, depth);
t.tex(u2, v1); t.vertex(halfW, height, depth);
t.draw();
glPopMatrix2();
}
}
}
}
void HumanoidMobRenderer::render( Entity* mob_, float x, float y, float z, float rot, float a ) {

View File

@@ -21,6 +21,10 @@ protected:
private:
HumanoidModel* humanoidModel;
// Last rotation values for cape smoothing (reduces jitter)
float lastCapeXRot;
float lastCapeZRot;
};
#endif /*NET_MINECRAFT_CLIENT_RENDERER_ENTITY__HumanoidMobRenderer_H__*/

View File

@@ -14,8 +14,8 @@ static const std::string armorFilenames[10] = {
PlayerRenderer::PlayerRenderer( HumanoidModel* humanoidModel, float shadow )
: super(humanoidModel, shadow),
armorParts1(new HumanoidModel(1.0f)),
armorParts2(new HumanoidModel(0.5f))
armorParts1(new HumanoidModel(1.0f, 0, 64, 64)),
armorParts2(new HumanoidModel(0.5f, 0, 64, 64))
{
}