diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/SignRenderer.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/SignRenderer.cpp')
| -rw-r--r-- | Minecraft.Client/SignRenderer.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/Minecraft.Client/SignRenderer.cpp b/Minecraft.Client/SignRenderer.cpp new file mode 100644 index 00000000..97eff4bd --- /dev/null +++ b/Minecraft.Client/SignRenderer.cpp @@ -0,0 +1,120 @@ +#include "stdafx.h" +#include "SignRenderer.h" +#include "SignModel.h" +#include "ModelPart.h" +#include "..\Minecraft.World\net.minecraft.world.level.tile.entity.h" +#include "..\Minecraft.World\net.minecraft.world.level.tile.h" +#include "..\Minecraft.World\Entity.h" +#include "..\Minecraft.World\Level.h" + + +SignRenderer::SignRenderer() +{ + signModel = new SignModel(); +} + +void SignRenderer::render(shared_ptr<TileEntity> _sign, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) +{ + // 4J - dynamic cast required because we aren't using templates/generics in our version + shared_ptr<SignTileEntity> sign = dynamic_pointer_cast<SignTileEntity>(_sign); + + Tile *tile = sign->getTile(); + + glPushMatrix(); + float size = 16 / 24.0f; + if (tile == Tile::sign) + { + glTranslatef((float) x + 0.5f, (float) y + 0.75f * size, (float) z + 0.5f); + float rot = sign->getData() * 360 / 16.0f; + glRotatef(-rot, 0, 1, 0); + signModel->cube2->visible = true; + } + else + { + int face = sign->getData(); + float rot = 0; + + if (face == 2) rot = 180; + if (face == 4) rot = 90; + if (face == 5) rot = -90; + + glTranslatef((float) x + 0.5f, (float) y + 0.75f * size, (float) z + 0.5f); + glRotatef(-rot, 0, 1, 0); + glTranslatef(0, -5 / 16.0f, -7 / 16.0f); + + signModel->cube2->visible = false; + } + + bindTexture(TN_ITEM_SIGN); // 4J was L"/item/sign.png" + + glPushMatrix(); + glScalef(size, -size, -size); + signModel->render(true); + glPopMatrix(); + Font *font = getFont(); + + float s = 1 / 60.0f * size; + glTranslatef(0, 0.5f * size, 0.07f * size); + glScalef(s, -s, s); + glNormal3f(0, 0, -1 * s); + glDepthMask(false); + + int col = Minecraft::GetInstance()->getColourTable()->getColor(eMinecraftColour_Sign_Text); + wstring msg; + // need to send the new data + // Get the current language setting from the console + DWORD dwLanguage = XGetLanguage( ); + + for (int i = 0; i < MAX_SIGN_LINES; i++) // 4J - was sign.messages.length + { + if(sign->IsVerified()) + { + if(sign->IsCensored()) + { + switch(dwLanguage) + { + case XC_LANGUAGE_KOREAN: + case XC_LANGUAGE_JAPANESE: + case XC_LANGUAGE_TCHINESE: + msg = L"Censored";// In-game font, so English only + break; + default: + msg = app.GetString(IDS_STRINGVERIFY_CENSORED); + break; + } + } + else + { + msg = sign->GetMessage(i); + } + } + else + { + switch(dwLanguage) + { + case XC_LANGUAGE_KOREAN: + case XC_LANGUAGE_JAPANESE: + case XC_LANGUAGE_TCHINESE: + msg = L"Awaiting Approval";// In-game font, so English only + break; + default: + msg = app.GetString(IDS_STRINGVERIFY_AWAITING_APPROVAL); + break; + } + } + + if (i == sign->GetSelectedLine()) + { + msg = L"> " + msg + L" <"; + font->draw(msg, -font->width(msg) / 2, i * 10 - (MAX_SIGN_LINES) * 5, col); // 4J - (MAX_SIGN_LINES) was sign.messages.length + } + else + { + font->draw(msg, -font->width(msg) / 2, i * 10 - (MAX_SIGN_LINES) * 5, col); // 4J - (MAX_SIGN_LINES) was sign.messages.length + } + } + glDepthMask(true); + glColor4f(1, 1, 1, 1); + glPopMatrix(); + +} |
