From 055f00be499a61f42be973706ea376258b892fbe Mon Sep 17 00:00:00 2001 From: Shredder Date: Mon, 6 Apr 2026 01:52:27 +0500 Subject: [PATCH] A bit big of a commit but Added 3 Fog Choices (Pocket) (Java) (Unknown that was unused) Restored Java Beta Sky Color code that was unused that depends on biome temperature (choosable using Java fog) Tile Shadows and Entity Shadows that appear beneath them have been restored and fixed from the unused code, toggleable by turning fancy graphics on or off Entities will now render flames on themselves when on fire, including the player Added option to use Java Style Item Count text and position in tweaks - fileshredder --- .../{environment => misc}/foliagecolor.png | Bin .../{environment => misc}/grasscolor.png | Bin data/images/misc/shadow.png | Bin 0 -> 868 bytes data/images/misc/vignette.png | Bin 0 -> 24157 bytes src/client/Minecraft.cpp | 14 +- src/client/Options.cpp | 9 + src/client/Options.h | 2 + src/client/gui/Gui.cpp | 262 +-- src/client/gui/screens/OptionsScreen.cpp | 11 +- src/client/renderer/LevelRenderer.cpp | 290 +-- src/client/renderer/LevelRenderer.h | 3 + .../entity/EntityRenderDispatcher.cpp | 14 +- src/client/renderer/entity/EntityRenderer.cpp | 241 +-- src/client/renderer/entity/EntityRenderer.h | 7 + src/client/renderer/entity/ItemRenderer.cpp | 35 +- src/client/renderer/entity/ItemRenderer.h | 2 +- src/client/renderer/entity/MobRenderer.cpp | 2 +- src/util/Color.cpp | 98 + src/util/Color.h | 15 + src/world/entity/player/Inventory.cpp | 1 + src/world/level/Level.cpp | 1804 +++++++++-------- src/world/level/biome/Biome.cpp | 12 +- src/world/level/chunk/LevelChunk.cpp | 14 +- src/world/level/dimension/Dimension.cpp | 18 +- src/world/level/dimension/Dimension.h | 5 +- .../level/dimension/NormalDayCycleDimension.h | 15 +- 26 files changed, 1574 insertions(+), 1300 deletions(-) rename data/images/{environment => misc}/foliagecolor.png (100%) rename data/images/{environment => misc}/grasscolor.png (100%) create mode 100644 data/images/misc/shadow.png create mode 100644 data/images/misc/vignette.png create mode 100644 src/util/Color.cpp create mode 100644 src/util/Color.h diff --git a/data/images/environment/foliagecolor.png b/data/images/misc/foliagecolor.png similarity index 100% rename from data/images/environment/foliagecolor.png rename to data/images/misc/foliagecolor.png diff --git a/data/images/environment/grasscolor.png b/data/images/misc/grasscolor.png similarity index 100% rename from data/images/environment/grasscolor.png rename to data/images/misc/grasscolor.png diff --git a/data/images/misc/shadow.png b/data/images/misc/shadow.png new file mode 100644 index 0000000000000000000000000000000000000000..06d999b20896dcc2ee077cb94f6afa3c8162895a GIT binary patch literal 868 zcmV-q1DpJbP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qu=Q#NQ00PuWL_t(|UhSK&SHmz6$0w1K$Vp@+vJyFo ztVB*C=a5L`{)9>7Boc|7L?V%JAJM(FOP4fhvs}7+FJiCxb>I8m<#O$2v#Uf$U?D4( z9qlgqZbn`ZWh-eLX`j;m9NU-l+e%wWD@NYq;M31##;2YN+kn~2e9zJVG+AMDSlXsc z=yRBn6f15cDc%NdC+l83W(_$1^Dp0-#c0Du#8Z6&t)nFjt^QqIm%cZJNCUC~581P(U z2!^{40fA)0b+J_Ykw$ZD_m))#%GXAD>#IG~*Xs9OOzhyO7-HT*rW62cqc!S>tH zpuqs%@MsQbK6}5qz;O&9HS|GI^Oyz$C>Lo~#%J%i{Xymv1mL7b$TiUiNv&frdP8;- z0$|@(p5Fuot=80DoJt&^_-hm@C4K3ntv{dkbV@M+0F3lMMuc*a zHmkbsm#UZbi?U_L062d?lp_mx+ua%b+Cd@5BXM;u_?e!OEV%ks>ivvma2p_V=|IYu zx^lMtL4EJ9NON$7#67+~+gNp_b zKE_hMMlj0{{YkivX|~_(#ZJRmb5U=m__H?f~$gTouU?1^9QRnBBo=0bs?;OG9M6P(KzDd|LH8?a|BD}+jXNw2FHV)0#P83fik1i&*IuHG)NjeeD9a?x= zU(Bj+o`3N5@X*YS+4&!i?DI*VZV$ya4~gD5MnxyQTJxdz7g@eE5ywgzTuhueMQ&{R z;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? z4S)5r*4r(KcN+{pyq)r373IMHwht|Q?`w#I{qc=nh6d()VL*w25ysK=u{Q(f5y_Y7 z{+^*IANf!Fgy)6I?!W|89(h>)^LXKw>K{_ISRm6it?j*KVZ5%xSkALx=bc{k8~M`y+G!4w zxc@Kq&Oqy|;1+KsPHuL~A5OT*w_V!sMGZ_{{)ND*nEx z4bhr)%HM1DdBKma9o>Yn)Cg>V>qD|OP?cqGvvW-kHrE{Pjr>io$TGc!-r1;Z!Fqa~ zP&@d2ZeeLfKDJ&(oLJ*9B1mcg_op+R`M3(6Qa+qOXZ|GVgehvLxKamTEN`@`B?h`W zK5#ldmAupN*R@yPZlGuk%|Y;TL2%^Do)YE}e#ktcIQS#*4MIh_i?@NbY&AgGLdqNZ zKAEmy4=V2Z=*D3upm}+kV|ekG_O><`h)}J>KrT8itz!Fj@-HH0?c$TnK4`HKdg64k z^~oG##?TwsX3h8%*hcMf;Ma)FMKf~L@r8ysL@^MEq32mXj9ttP)Jl=niN1O1hWDhX z!AH*5C(OsP|K#Bsa(8^0!6Duo<`NWh14TbO|)U0`Hf;(0>+3NqI zi#M{^Yl~e^Q%l+2llBLVH&gk)vr`f)LJ?3jb7;R2Cx!7_?>eZ(5_*C$sgSE^Tlvo9 zfdyz%TG|p2m`+%jcIaoy`^hJoZ%LnUz`xiC>~`I5k9=*sYXQXx@UXT5Q}1C)em?ZJM#w{ARhZBp zzHBv)O9kusDc6mpV0%053OXw|FxnmV1h+;$aawQb4|zx8tn!2vYw!^;@R8n?DNQ(? z#@Ckp literal 0 HcmV?d00001 diff --git a/src/client/Minecraft.cpp b/src/client/Minecraft.cpp index 1127246..1bd68de 100755 --- a/src/client/Minecraft.cpp +++ b/src/client/Minecraft.cpp @@ -1138,13 +1138,13 @@ void Minecraft::init() // my code - TextureId foliageId = (textures->loadTexture("environment/foliagecolor.png")); // loading the uh png for foliage color - int* foliagePixels = textures->loadTexturePixels(foliageId, "environment/foliagecolor.png"); + TextureId foliageId = (textures->loadTexture("misc/foliagecolor.png")); // loading the uh png for foliage color + int* foliagePixels = textures->loadTexturePixels(foliageId, "misc/foliagecolor.png"); // now i can finally initialize foliage color, probably not the best way to handle this but i cant be arsed rn FoliageColor::init(foliagePixels); - TextureId grassId = (textures->loadTexture("environment/grasscolor.png")); // loading the uh png for foliage color - int* grassPixels = textures->loadTexturePixels(grassId, "environment/grasscolor.png"); + TextureId grassId = (textures->loadTexture("misc/foliagecolor.png")); // loading the uh png for foliage color + int* grassPixels = textures->loadTexturePixels(grassId, "misc/foliagecolor.png"); GrassColor::init(grassPixels); bool tint = options.getBooleanValue(OPTIONS_FOLIAGE_TINT); // finally, toggleable foliage color @@ -1401,6 +1401,12 @@ void Minecraft::_levelGenerated() player->resetPos(false); } + if (level && level->dimension) { + // For example, if you want FogType or any other option + level->dimension->FogType = options.getBooleanValue(OPTIONS_FOG_TYPE); + } + + this->cameraTargetPlayer = player; std::string serverName = options.getStringValue(OPTIONS_USERNAME) + " - " + level->getLevelData()->levelName; diff --git a/src/client/Options.cpp b/src/client/Options.cpp index 68d6bae..cf719b0 100755 --- a/src/client/Options.cpp +++ b/src/client/Options.cpp @@ -62,6 +62,10 @@ OptionBool serverVisible("servervisible", true); OptionBool foliageTint("foliagetint", false); +OptionInt fogType("fogType", 0, 0, 2); + +OptionBool javaHud("javaHud", false); + OptionInt keyForward("key.forward", Keyboard::KEY_W); OptionInt keyLeft("key.left", Keyboard::KEY_A); OptionInt keyBack("key.back", Keyboard::KEY_S); @@ -166,6 +170,11 @@ void Options::initTable() { m_options[OPTIONS_RPI_CURSOR] = &rpiCursor; m_options[OPTIONS_FOLIAGE_TINT] = &foliageTint; + // more options yay + m_options[OPTIONS_FOG_TYPE] = &fogType; + + m_options[OPTIONS_JAVA_HUD] = &javaHud; + m_options[OPTIONS_AUTOJUMP] = &autoJump; m_options[OPTIONS_LAST_IP] = &lastIp; } diff --git a/src/client/Options.h b/src/client/Options.h index 96d6f3b..9852d48 100755 --- a/src/client/Options.h +++ b/src/client/Options.h @@ -85,6 +85,8 @@ enum OptionId { OPTIONS_RPI_CURSOR, OPTIONS_FOLIAGE_TINT, + OPTIONS_FOG_TYPE, + OPTIONS_JAVA_HUD, // Should be last! OPTIONS_COUNT }; diff --git a/src/client/gui/Gui.cpp b/src/client/gui/Gui.cpp index ccc9c26..8df59f0 100755 --- a/src/client/gui/Gui.cpp +++ b/src/client/gui/Gui.cpp @@ -36,7 +36,7 @@ const float Gui::DropTicks = 40.0f; //#include Gui::Gui(Minecraft* minecraft) -: minecraft(minecraft), + : minecraft(minecraft), tickCount(0), progress(0), overlayMessageTime(0), @@ -77,7 +77,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { Font* font = minecraft->font; const bool isTouchInterface = minecraft->useTouchscreen(); - + const int screenWidth = (int)(minecraft->width * InvGuiScale); const int screenHeight = (int)(minecraft->height * InvGuiScale); blitOffset = -90; @@ -86,9 +86,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { glColor4f2(1, 1, 1, 1); // H: 4 - // T: 7 - // L: 6 - // F: 3 + // T: 7 + // L: 6 + // F: 3 int ySlot = screenHeight - 16 - 3; if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) { @@ -103,6 +103,12 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { } } + // @todo - Shredder: I added this here but currently viginette is broken so i cant do much about it. + // if (minecraft->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)){ + // this->renderVignette(this->minecraft->player->getBrightness(a), screenWidth, screenHeight); + // } + // shredder end + if(minecraft->player->getSleepTimer() > 0) { glDisable(GL_DEPTH_TEST); glDisable(GL_ALPHA_TEST); @@ -113,38 +119,38 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { glEnable(GL_DEPTH_TEST); } if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) { - renderToolBar(a, ySlot, screenWidth); + renderToolBar(a, ySlot, screenWidth); - glEnable(GL_BLEND); - bool isChatting = (minecraft->screen && (dynamic_cast(minecraft->screen) || dynamic_cast(minecraft->screen))); - unsigned int max = 10; - if (isChatting) { - int lineHeight = 9; - max = (screenHeight - 48) / lineHeight; - if (max < 1) max = 1; - int maxScroll = (int)guiMessages.size() - (int)max; - if (maxScroll < 0) maxScroll = 0; - if (chatScrollOffset > maxScroll) chatScrollOffset = maxScroll; - } else { - chatScrollOffset = 0; - } - renderChatMessages(screenHeight, max, isChatting, font); + glEnable(GL_BLEND); + bool isChatting = (minecraft->screen && (dynamic_cast(minecraft->screen) || dynamic_cast(minecraft->screen))); + unsigned int max = 10; + if (isChatting) { + int lineHeight = 9; + max = (screenHeight - 48) / lineHeight; + if (max < 1) max = 1; + int maxScroll = (int)guiMessages.size() - (int)max; + if (maxScroll < 0) maxScroll = 0; + if (chatScrollOffset > maxScroll) chatScrollOffset = maxScroll; + } else { + chatScrollOffset = 0; + } + renderChatMessages(screenHeight, max, isChatting, font); #if !defined(RPI) - renderOnSelectItemNameText(screenWidth, font, ySlot); + renderOnSelectItemNameText(screenWidth, font, ySlot); #endif #if defined(RPI) - renderDebugInfo(); + renderDebugInfo(); #endif - if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) { - renderPlayerList(font, screenWidth, screenHeight); + if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) { + renderPlayerList(font, screenWidth, screenHeight); + } + + if (minecraft->options.getBooleanValue(OPTIONS_RENDER_DEBUG)) + renderDebugInfo(); } - if (minecraft->options.getBooleanValue(OPTIONS_RENDER_DEBUG)) - renderDebugInfo(); - } - - glDisable(GL_BLEND); + glDisable(GL_BLEND); glEnable2(GL_ALPHA_TEST); } @@ -183,7 +189,7 @@ void Gui::getSlotPos(int slot, int& posX, int& posY) { int screenWidth = (int)(minecraft->width * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale); posX = screenWidth / 2 - getNumSlots() * 10 + slot * 20, - posY = screenHeight - 22; + posY = screenHeight - 22; } RectangleArea Gui::getRectangleArea(int extendSide) { @@ -196,7 +202,7 @@ RectangleArea Gui::getRectangleArea(int extendSide) { return RectangleArea(0, (float)minecraft->height-pHeight, pCenterX+pHalfWidth+2, (float)minecraft->height); if (extendSide > 0) return RectangleArea(pCenterX-pHalfWidth, (float)minecraft->height-pHeight, (float)minecraft->width, (float)minecraft->height); - + return RectangleArea(pCenterX-pHalfWidth, (float)minecraft->height-pHeight, pCenterX+pHalfWidth+2, (float)minecraft->height); } @@ -242,7 +248,7 @@ void Gui::handleKeyPressed(int key) if (key == Keyboard::KEY_F1) { minecraft->options.toggle(OPTIONS_HIDEGUI); } - + if (key == 99) { if (minecraft->player->inventory->selected > 0) @@ -290,11 +296,11 @@ void Gui::tick() { if(itemNameOverlayTime < 2) itemNameOverlayTime += 1.0f / SharedConstants::TicksPerSecond; for (unsigned int i = 0; i < guiMessages.size(); i++) { - guiMessages.at(i).ticks++; + guiMessages.at(i).ticks++; } - if (!minecraft->isCreativeMode()) - tickItemDrop(); + if (!minecraft->isCreativeMode()) + tickItemDrop(); } void Gui::addMessage(const std::string& _string) { @@ -344,6 +350,8 @@ void Gui::displayClientMessage(const std::string& messageId) { addMessage(messageId); } + +// @todo - shredder: Function seems to be completely fine and ported over from java beta, but renders opaque??? need to investigate void Gui::renderVignette(float br, int w, int h) { br = 1 - br; if (br < 0) br = 0; @@ -354,7 +362,10 @@ void Gui::renderVignette(float br, int w, int h) { glDepthMask(false); glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glColor4f2(tbr, tbr, tbr, 1); + minecraft->textures->loadAndBindTexture("misc/vignette.png"); + glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); Tesselator& t = Tesselator::instance; t.begin(); @@ -407,7 +418,7 @@ void Gui::inventoryUpdated() { } void Gui::onGraphicsReset() { - inventoryUpdated(); + inventoryUpdated(); } void Gui::texturesLoaded( Textures* textures ) { @@ -585,12 +596,12 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen bool bowEquipped = currentItem != NULL ? currentItem->getItem() == Item::bow : false; bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft->player->getUseItem()->getItem() : false; if ((!isTouchInterface || minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA) - || (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) { - minecraft->textures->loadAndBindTexture("gui/icons.png"); - glEnable(GL_BLEND); - glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); - blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16); - glDisable(GL_BLEND); + || (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) { + minecraft->textures->loadAndBindTexture("gui/icons.png"); + glEnable(GL_BLEND); + glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); + blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16); + glDisable(GL_BLEND); } else if(!bowEquipped) { const float tprogress = minecraft->gameMode->destroyProgress; const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f); @@ -665,10 +676,10 @@ void Gui::renderHearts() { int ip2 = i + i + 1; if (armor > 0) { - int xo = xx + 80 + i * 8 + 4; - if (ip2 < armor) blit(xo, yo, 16 + 2 * 9, 9 * 1, 9, 9); - else if (ip2 == armor) blit(xo, yo, 16 + 4 * 9, 9 * 1, 9, 9); - else if (ip2 > armor) blit(xo, yo, 16 + 0 * 9, 9 * 1, 9, 9); + int xo = xx + 80 + i * 8 + 4; + if (ip2 < armor) blit(xo, yo, 16 + 2 * 9, 9 * 1, 9, 9); + else if (ip2 == armor) blit(xo, yo, 16 + 4 * 9, 9 * 1, 9, 9); + else if (ip2 > armor) blit(xo, yo, 16 + 0 * 9, 9 * 1, 9, 9); } int bg = 0; @@ -691,7 +702,7 @@ void Gui::renderBubbles() { if (minecraft->player->isUnderLiquid(Material::water)) { int screenWidth = (int)(minecraft->width * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale); - + int xx = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2; int yo = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 42 : 12; int count = (int) std::ceil((minecraft->player->airSupply - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY); @@ -910,64 +921,64 @@ void Gui::renderOnSelectItemNameText( const int screenWidth, Font* font, int ySl // helper structure used by drawColoredString struct ColorSegment { - std::string text; - uint32_t color; + std::string text; + uint32_t color; }; // parse [tag] and [/tag] markers; tags may contain a color name (gold, green, etc.) static void parseColorTags(const std::string& in, std::vector& out) { - uint32_t curColor = 0xffffff; - size_t pos = 0; - while (pos < in.size()) { - size_t open = in.find('[', pos); - if (open == std::string::npos) { - out.push_back({in.substr(pos), curColor}); - break; - } - if (open > pos) { - out.push_back({in.substr(pos, open - pos), curColor}); - } - size_t close = in.find(']', open); - if (close == std::string::npos) { - out.push_back({in.substr(open), curColor}); - break; - } - std::string tag = in.substr(open + 1, close - open - 1); - if (!tag.empty() && tag[0] == '/') { - curColor = 0xffffff; - } else { - std::string lower; - lower.resize(tag.size()); - std::transform(tag.begin(), tag.end(), lower.begin(), ::tolower); - if (lower.find("gold") != std::string::npos) curColor = 0xffd700; - else if (lower.find("green") != std::string::npos) curColor = 0x00ff00; - else if (lower.find("yellow") != std::string::npos) curColor = 0xffff00; - else if (lower.find("red") != std::string::npos) curColor = 0xff0000; - else if (lower.find("blue") != std::string::npos) curColor = 0x0000ff; - } - pos = close + 1; - } + uint32_t curColor = 0xffffff; + size_t pos = 0; + while (pos < in.size()) { + size_t open = in.find('[', pos); + if (open == std::string::npos) { + out.push_back({in.substr(pos), curColor}); + break; + } + if (open > pos) { + out.push_back({in.substr(pos, open - pos), curColor}); + } + size_t close = in.find(']', open); + if (close == std::string::npos) { + out.push_back({in.substr(open), curColor}); + break; + } + std::string tag = in.substr(open + 1, close - open - 1); + if (!tag.empty() && tag[0] == '/') { + curColor = 0xffffff; + } else { + std::string lower; + lower.resize(tag.size()); + std::transform(tag.begin(), tag.end(), lower.begin(), ::tolower); + if (lower.find("gold") != std::string::npos) curColor = 0xffd700; + else if (lower.find("green") != std::string::npos) curColor = 0x00ff00; + else if (lower.find("yellow") != std::string::npos) curColor = 0xffff00; + else if (lower.find("red") != std::string::npos) curColor = 0xff0000; + else if (lower.find("blue") != std::string::npos) curColor = 0x0000ff; + } + pos = close + 1; + } } void Gui::drawColoredString(Font* font, const std::string& text, float x, float y, int alpha) { - std::vector segs; - parseColorTags(text, segs); - float cx = x; - for (auto &s : segs) { - int color = s.color + (alpha << 24); - font->drawShadow(s.text, cx, y, color); - cx += font->width(s.text); - } + std::vector segs; + parseColorTags(text, segs); + float cx = x; + for (auto &s : segs) { + int color = s.color + (alpha << 24); + font->drawShadow(s.text, cx, y, color); + cx += font->width(s.text); + } } float Gui::getColoredWidth(Font* font, const std::string& text) { - std::vector segs; - parseColorTags(text, segs); - float w = 0; - for (auto &s : segs) { - w += font->width(s.text); - } - return w; + std::vector segs; + parseColorTags(text, segs); + float w = 0; + for (auto &s : segs) { + w += font->width(s.text); + } + return w; } void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font ) { @@ -1011,13 +1022,13 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC glEnable(GL_BLEND); // special-case join/leave announcements - int baseColor = 0xffffff; - if (msg.find(" joined the game") != std::string::npos || - msg.find(" left the game") != std::string::npos) { - baseColor = 0xffff00; // yellow - } - // replace previous logic; allow full colour tags now - Gui::drawColoredString(font, msg, x, y, alpha); + int baseColor = 0xffffff; + if (msg.find(" joined the game") != std::string::npos || + msg.find(" left the game") != std::string::npos) { + baseColor = 0xffff00; // yellow + } + // replace previous logic; allow full colour tags now + Gui::drawColoredString(font, msg, x, y, alpha); } } } @@ -1105,22 +1116,41 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) { // Draw count //Tesselator& t = Tesselator::instance; - glPushMatrix2(); - glScalef2(InvGuiScale + InvGuiScale, InvGuiScale + InvGuiScale, 1); + const float k = 0.5f * GuiScale; - - t.beginOverride(); - if (minecraft->gameMode->isSurvivalType()) { - x = baseItemX; - for (int i = 0; i < slots; i++) { - ItemInstance* item = minecraft->player->inventory->getItem(i); - if (item && item->count >= 0) - renderSlotText(item, k*x, k*ySlot + 1, true, true); - x += 20; + if (minecraft->options.getBooleanValue(OPTIONS_JAVA_HUD)) // if true enables the java beta item count size and color and calls the java items decorations + { + t.beginOverride(); + if (minecraft->gameMode->isSurvivalType()) { + x = baseItemX; + for (int i = 0; i < slots; i++) { + ItemInstance* item = minecraft->player->inventory->getItem(i); + if (item && item->count >= 0) + ItemRenderer::renderGuiItemDecorations(minecraft->font, minecraft->textures, minecraft->player->inventory->getItem(i), x, (float)ySlot); + x += 20; + } } + minecraft->textures->loadAndBindTexture("font/default8.png"); + t.endOverrideAndDraw(); + } + else { // otherwise uses the normal pocket edition one + glPushMatrix2(); + glScalef2(InvGuiScale + InvGuiScale, InvGuiScale + InvGuiScale, 1); + t.beginOverride(); + if (minecraft->gameMode->isSurvivalType()) { + x = baseItemX; + for (int i = 0; i < slots; i++) { + ItemInstance* item = minecraft->player->inventory->getItem(i); + if (item && item->count >= 0) + renderSlotText(item, k*x, k*ySlot, true, true); + x += 20; + } + } + + minecraft->textures->loadAndBindTexture("font/default8.png"); + t.endOverrideAndDraw(); + + glPopMatrix2(); } - minecraft->textures->loadAndBindTexture("font/default8.png"); - t.endOverrideAndDraw(); - glPopMatrix2(); } diff --git a/src/client/gui/screens/OptionsScreen.cpp b/src/client/gui/screens/OptionsScreen.cpp index 02a7a62..328a207 100755 --- a/src/client/gui/screens/OptionsScreen.cpp +++ b/src/client/gui/screens/OptionsScreen.cpp @@ -138,7 +138,7 @@ void OptionsScreen::render(int xm, int ym, float a) { if (currentOptionsGroup != NULL) currentOptionsGroup->render(minecraft, xmm, ymm); - + super::render(xm, ym, a); } @@ -222,11 +222,14 @@ void OptionsScreen::generateOptionScreens() { .addOptionItem(OPTIONS_ANAGLYPH_3D, minecraft) .addOptionItem(OPTIONS_VIEW_BOBBING, minecraft) .addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft); - + optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft) .addOptionItem(OPTIONS_BAR_ON_TOP, minecraft) .addOptionItem(OPTIONS_RPI_CURSOR, minecraft) - .addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft); + .addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft) + .addOptionItem(OPTIONS_JAVA_HUD, minecraft) + .addOptionItem(OPTIONS_FOG_TYPE, minecraft); + } void OptionsScreen::mouseClicked(int x, int y, int buttonNum) { @@ -248,7 +251,7 @@ void OptionsScreen::keyPressed(int eventKey) { currentOptionsGroup->keyPressed(minecraft, eventKey); if (eventKey == Keyboard::KEY_ESCAPE) minecraft->options.save(); - + super::keyPressed(eventKey); } diff --git a/src/client/renderer/LevelRenderer.cpp b/src/client/renderer/LevelRenderer.cpp index 73670cd..439a443 100755 --- a/src/client/renderer/LevelRenderer.cpp +++ b/src/client/renderer/LevelRenderer.cpp @@ -34,7 +34,7 @@ #endif LevelRenderer::LevelRenderer( Minecraft* mc) -: mc(mc), + : mc(mc), textures(mc->textures), level(NULL), cullStep(0), @@ -49,6 +49,7 @@ LevelRenderer::LevelRenderer( Minecraft* mc) xMaxChunk(0), yMaxChunk(0), zMaxChunk(0), lastViewDistance(-1), + lastFogType(-1), noEntityRenderFrames(2), totalEntities(0), @@ -145,10 +146,10 @@ void LevelRenderer::setLevel( Level* level ) level->addListener(this); allChanged(); } - if (mc->options.getBooleanValue(OPTIONS_AMBIENT_OCCLUSION)) { - mc->useAmbientOcclusion = !mc->useAmbientOcclusion; - allChanged(); - } + if (mc->options.getBooleanValue(OPTIONS_AMBIENT_OCCLUSION)) { + mc->useAmbientOcclusion = !mc->useAmbientOcclusion; + allChanged(); + } } void LevelRenderer::allChanged() @@ -161,6 +162,8 @@ void LevelRenderer::allChanged() Tile::leaves_carried->setFancy(fancy); lastViewDistance = mc->options.getIntValue(OPTIONS_VIEW_DISTANCE); + lastFogType = mc->options.getIntValue(OPTIONS_FOG_TYPE); + bool tint = mc->options.getBooleanValue(OPTIONS_FOLIAGE_TINT); FoliageColor::setUseTint(tint); GrassColor::setUseTint(tint); @@ -171,9 +174,9 @@ void LevelRenderer::allChanged() dist = (int)((float)dist * 0.8f); LOGI("last: %d, power: %d\n", lastViewDistance, mc->isPowerVR()); - #if defined(RPI) - dist *= 0.6f; - #endif +#if defined(RPI) + dist *= 0.6f; +#endif if (dist > 400) dist = 400; /* @@ -238,17 +241,17 @@ void LevelRenderer::allChanged() void LevelRenderer::deleteChunks() { for (int z = 0; z < zChunks; ++z) - for (int y = 0; y < yChunks; ++y) - for (int x = 0; x < xChunks; ++x) { - int c = getLinearCoord(x, y, z); - delete chunks[c]; - } + for (int y = 0; y < yChunks; ++y) + for (int x = 0; x < xChunks; ++x) { + int c = getLinearCoord(x, y, z); + delete chunks[c]; + } - delete[] chunks; - chunks = NULL; + delete[] chunks; + chunks = NULL; - delete[] sortedChunks; - sortedChunks = NULL; + delete[] sortedChunks; + sortedChunks = NULL; } void LevelRenderer::resortChunks( int xc, int yc, int zc ) @@ -312,6 +315,17 @@ int LevelRenderer::render( Mob* player, int layer, float alpha ) allChanged(); } + int currentFogType = mc->options.getIntValue(OPTIONS_FOG_TYPE); + if (currentFogType != lastFogType) { + lastFogType = currentFogType; + + if (level && level->dimension) { + level->dimension->FogType = currentFogType; // use new fog stuff + } + + allChanged(); + } + TIMER_PUSH("sortchunks"); for (int i = 0; i < 10; i++) { chunkFixOffs = (chunkFixOffs + 1) % chunksLength; @@ -580,11 +594,11 @@ int LevelRenderer::renderChunks( int from, int to, int layer, float alpha ) for (unsigned int i = 0; i < _renderChunks.size(); ++i) { Chunk* chunk = _renderChunks[i]; - #ifdef USE_VBO - renderList.addR(chunk->getRenderChunk(layer)); - #else - renderList.add(chunk->getList(layer)); - #endif +#ifdef USE_VBO + renderList.addR(chunk->getRenderChunk(layer)); +#else + renderList.add(chunk->getList(layer)); +#endif renderList.next(); } @@ -735,20 +749,20 @@ bool LevelRenderer::updateDirtyChunks( Mob* player, bool force ) Chunk* chunk = dirtyChunks[cursor]; if (chunk != NULL) { bool remove = false; - for (int i = 0; i < count && !remove; i++) - if (chunk == toAdd[i]) { - remove = true; - } - - if (!remove) { - //if (chunk == toAdd[0] || chunk == toAdd[1] || chunk == toAdd[2]) { - // ; // this chunk was rendered and should be removed - //} else { - if (target != cursor) { - dirtyChunks[target] = chunk; + for (int i = 0; i < count && !remove; i++) + if (chunk == toAdd[i]) { + remove = true; + } + + if (!remove) { + //if (chunk == toAdd[0] || chunk == toAdd[1] || chunk == toAdd[2]) { + // ; // this chunk was rendered and should be removed + //} else { + if (target != cursor) { + dirtyChunks[target] = chunk; + } + target++; } - target++; - } } cursor++; } @@ -922,23 +936,23 @@ bool entityRenderPredicate(const Entity* a, const Entity* b) { } void LevelRenderer::renderEntities(Vec3 cam, Culler* culler, float a) { - if (noEntityRenderFrames > 0) { - noEntityRenderFrames--; - return; - } + if (noEntityRenderFrames > 0) { + noEntityRenderFrames--; + return; + } TIMER_PUSH("prepare"); - TileEntityRenderDispatcher::getInstance()->prepare(level, textures, mc->font, mc->cameraTargetPlayer, a); - EntityRenderDispatcher::getInstance()->prepare(level, mc->font, mc->cameraTargetPlayer, &mc->options, a); + TileEntityRenderDispatcher::getInstance()->prepare(level, textures, mc->font, mc->cameraTargetPlayer, a); + EntityRenderDispatcher::getInstance()->prepare(level, mc->font, mc->cameraTargetPlayer, &mc->options, a); - totalEntities = 0; - renderedEntities = 0; - culledEntities = 0; + totalEntities = 0; + renderedEntities = 0; + culledEntities = 0; Entity* player = mc->cameraTargetPlayer; - EntityRenderDispatcher::xOff = TileEntityRenderDispatcher::xOff = (player->xOld + (player->x - player->xOld) * a); - EntityRenderDispatcher::yOff = TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a); - EntityRenderDispatcher::zOff = TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a); + EntityRenderDispatcher::xOff = TileEntityRenderDispatcher::xOff = (player->xOld + (player->x - player->xOld) * a); + EntityRenderDispatcher::yOff = TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a); + EntityRenderDispatcher::zOff = TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a); glEnableClientState2(GL_VERTEX_ARRAY); glEnableClientState2(GL_TEXTURE_COORD_ARRAY); @@ -977,10 +991,10 @@ void LevelRenderer::renderEntities(Vec3 cam, Culler* culler, float a) { delete[] toRender; } - TIMER_POP_PUSH("tileentities"); - for (unsigned int i = 0; i < level->tileEntities.size(); i++) { - TileEntityRenderDispatcher::getInstance()->render(level->tileEntities[i], a); - } + TIMER_POP_PUSH("tileentities"); + for (unsigned int i = 0; i < level->tileEntities.size(); i++) { + TileEntityRenderDispatcher::getInstance()->render(level->tileEntities[i], a); + } glDisableClientState2(GL_VERTEX_ARRAY); glDisableClientState2(GL_TEXTURE_COORD_ARRAY); @@ -991,7 +1005,7 @@ void LevelRenderer::renderEntities(Vec3 cam, Culler* culler, float a) { std::string LevelRenderer::gatherStats1() { std::stringstream ss; ss << "C: " << renderedChunks << "/" << totalChunks << ". F: " << offscreenChunks << ", O: " << occludedChunks << ", E: " << emptyChunks << "\n"; - return ss.str(); + return ss.str(); } // @@ -1003,34 +1017,34 @@ std::string LevelRenderer::gatherStats1() { // IntBuffer resultBuffer = MemoryTracker.createIntBuffer(64); void LevelRenderer::renderSky(float alpha) { - if (mc->level->dimension->foggy) return; + if (mc->level->dimension->foggy) return; - glDisable2(GL_TEXTURE_2D); - Vec3 sc = level->getSkyColor(mc->cameraTargetPlayer, alpha); - float sr = (float) sc.x; - float sg = (float) sc.y; - float sb = (float) sc.z;// + 0.5f; + glDisable2(GL_TEXTURE_2D); + Vec3 sc = level->getSkyColor(mc->cameraTargetPlayer, alpha); + float sr = (float) sc.x; + float sg = (float) sc.y; + float sb = (float) sc.z;// + 0.5f; - if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) { - float srr = (sr * 30.0f + sg * 59.0f + sb * 11.0f) / 100.0f; - float sgg = (sr * 30.0f + sg * 70.0f) / (100.0f); - float sbb = (sr * 30.0f + sb * 70.0f) / (100.0f); + if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) { + float srr = (sr * 30.0f + sg * 59.0f + sb * 11.0f) / 100.0f; + float sgg = (sr * 30.0f + sg * 70.0f) / (100.0f); + float sbb = (sr * 30.0f + sb * 70.0f) / (100.0f); - sr = srr; - sg = sgg; - sb = sbb; - } - glColor4f2(sr, sg, Mth::Min(1.0f, sb), 1); + sr = srr; + sg = sgg; + sb = sbb; + } + glColor4f2(sr, sg, Mth::Min(1.0f, sb), 1); - //Tesselator& t = Tesselator::instance; + //Tesselator& t = Tesselator::instance; - glEnable2(GL_FOG); - glColor4f2(sr, sg, sb, 1.0f); + glEnable2(GL_FOG); + glColor4f2(sr, sg, sb, 1.0f); #ifdef OPENGL_ES drawArrayVT(skyBuffer, skyVertexCount); #endif - glEnable2(GL_TEXTURE_2D); + glEnable2(GL_TEXTURE_2D); } void LevelRenderer::renderClouds( float alpha ) { @@ -1044,7 +1058,7 @@ void LevelRenderer::renderClouds( float alpha ) { //glBindTexture(GL_TEXTURE_2D, texturesloadTexture("/environment/clouds.png")); textures->loadAndBindTexture("environment/clouds.png"); - + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1087,17 +1101,17 @@ void LevelRenderer::playSound(const std::string& name, float x, float y, float z // @todo: deny sounds here if sound is off (rather than waiting 'til SoundEngine) float dd = 16; - if (volume > 1) dd *= volume; - if (mc->cameraTargetPlayer->distanceToSqr(x, y, z) < dd * dd) { - mc->soundEngine->play(name, x, y, z, volume, pitch); - } + if (volume > 1) dd *= volume; + if (mc->cameraTargetPlayer->distanceToSqr(x, y, z) < dd * dd) { + mc->soundEngine->play(name, x, y, z, volume, pitch); + } } void LevelRenderer::addParticle(const std::string& name, float x, float y, float z, float xa, float ya, float za, int data) { float xd = mc->cameraTargetPlayer->x - x; - float yd = mc->cameraTargetPlayer->y - y; - float zd = mc->cameraTargetPlayer->z - z; + float yd = mc->cameraTargetPlayer->y - y; + float zd = mc->cameraTargetPlayer->z - z; float distanceSquared = xd * xd + yd * yd + zd * zd; //Particle* p = NULL; @@ -1111,27 +1125,27 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float // return; //} - const float particleDistance = 16; - if (distanceSquared > particleDistance * particleDistance) return; + const float particleDistance = 16; + if (distanceSquared > particleDistance * particleDistance) return; //static Stopwatch sw; //sw.start(); - if (name == "bubble") mc->particleEngine->add(new BubbleParticle(level, x, y, z, xa, ya, za)); + if (name == "bubble") mc->particleEngine->add(new BubbleParticle(level, x, y, z, xa, ya, za)); else if (name == "crit") mc->particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za)); else if (name == "smoke") mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za)); - //else if (name == "note") mc->particleEngine->add(new NoteParticle(level, x, y, z, xa, ya, za)); - else if (name == "explode") mc->particleEngine->add(new ExplodeParticle(level, x, y, z, xa, ya, za)); - else if (name == "flame") mc->particleEngine->add(new FlameParticle(level, x, y, z, xa, ya, za)); - else if (name == "lava") mc->particleEngine->add(new LavaParticle(level, x, y, z)); - //else if (name == "splash") mc->particleEngine->add(new SplashParticle(level, x, y, z, xa, ya, za)); + //else if (name == "note") mc->particleEngine->add(new NoteParticle(level, x, y, z, xa, ya, za)); + else if (name == "explode") mc->particleEngine->add(new ExplodeParticle(level, x, y, z, xa, ya, za)); + else if (name == "flame") mc->particleEngine->add(new FlameParticle(level, x, y, z, xa, ya, za)); + else if (name == "lava") mc->particleEngine->add(new LavaParticle(level, x, y, z)); + //else if (name == "splash") mc->particleEngine->add(new SplashParticle(level, x, y, z, xa, ya, za)); else if (name == "largesmoke") mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f)); - else if (name == "reddust") mc->particleEngine->add(new RedDustParticle(level, x, y, z, xa, ya, za)); + else if (name == "reddust") mc->particleEngine->add(new RedDustParticle(level, x, y, z, xa, ya, za)); else if (name == "iconcrack") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data])); else if (name == "snowballpoof") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall)); - //else if (name == "snowballpoof") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall)); - //else if (name == "slime") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::slimeBall)); - //else if (name == "heart") mc->particleEngine->add(new HeartParticle(level, x, y, z, xa, ya, za)); + //else if (name == "snowballpoof") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::snowBall)); + //else if (name == "slime") mc->particleEngine->add(new BreakingItemParticle(level, x, y, z, Item::slimeBall)); + //else if (name == "heart") mc->particleEngine->add(new HeartParticle(level, x, y, z, xa, ya, za)); //sw.stop(); //sw.printEvery(50, "add-particle-string"); @@ -1139,53 +1153,53 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float /* void LevelRenderer::addParticle(ParticleType::Id name, float x, float y, float z, float xa, float ya, float za, int data) { - float xd = mc->cameraTargetPlayer->x - x; - float yd = mc->cameraTargetPlayer->y - y; - float zd = mc->cameraTargetPlayer->z - z; +float xd = mc->cameraTargetPlayer->x - x; +float yd = mc->cameraTargetPlayer->y - y; +float zd = mc->cameraTargetPlayer->z - z; - const float particleDistance = 16; - if (xd * xd + yd * yd + zd * zd > particleDistance * particleDistance) return; +const float particleDistance = 16; +if (xd * xd + yd * yd + zd * zd > particleDistance * particleDistance) return; - //static Stopwatch sw; - //sw.start(); +//static Stopwatch sw; +//sw.start(); - //Particle* p = NULL; +//Particle* p = NULL; - if (name == ParticleType::bubble) mc->particleEngine->add( new BubbleParticle(level, x, y, z, xa, ya, za) ); - else if (name == ParticleType::crit) mc->particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za) ); - else if (name == ParticleType::smoke) mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za) ); - else if (name == ParticleType::explode) mc->particleEngine->add( new ExplodeParticle(level, x, y, z, xa, ya, za) ); - else if (name == ParticleType::flame) mc->particleEngine->add( new FlameParticle(level, x, y, z, xa, ya, za) ); - else if (name == ParticleType::lava) mc->particleEngine->add( new LavaParticle(level, x, y, z) ); - else if (name == ParticleType::largesmoke) mc->particleEngine->add( new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f) ); - else if (name == ParticleType::reddust) mc->particleEngine->add( new RedDustParticle(level, x, y, z, xa, ya, za) ); - else if (name == ParticleType::iconcrack) mc->particleEngine->add( new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]) ); +if (name == ParticleType::bubble) mc->particleEngine->add( new BubbleParticle(level, x, y, z, xa, ya, za) ); +else if (name == ParticleType::crit) mc->particleEngine->add(new CritParticle2(level, x, y, z, xa, ya, za) ); +else if (name == ParticleType::smoke) mc->particleEngine->add(new SmokeParticle(level, x, y, z, xa, ya, za) ); +else if (name == ParticleType::explode) mc->particleEngine->add( new ExplodeParticle(level, x, y, z, xa, ya, za) ); +else if (name == ParticleType::flame) mc->particleEngine->add( new FlameParticle(level, x, y, z, xa, ya, za) ); +else if (name == ParticleType::lava) mc->particleEngine->add( new LavaParticle(level, x, y, z) ); +else if (name == ParticleType::largesmoke) mc->particleEngine->add( new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f) ); +else if (name == ParticleType::reddust) mc->particleEngine->add( new RedDustParticle(level, x, y, z, xa, ya, za) ); +else if (name == ParticleType::iconcrack) mc->particleEngine->add( new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]) ); - //switch (name) { - // case ParticleType::bubble: p = new BubbleParticle(level, x, y, z, xa, ya, za); break; - // case ParticleType::crit: p = new CritParticle2(level, x, y, z, xa, ya, za); break; - // case ParticleType::smoke: p = new SmokeParticle(level, x, y, z, xa, ya, za); break; - // //case ParticleType::note: p = new NoteParticle(level, x, y, z, xa, ya, za); break; - // case ParticleType::explode: p = new ExplodeParticle(level, x, y, z, xa, ya, za); break; - // case ParticleType::flame: p = new FlameParticle(level, x, y, z, xa, ya, za); break; - // case ParticleType::lava: p = new LavaParticle(level, x, y, z); break; - // //case ParticleType::splash: p = new SplashParticle(level, x, y, z, xa, ya, za); break; - // case ParticleType::largesmoke: p = new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f); break; - // case ParticleType::reddust: p = new RedDustParticle(level, x, y, z, xa, ya, za); break; - // case ParticleType::iconcrack: p = new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]); break; - // //case ParticleType::snowballpoof: p = new BreakingItemParticle(level, x, y, z, Item::snowBall); break; - // //case ParticleType::slime: p = new BreakingItemParticle(level, x, y, z, Item::slimeBall); break; - // //case ParticleType::heart: p = new HeartParticle(level, x, y, z, xa, ya, za); break; - // default: - // LOGW("Couldn't find particle of type: %d\n", name); - // break; - //} - //if (p) { - // mc->particleEngine->add(p); - //} +//switch (name) { +// case ParticleType::bubble: p = new BubbleParticle(level, x, y, z, xa, ya, za); break; +// case ParticleType::crit: p = new CritParticle2(level, x, y, z, xa, ya, za); break; +// case ParticleType::smoke: p = new SmokeParticle(level, x, y, z, xa, ya, za); break; +// //case ParticleType::note: p = new NoteParticle(level, x, y, z, xa, ya, za); break; +// case ParticleType::explode: p = new ExplodeParticle(level, x, y, z, xa, ya, za); break; +// case ParticleType::flame: p = new FlameParticle(level, x, y, z, xa, ya, za); break; +// case ParticleType::lava: p = new LavaParticle(level, x, y, z); break; +// //case ParticleType::splash: p = new SplashParticle(level, x, y, z, xa, ya, za); break; +// case ParticleType::largesmoke: p = new SmokeParticle(level, x, y, z, xa, ya, za, 2.5f); break; +// case ParticleType::reddust: p = new RedDustParticle(level, x, y, z, xa, ya, za); break; +// case ParticleType::iconcrack: p = new BreakingItemParticle(level, x, y, z, xa, ya, za, Item::items[data]); break; +// //case ParticleType::snowballpoof: p = new BreakingItemParticle(level, x, y, z, Item::snowBall); break; +// //case ParticleType::slime: p = new BreakingItemParticle(level, x, y, z, Item::slimeBall); break; +// //case ParticleType::heart: p = new HeartParticle(level, x, y, z, xa, ya, za); break; +// default: +// LOGW("Couldn't find particle of type: %d\n", name); +// break; +//} +//if (p) { +// mc->particleEngine->add(p); +//} - //sw.stop(); - //sw.printEvery(50, "add-particle-enum"); +//sw.stop(); +//sw.printEvery(50, "add-particle-enum"); } */ @@ -1203,7 +1217,7 @@ void LevelRenderer::renderHitSelect( Player* player, const HitResult& h, int mod glEnable2(GL_DEPTH_TEST); textures->loadAndBindTexture("terrain.png"); - + int tileId = level->getTile(h.x, h.y, h.z); Tile* tile = tileId > 0 ? Tile::tiles[tileId] : NULL; glDisable2(GL_ALPHA_TEST); @@ -1300,11 +1314,11 @@ void LevelRenderer::takePicture( TripodCamera* cam, Entity* entity ) void LevelRenderer::levelEvent(Player* player, int type, int x, int y, int z, int data) { switch (type) { case LevelEvent::SOUND_OPEN_DOOR: - if (Mth::random() < 0.5f) { - level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, "random.door_open", 1, level->random.nextFloat() * 0.1f + 0.9f); - } else { - level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, "random.door_close", 1, level->random.nextFloat() * 0.1f + 0.9f); - } - break; + if (Mth::random() < 0.5f) { + level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, "random.door_open", 1, level->random.nextFloat() * 0.1f + 0.9f); + } else { + level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, "random.door_close", 1, level->random.nextFloat() * 0.1f + 0.9f); + } + break; } } diff --git a/src/client/renderer/LevelRenderer.h b/src/client/renderer/LevelRenderer.h index df43de1..2a9c7e2 100755 --- a/src/client/renderer/LevelRenderer.h +++ b/src/client/renderer/LevelRenderer.h @@ -113,6 +113,9 @@ private: bool occlusionCheck; int lastViewDistance; + // shredder added again... + int lastFogType; + int ticks; int starList, skyList, darkList; diff --git a/src/client/renderer/entity/EntityRenderDispatcher.cpp b/src/client/renderer/entity/EntityRenderDispatcher.cpp index a3148fc..b0edea7 100755 --- a/src/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/src/client/renderer/entity/EntityRenderDispatcher.cpp @@ -40,18 +40,18 @@ EntityRenderDispatcher::EntityRenderDispatcher() { //@note: The Models (model/armor) will be deleted by resp. MobRenderer assign( ER_ITEM_RENDERER, new ItemRenderer()); - assign( ER_HUMANOID_RENDERER, new HumanoidMobRenderer(new HumanoidModel(), 0)); - assign( ER_PIG_RENDERER, new PigRenderer(new PigModel(), NULL/*new PigModel(0.5f)*/, 0)); - assign( ER_COW_RENDERER, new MobRenderer(new CowModel(), 0)); - assign( ER_CHICKEN_RENDERER, new ChickenRenderer( new ChickenModel(), 0)); - assign( ER_SHEEP_RENDERER, new SheepRenderer(new SheepModel(), new SheepFurModel(), 0)); + assign( ER_HUMANOID_RENDERER, new HumanoidMobRenderer(new HumanoidModel(), 0.5)); + assign( ER_PIG_RENDERER, new PigRenderer(new PigModel(0.5), NULL/*new PigModel(0.5f)*/, 0.7)); + assign( ER_COW_RENDERER, new MobRenderer(new CowModel(), 0.7)); + assign( ER_CHICKEN_RENDERER, new ChickenRenderer( new ChickenModel(), 0.3)); + assign( ER_SHEEP_RENDERER, new SheepRenderer(new SheepModel(), new SheepFurModel(), 0.7)); assign( ER_SKELETON_RENDERER, new HumanoidMobRenderer(new SkeletonModel(), 0.5f)); assign( ER_ZOMBIE_RENDERER, new HumanoidMobRenderer(new ZombieModel(), 0.5f)); assign( ER_CREEPER_RENDERER, new CreeperRenderer()); 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, 0, 64, 64), 0)); + assign( ER_PLAYER_RENDERER, new PlayerRenderer(new HumanoidModel(0, 0, 64, 64), 0.5)); 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()); @@ -133,7 +133,7 @@ void EntityRenderDispatcher::render( Entity* entity, float x, float y, float z, EntityRenderer* renderer = getRenderer(entity); if (renderer != NULL) { renderer->render(entity, x, y, z, rot, a); - //renderer->postRender(entity, x, y, z, rot, a); + renderer->postRender(entity, x, y, z, rot, a); } } diff --git a/src/client/renderer/entity/EntityRenderer.cpp b/src/client/renderer/entity/EntityRenderer.cpp index 641581b..ad500b2 100755 --- a/src/client/renderer/entity/EntityRenderer.cpp +++ b/src/client/renderer/entity/EntityRenderer.cpp @@ -5,11 +5,17 @@ #include "../gles.h" #include "../../../world/phys/AABB.h" #include "EntityRenderDispatcher.h" +#include "../../../util/Mth.h" +#include "../../../world/level/Level.h" +#include "../../../world/level/tile/Tile.h" + +#include "../../Minecraft.h" +#include "../../Option.h" EntityRenderDispatcher* EntityRenderer::entityRenderDispatcher = NULL; EntityRenderer::EntityRenderer() -: shadowRadius(0), + : shadowRadius(0), shadowStrength(1.0f) {} @@ -36,37 +42,37 @@ void EntityRenderer::render(const AABB& bb, float xo, float yo, float zo) { glColor4f2(1, 1, 1, 1); t.begin(); t.offset(xo, yo, zo); - //t.normal(0, 0, -1); + t.normal(0, 0, -1); t.vertex(bb.x0, bb.y1, bb.z0); t.vertex(bb.x1, bb.y1, bb.z0); t.vertex(bb.x1, bb.y0, bb.z0); t.vertex(bb.x0, bb.y0, bb.z0); - //t.normal(0, 0, 1); + t.normal(0, 0, 1); t.vertex(bb.x0, bb.y0, bb.z1); t.vertex(bb.x1, bb.y0, bb.z1); t.vertex(bb.x1, bb.y1, bb.z1); t.vertex(bb.x0, bb.y1, bb.z1); - //t.normal(0, -1, 0); + t.normal(0, -1, 0); t.vertex(bb.x0, bb.y0, bb.z0); t.vertex(bb.x1, bb.y0, bb.z0); t.vertex(bb.x1, bb.y0, bb.z1); t.vertex(bb.x0, bb.y0, bb.z1); - //t.normal(0, 1, 0); + t.normal(0, 1, 0); t.vertex(bb.x0, bb.y1, bb.z1); t.vertex(bb.x1, bb.y1, bb.z1); t.vertex(bb.x1, bb.y1, bb.z0); t.vertex(bb.x0, bb.y1, bb.z0); - //t.normal(-1, 0, 0); + t.normal(-1, 0, 0); t.vertex(bb.x0, bb.y0, bb.z1); t.vertex(bb.x0, bb.y1, bb.z1); t.vertex(bb.x0, bb.y1, bb.z0); t.vertex(bb.x0, bb.y0, bb.z0); - //t.normal(1, 0, 0); + t.normal(1, 0, 0); t.vertex(bb.x1, bb.y0, bb.z0); t.vertex(bb.x1, bb.y1, bb.z0); t.vertex(bb.x1, bb.y1, bb.z1); @@ -116,134 +122,139 @@ Font* EntityRenderer::getFont() { return entityRenderDispatcher->getFont(); } -//void postRender(Entity entity, float x, float y, float z, float rot, float a) { -// if (entityRenderDispatcher.options.fancyGraphics && shadowRadius > 0) { -// float dist = entityRenderDispatcher.distanceToSqr(entity.x, entity.y, entity.z); -// float pow = (float) ((1 - dist / (16.0f * 16.0f)) * shadowStrength); -// if (pow > 0) { -// renderShadow(entity, x, y, z, pow, a); -// } -// } -// if (entity.isOnFire()) renderFlame(entity, x, y, z, a); -//} +void EntityRenderer::postRender(Entity* entity, float x, float y, float z, float rot, float a) { + if (/*entityRenderDispatcher.options.fancyGraphics &&*/entityRenderDispatcher->minecraft->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS) && shadowRadius > 0) { + float dist = entityRenderDispatcher->distanceToSqr(entity->x, entity->y, entity->z); + float pow = (float) ((1 - dist / (16.0f * 16.0f)) * shadowStrength); + if (pow > 0) { + renderShadow(entity, x, y, z, pow, a); + } + //} + if (entity->isOnFire()) renderFlame(entity, x, y, z, a); + } +} +void EntityRenderer::renderFlame(Entity* e, float x, float y, float z, float a) { -//void renderFlame(Entity e, float x, float y, float z, float a) { -// glDisable2(GL_LIGHTING); -// int tex = Tile.fire.tex; + int tex = ((Tile*)Tile::fire)->tex; -// int xt = (tex & 0xf) << 4; -// int yt = tex & 0xf0; + int xt = (tex & 0xf) << 4; + int yt = tex & 0xf0; -// float u0 = (xt) / 256.0f; -// float u1 = (xt + 15.99f) / 256.0f; -// float v0 = (yt) / 256.0f; -// float v1 = (yt + 15.99f) / 256.0f; + float u0 = (xt) / 256.0f; + float u1 = (xt + 15.99f) / 256.0f; + float v0 = (yt) / 256.0f; + float v1 = (yt + 15.99f) / 256.0f; -// glPushMatrix2(); -// glTranslatef2((float) x, (float) y, (float) z); + glPushMatrix2(); + glTranslatef2((float) x, (float) y, (float) z); -// float s = e.bbWidth * 1.4f; -// glScalef2(s, s, s); -// bindTexture("terrain.png"); -// Tesselator t = Tesselator.instance; + float s = e->bbWidth * 1.4f; + glScalef2(s, s, s); + bindTexture("terrain.png"); + Tesselator& t = Tesselator::instance; -// float r = 1.0f; -// float xo = 0.5f; -// float yo = 0.0f; + float r = 1.0f; + float xo = 0.5f; + float yo = 0.0f; -// float h = e.bbHeight / e.bbWidth; + float h = e->bbHeight / e->bbWidth; -// glRotatef2(-entityRenderDispatcher.playerRotY, 0, 1, 0); -// glTranslatef2(0, 0, -0.4f + ((int) h) * 0.02f); -// glColor4f2(1, 1, 1, 1); -// // glRotatef2(-playerRotX, 1, 0, 0); -// t.begin(); -// while (h > 0) { -// t.vertexUV(r - xo, 0 - yo, 0, u1, v1); -// t.vertexUV(0 - xo, 0 - yo, 0, u0, v1); -// t.vertexUV(0 - xo, 1.4f - yo, 0, u0, v0); -// t.vertexUV(r - xo, 1.4f - yo, 0, u1, v0); -// h -= 1; -// yo -= 1; -// r *= 0.9f; -// glTranslatef2(0, 0, -0.04f); -// } -// t.end(); -// glPopMatrix2(); -// glEnable2(GL_LIGHTING); -//} + glRotatef2(-entityRenderDispatcher->playerRotY, 0, 1, 0); + glTranslatef2(0, 0, -0.4f + ((int) h) * 0.02f); + glColor4f2(1, 1, 1, 1); + // glRotatef2(-playerRotX, 1, 0, 0); + t.begin(); + while (h > 0) { + t.vertexUV(r - xo, 0 - yo, 0, u1, v1); + t.vertexUV(0 - xo, 0 - yo, 0, u0, v1); + t.vertexUV(0 - xo, 1.4f - yo, 0, u0, v0); + t.vertexUV(r - xo, 1.4f - yo, 0, u1, v0); + h -= 1; + yo -= 1; + r *= 0.9f; + glTranslatef2(0, 0, -0.04f); + } + t.draw(); + glPopMatrix2(); + // glEnable2(GL_LIGHTING); +} -//void renderShadow(Entity e, float x, float y, float z, float pow, float a) { -// glEnable2(GL_BLEND); -// glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float pow, float a) { // + glEnable2(GL_BLEND); + glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -// Textures textures = entityRenderDispatcher.textures; -// textures.bind(textures.loadTexture("%clamp%/misc/shadow.png")); + //Textures* textures = entityRenderDispatcher->textures; + //textures->bind(textures->loadTexture("%clamp%/environment/shadow.png")); + Textures* textures = entityRenderDispatcher->textures; + textures->bind(textures->loadTexture("/misc/shadow.png")); -// Level level = getLevel(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -// glDepthMask(false); -// float r = shadowRadius; + Level* level = getLevel(); -// float ex = e.xOld + (e.x - e.xOld) * a; -// float ey = e.yOld + (e.y - e.yOld) * a + e.getShadowHeightOffs(); -// float ez = e.zOld + (e.z - e.zOld) * a; + glDepthMask(false); + float r = shadowRadius; -// int x0 = Mth.floor(ex - r); -// int x1 = Mth.floor(ex + r); -// int y0 = Mth.floor(ey - r); -// int y1 = Mth.floor(ey); -// int z0 = Mth.floor(ez - r); -// int z1 = Mth.floor(ez + r); + float ex = e->xOld + (e->x - e->xOld) * a; + float ey = e->yOld + (e->y - e->yOld) * a + e->getShadowHeightOffs(); + float ez = e->zOld + (e->z - e->zOld) * a; -// float xo = x - ex; -// float yo = y - ey; -// float zo = z - ez; + int x0 = Mth::floor(ex - r); + int x1 = Mth::floor(ex + r); + int y0 = Mth::floor(ey - r); + int y1 = Mth::floor(ey); + int z0 = Mth::floor(ez - r); + int z1 = Mth::floor(ez + r); -// Tesselator tt = Tesselator.instance; -// tt.begin(); -// for (int xt = x0; xt <= x1; xt++) -// for (int yt = y0; yt <= y1; yt++) -// for (int zt = z0; zt <= z1; zt++) { -// int t = level.getTile(xt, yt - 1, zt); -// if (t > 0 && level.getRawBrightness(xt, yt, zt) > 3) { -// renderTileShadow(Tile.tiles[t], x, y + e.getShadowHeightOffs(), z, xt, yt, zt, pow, r, xo, yo + e.getShadowHeightOffs(), zo); -// } -// } -// tt.end(); + float xo = x - ex; + float yo = y - ey; + float zo = z - ez; -// glColor4f2(1, 1, 1, 1); -// glDisable2(GL_BLEND); -// glDepthMask(true); -//} + Tesselator& tt = Tesselator::instance; + tt.begin(); + for (int xt = x0; xt <= x1; xt++) + for (int yt = y0; yt <= y1; yt++) + for (int zt = z0; zt <= z1; zt++) { + int t = level->getTile(xt, yt - 1, zt); + if (t > 0 && level->getRawBrightness(xt, yt, zt) > 3) { + renderTileShadow(Tile::tiles[t], x, y + e->getShadowHeightOffs(), z, xt, yt, zt, pow, r, xo, yo + e->getShadowHeightOffs(), zo); + } + } + tt.draw(); -//Level* getLevel() { -// return entityRenderDispatcher.level; -//} + glColor4f2(1, 1, 1, 1); + glDisable2(GL_BLEND); + glDepthMask(true); +} -//void renderTileShadow(Tile tt, float x, float y, float z, int xt, int yt, int zt, float pow, float r, float xo, float yo, float zo) { -// Tesselator t = Tesselator.instance; -// if (!tt.isCubeShaped()) return; +Level* EntityRenderer::getLevel() { + return entityRenderDispatcher->level; +} -// float a = ((pow - (y - (yt + yo)) / 2) * 0.5f) * getLevel().getBrightness(xt, yt, zt); -// if (a < 0) return; -// if (a > 1) a = 1; -// t.color(1, 1, 1, (float) a); -// // glColor4f2(1, 1, 1, (float) a); +void EntityRenderer::renderTileShadow(Tile* tt, float x, float y, float z, int xt, int yt, int zt, float pow, float r, float xo, float yo, float zo) { + Tesselator& t = Tesselator::instance; + if (!tt->isCubeShaped()) return; -// float x0 = xt + tt.xx0 + xo; -// float x1 = xt + tt.xx1 + xo; -// float y0 = yt + tt.yy0 + yo + 1.0 / 64.0f; -// float z0 = zt + tt.zz0 + zo; -// float z1 = zt + tt.zz1 + zo; + float a = ((pow - (y - (yt + yo)) / 2) * 0.5f) * getLevel()->getBrightness(xt, yt, zt); + if (a < 0) return; + if (a > 1) a = 1; + // t.color(1, 1, 1, (float) a); + glColor4f2(1, 1, 1, (float) a); -// float u0 = (float) ((x - (x0)) / 2 / r + 0.5f); -// float u1 = (float) ((x - (x1)) / 2 / r + 0.5f); -// float v0 = (float) ((z - (z0)) / 2 / r + 0.5f); -// float v1 = (float) ((z - (z1)) / 2 / r + 0.5f); + float x0 = xt + tt->xx0 + xo; + float x1 = xt + tt->xx1 + xo; + float y0 = yt + tt->yy0 + yo + 1.0 / 64.0f; + float z0 = zt + tt->zz0 + zo; + float z1 = zt + tt->zz1 + zo; -// t.vertexUV(x0, y0, z0, u0, v0); -// t.vertexUV(x0, y0, z1, u0, v1); -// t.vertexUV(x1, y0, z1, u1, v1); -// t.vertexUV(x1, y0, z0, u1, v0); -//} + float u0 = (float) ((x - (x0)) / 2 / r + 0.5f); + float u1 = (float) ((x - (x1)) / 2 / r + 0.5f); + float v0 = (float) ((z - (z0)) / 2 / r + 0.5f); + float v1 = (float) ((z - (z1)) / 2 / r + 0.5f); + + t.vertexUV(x0, y0, z0, u0, v0); + t.vertexUV(x0, y0, z1, u0, v1); + t.vertexUV(x1, y0, z1, u1, v1); + t.vertexUV(x1, y0, z0, u1, v0); +} diff --git a/src/client/renderer/entity/EntityRenderer.h b/src/client/renderer/entity/EntityRenderer.h index 318f7f2..699c82d 100755 --- a/src/client/renderer/entity/EntityRenderer.h +++ b/src/client/renderer/entity/EntityRenderer.h @@ -12,6 +12,8 @@ class EntityRenderDispatcher; class Entity; class AABB; class Font; +class Tile; +class Level; class EntityRenderer { @@ -24,6 +26,11 @@ public: virtual void render(Entity* entity, float x, float y, float z, float rot, float a) = 0; static void render(const AABB& bb, float xo, float yo, float zo); static void renderFlat(const AABB& bb); + void renderShadow(Entity* e, float x, float y, float z, float pow, float a); + void renderTileShadow(Tile* tt, float x, float y, float z, int xt, int yt, int zt, float pow, float r, float xo, float yo, float zo); + void renderFlame(Entity* e, float x, float y, float z, float a); + void postRender(Entity* entity, float x, float y, float z, float rot, float a); + Level* getLevel(); Font* getFont(); diff --git a/src/client/renderer/entity/ItemRenderer.cpp b/src/client/renderer/entity/ItemRenderer.cpp index 15e63d1..eaf29b4 100755 --- a/src/client/renderer/entity/ItemRenderer.cpp +++ b/src/client/renderer/entity/ItemRenderer.cpp @@ -226,7 +226,40 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, const ItemInsta t.draw(); } -void ItemRenderer::renderGuiItemDecorations(const ItemInstance* item, float x, float y) { + +void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures, ItemInstance* item, int x, int y){ // this is normally unused in the header but i ported it from java beta - shredder + if (item != NULL) { + if (item->count > 1) { + std::string countStr = std::to_string(item->count); + // glDisable(GL_LIGHTING); + // glDisable(GL_DEPTH_TEST); + font->drawShadow(countStr, x + 19 - 2 - font->width(countStr), + y + 6 + 3, 0xFFFFFF); + // glEnable(GL_LIGHTING); + // glEnable(GL_DEPTH_TEST); + } + if (item->isDamaged()) { + float p = std::floor(13.5f - (float) item->getDamageValue() * 13.0f / (float) item->getMaxDamage() + 0.5); + int cc = (int) std::floor(255.5f - (float) item->getDamageValue() * 255.0f / (float) item->getMaxDamage() + 0.5); + // glDisable(GL_LIGHTING); + // glDisable(GL_DEPTH_TEST); + // glDisable(GL_TEXTURE_2D); + // auto var8 = ::net::minecraft::client::renderer::Tesselator::instance(); + Tesselator& t = Tesselator::instance; + int ca = 255 - cc << 16 | cc << 8; + int cb = (255 - cc) / 4 << 16 | 16128; + fillRect(t, x + 2, y + 13, 13, 2, 0); + fillRect(t, x + 2, y + 13, 12, 1, cb); + fillRect(t, x + 2, y + 13, p, 1, ca); + // glEnable(GL_TEXTURE_2D); + // glEnable(GL_LIGHTING); + // glEnable(GL_DEPTH_TEST); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } + } +} + +void ItemRenderer::renderGuiItemDecorations(const ItemInstance* item, float x, float y) { // nothing changed here this is the normal pocket edition one. if (!item) return; if (item->count > 0 && item->isDamaged()) { float p = std::floor(13.5f - (float) item->getDamageValue() * 13.0f / (float) item->getMaxDamage()); diff --git a/src/client/renderer/entity/ItemRenderer.h b/src/client/renderer/entity/ItemRenderer.h index 9fb88f6..a104dc7 100755 --- a/src/client/renderer/entity/ItemRenderer.h +++ b/src/client/renderer/entity/ItemRenderer.h @@ -22,7 +22,7 @@ public: static void renderGuiItem(Font* font, Textures* textures, const ItemInstance* item, float x, float y, bool fancy); static void renderGuiItem(Font* font, Textures* textures, const ItemInstance* item, float x, float y, float w, float h, bool fancy); static void renderGuiItemCorrect(Font* font, Textures* textures, const ItemInstance* item, int x, int y); - //void renderGuiItemDecorations(Font* font, Textures* textures, ItemInstance* item, int x, int y); + static void renderGuiItemDecorations(Font* font, Textures* textures, ItemInstance* item, int x, int y); static void renderGuiItemDecorations(const ItemInstance* item, float x, float y); static void blit(float x, float y, float sx, float sy, float w, float h); diff --git a/src/client/renderer/entity/MobRenderer.cpp b/src/client/renderer/entity/MobRenderer.cpp index 51ccee9..3d6b3d9 100755 --- a/src/client/renderer/entity/MobRenderer.cpp +++ b/src/client/renderer/entity/MobRenderer.cpp @@ -135,7 +135,7 @@ void MobRenderer::render(Entity* e, float x, float y, float z, float rot, float //glEnable2(GL_DEPTH_TEST); glPopMatrix2(); - + postRender(mob, x, y, z, rot, a); renderName(mob, x, y, z); } diff --git a/src/util/Color.cpp b/src/util/Color.cpp new file mode 100644 index 0000000..9afaa5c --- /dev/null +++ b/src/util/Color.cpp @@ -0,0 +1,98 @@ +#include "Mth.h" + +#include "Color.h" +#include + +//Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0). +//Alpha is defaulted to 1.0. The actual color used in rendering depends on finding the best match given the color space +//available for a particular output device. +//Parameters: +//r - the red component +//g - the green component +//b - the blue component +//Throws: +//IllegalArgumentException - if r, g or b are outside of the range 0.0 to 1.0, inclusive +Color::Color( float r, float g, float b) +{ + assert( r >= 0.0f && r <= 1.0f ); + assert( g >= 0.0f && g <= 1.0f ); + assert( b >= 0.0f && b <= 1.0f ); + + //argb + colour = ( (0xFF<<24) | ( (int)(r*255)<<16 ) | ( (int)(g*255)<<8 ) | ( (int)(b*255) ) ); +} + +Color::Color( int r, int g, int b) +{ + colour = ( (0xFF<<24) | ( (r&0xff)<<16 ) | ( (g&0xff)<<8 ) | ( (b&0xff) ) ); +} + + +//Creates a Color object based on the specified values for the HSB color model. +//The s and b components should be floating-point values between zero and one (numbers in the range 0.0-1.0). +//The h component can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. +//This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model. +// +//Parameters: +//h - the hue component +//s - the saturation of the color +//b - the brightness of the color +//Returns: +//a Color object with the specified hue, saturation, and brightness. +Color Color::getHSBColor(float hue, float saturation, float brightness) +{ + int r = 0, g = 0, b = 0; + if (saturation == 0) + { + r = g = b = (int) (brightness * 255.0f + 0.5f); + } + else + { + float h = (hue - (float)floor(hue)) * 6.0f; + float f = h - (float)floor(h); + float p = brightness * (1.0f - saturation); + float q = brightness * (1.0f - saturation * f); + float t = brightness * (1.0f - (saturation * (1.0f - f))); + switch ((int) h) + { + case 0: + r = (int) (brightness * 255.0f + 0.5f); + g = (int) (t * 255.0f + 0.5f); + b = (int) (p * 255.0f + 0.5f); + break; + case 1: + r = (int) (q * 255.0f + 0.5f); + g = (int) (brightness * 255.0f + 0.5f); + b = (int) (p * 255.0f + 0.5f); + break; + case 2: + r = (int) (p * 255.0f + 0.5f); + g = (int) (brightness * 255.0f + 0.5f); + b = (int) (t * 255.0f + 0.5f); + break; + case 3: + r = (int) (p * 255.0f + 0.5f); + g = (int) (q * 255.0f + 0.5f); + b = (int) (brightness * 255.0f + 0.5f); + break; + case 4: + r = (int) (t * 255.0f + 0.5f); + g = (int) (p * 255.0f + 0.5f); + b = (int) (brightness * 255.0f + 0.5f); + break; + case 5: + r = (int) (brightness * 255.0f + 0.5f); + g = (int) (p * 255.0f + 0.5f); + b = (int) (q * 255.0f + 0.5f); + break; + } + } + + + return Color( r, g, b ); +} + +int Color::getRGB() +{ + return colour; +} \ No newline at end of file diff --git a/src/util/Color.h b/src/util/Color.h new file mode 100644 index 0000000..a9d31ec --- /dev/null +++ b/src/util/Color.h @@ -0,0 +1,15 @@ +#pragma once + +class Color +{ +private: + int colour; + +public: + //Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0). + Color( float r, float g, float b); + Color( int r, int g, int b); + + static Color getHSBColor(float h, float s, float b); + int getRGB(); +}; \ No newline at end of file diff --git a/src/world/entity/player/Inventory.cpp b/src/world/entity/player/Inventory.cpp index 5a46535..480627b 100755 --- a/src/world/entity/player/Inventory.cpp +++ b/src/world/entity/player/Inventory.cpp @@ -245,6 +245,7 @@ void Inventory::setupDefault() { addItem(new ItemInstance(Item::seeds_melon)); addItem(new ItemInstance(Item::dye_powder, 1, DyePowderItem::WHITE)); addItem(new ItemInstance(Item::hoe_iron)); + addItem(new ItemInstance(Item::flintAndSteel)); #ifdef RPI Sel[0] = addItem(new ItemInstance(Item::sword_iron)); #else diff --git a/src/world/level/Level.cpp b/src/world/level/Level.cpp index c9132f5..bb5ac0e 100755 --- a/src/world/level/Level.cpp +++ b/src/world/level/Level.cpp @@ -30,7 +30,7 @@ #include "../../network/packet/ExplodePacket.h" Level::Level(LevelStorage* levelStorage, const std::string& levelName, const LevelSettings& settings, int generatorVersion, Dimension* fixedDimension /* = NULL */) -: levelStorage(levelStorage), + : levelStorage(levelStorage), isClientSide(false), isFindingSpawn(false), noNeighborUpdate(false), @@ -52,7 +52,7 @@ Level::Level(LevelStorage* levelStorage, const std::string& levelName, const Lev allPlayersAreSleeping(false), _nightMode(false) { - _init(levelName, settings, generatorVersion, fixedDimension); + _init(levelName, settings, generatorVersion, fixedDimension); } Level::~Level() { @@ -85,14 +85,14 @@ void Level::_init(const std::string& levelName, const LevelSettings& settings, i isGeneratingTerrain = false; LevelData* preparedData = levelStorage->prepareLevel(this); - _isNew = (preparedData == NULL); + _isNew = (preparedData == NULL); - if (preparedData == NULL) { - levelData = LevelData(settings, levelName, generatorVersion); - } else { + if (preparedData == NULL) { + levelData = LevelData(settings, levelName, generatorVersion); + } else { levelData = *preparedData; - levelData.setLevelName(levelName); - } + levelData.setLevelName(levelName); + } if (fixedDimension != NULL) { dimension = fixedDimension; @@ -100,12 +100,12 @@ void Level::_init(const std::string& levelName, const LevelSettings& settings, i dimension = DimensionFactory::createDefaultDimension( &levelData ); } - dimension->init(this); - _chunkSource = createChunkSource(); + dimension->init(this); + _chunkSource = createChunkSource(); _pathFinder = new PathFinder(); _nightMode = false; - updateSkyBrightness(); + updateSkyBrightness(); } /*protected*/ @@ -121,63 +121,63 @@ ChunkSource* Level::createChunkSource() { /*public*/ bool Level::checkAndHandleWater(const AABB& box, const Material* material, Entity* e) { - int x0 = Mth::floor(box.x0); - int x1 = Mth::floor(box.x1 + 1); + int x0 = Mth::floor(box.x0); + int x1 = Mth::floor(box.x1 + 1); - int y0 = Mth::floor(box.y0); - int y1 = Mth::floor(box.y1 + 1); + int y0 = Mth::floor(box.y0); + int y1 = Mth::floor(box.y1 + 1); - int z0 = Mth::floor(box.z0); - int z1 = Mth::floor(box.z1 + 1); + int z0 = Mth::floor(box.z0); + int z1 = Mth::floor(box.z1 + 1); - if (!hasChunksAt(x0, y0, z0, x1, y1, z1)) { - return false; - } + if (!hasChunksAt(x0, y0, z0, x1, y1, z1)) { + return false; + } - bool ok = false; - Vec3 current(0,0,0); - for (int x = x0; x < x1; x++) - for (int y = y0; y < y1; y++) - for (int z = z0; z < z1; z++) { - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material == material) { - float yt0 = y + 1 - LiquidTile::getHeight(getData(x, y, z)); - if (y1 >= yt0) { - ok = true; - tile->handleEntityInside(this, x, y, z, e, current); - } - } - } - float len = current.length(); - if (len > 0) { - const float pow = 0.004f / len; - e->xd += current.x * pow; - e->yd += current.y * pow; - e->zd += current.z * pow; - } - return ok; + bool ok = false; + Vec3 current(0,0,0); + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + for (int z = z0; z < z1; z++) { + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile != NULL && tile->material == material) { + float yt0 = y + 1 - LiquidTile::getHeight(getData(x, y, z)); + if (y1 >= yt0) { + ok = true; + tile->handleEntityInside(this, x, y, z, e, current); + } + } + } + float len = current.length(); + if (len > 0) { + const float pow = 0.004f / len; + e->xd += current.x * pow; + e->yd += current.y * pow; + e->zd += current.z * pow; + } + return ok; } /*public*/ Player* Level::getNearestPlayer(Entity* source, float maxDist) { - return getNearestPlayer(source->x, source->y, source->z, maxDist); + return getNearestPlayer(source->x, source->y, source->z, maxDist); } /*public*/ Player* Level::getNearestPlayer(float x, float y, float z, float maxDist) { - float maxDistSqr = maxDist * maxDist; + float maxDistSqr = maxDist * maxDist; float best = -1; - Player* result = NULL; - for (unsigned int i = 0; i < players.size(); i++) { - Player* p = players[i]; + Player* result = NULL; + for (unsigned int i = 0; i < players.size(); i++) { + Player* p = players[i]; if (p->removed) continue; float dist = p->distanceToSqr(x, y, z); - if ((maxDist < 0 || dist < maxDistSqr) && (best == -1 || dist < best)) { - best = dist; - result = p; - } - } - return result; + if ((maxDist < 0 || dist < maxDistSqr) && (best == -1 || dist < best)) { + best = dist; + result = p; + } + } + return result; } /*public*/ @@ -189,7 +189,7 @@ void Level::tick() { _mobSpawnTick = 0; TIMER_PUSH("mobSpawner"); MobSpawner::tick(this, _spawnEnemies && difficulty > Difficulty::PEACEFUL, - _spawnFriendlies && (levelData.getTime() % 400) < MobSpawnInterval); + _spawnFriendlies && (levelData.getTime() % 400) < MobSpawnInterval); TIMER_POP(); } } @@ -231,7 +231,7 @@ void Level::tick() { tickPendingTicks(false); TIMER_POP_PUSH("tickTiles"); - tickTiles(); + tickTiles(); TIMER_POP_PUSH("sendEntityData"); for (unsigned int i = 0; i < entities.size(); ++i) { @@ -255,7 +255,7 @@ void Level::tick() { /*protected*/ void Level::tickTiles() { - _chunksToPoll.clear(); + _chunksToPoll.clear(); static const int pollChunkOffsets[] = { -1,-4, 0,-4, 1,-4, -2,-3, -1,-3, 0,-3, 1,-3, 2,-3, -3,-2, @@ -270,10 +270,10 @@ void Level::tickTiles() { TIMER_PUSH("buildList"); //static Stopwatch w; //w.start(); - for (size_t i = 0; i < players.size(); i++) { - Player* player = players[i]; - int xx = Mth::floor(player->x / 16); - int zz = Mth::floor(player->z / 16); + for (size_t i = 0; i < players.size(); i++) { + Player* player = players[i]; + int xx = Mth::floor(player->x / 16); + int zz = Mth::floor(player->z / 16); for (int i = 0; i < pollChunkOffsetsSize; i += 2) { const int xp = xx + pollChunkOffsets[i]; @@ -282,114 +282,114 @@ void Level::tickTiles() { zp >= 0 && zp < CHUNK_CACHE_WIDTH) _chunksToPoll.insert(ChunkPos(xp, zp)); } - } + } TIMER_POP(); - //if (delayUntilNextMoodSound > 0) delayUntilNextMoodSound--; + //if (delayUntilNextMoodSound > 0) delayUntilNextMoodSound--; TIMER_PUSH("loop"); - for (ChunkPosSet::iterator it = _chunksToPoll.begin(); it != _chunksToPoll.end(); ++it) { + for (ChunkPosSet::iterator it = _chunksToPoll.begin(); it != _chunksToPoll.end(); ++it) { const ChunkPos& cp = *it; - int xo = cp.x * 16; - int zo = cp.z * 16; - // LevelSource region = new Region(this, xo, 0, zo, xo + 16, 128, zo + 16); + int xo = cp.x * 16; + int zo = cp.z * 16; + // LevelSource region = new Region(this, xo, 0, zo, xo + 16, 128, zo + 16); TIMER_PUSH("getChunk"); - LevelChunk* lc = this->getChunk(cp.x, cp.z); + LevelChunk* lc = this->getChunk(cp.x, cp.z); TIMER_POP_PUSH("tickChunk"); //lc->tick(); - //if (delayUntilNextMoodSound == 0) { - // randValue = randValue * 3 + addend; - // int val = (randValue >> 2); - // int x = (val & 15); - // int z = ((val >> 8) & 15); - // int y = ((val >> 16) & 127); + //if (delayUntilNextMoodSound == 0) { + // randValue = randValue * 3 + addend; + // int val = (randValue >> 2); + // int x = (val & 15); + // int z = ((val >> 8) & 15); + // int y = ((val >> 16) & 127); - // int id = lc->getTile(x, y, z); - // x += xo; - // z += zo; - // if (id == 0 && getRawBrightness(x, y, z) <= random.nextInt(8) && getBrightness(LightLayer::Sky, x, y, z) <= 0) { - // Player* player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8); - // if (player != NULL && player.distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2) { - // //this.playSound(x + 0.5, y + 0.5, z + 0.5, "ambient.cave.cave", 0.7f, 0.8f + random.nextFloat() * 0.2f); - // delayUntilNextMoodSound = random.nextInt(20 * 60 * 10) + 20 * 60 * 5; - // } - // } - //} + // int id = lc->getTile(x, y, z); + // x += xo; + // z += zo; + // if (id == 0 && getRawBrightness(x, y, z) <= random.nextInt(8) && getBrightness(LightLayer::Sky, x, y, z) <= 0) { + // Player* player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8); + // if (player != NULL && player.distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2) { + // //this.playSound(x + 0.5, y + 0.5, z + 0.5, "ambient.cave.cave", 0.7f, 0.8f + random.nextFloat() * 0.2f); + // delayUntilNextMoodSound = random.nextInt(20 * 60 * 10) + 20 * 60 * 5; + // } + // } + //} TIMER_POP_PUSH("tickTiles"); - for (int i = 0; i < 20; i++) { //@todo: CHUNK_TILE_TICK_COUNT - _randValue = _randValue * 3 + _addend; - int val = (_randValue >> 2); - int x = (val & 15); - int z = ((val >> 8) & 15); - int y = ((val >> 16) & 127); + for (int i = 0; i < 20; i++) { //@todo: CHUNK_TILE_TICK_COUNT + _randValue = _randValue * 3 + _addend; + int val = (_randValue >> 2); + int x = (val & 15); + int z = ((val >> 8) & 15); + int y = ((val >> 16) & 127); - int id = lc->getTile(x, y, z); - if (Tile::shouldTick[id]) { - Tile::tiles[id]->tick(this, x + xo, y, z + zo, &random); - } - } + int id = lc->getTile(x, y, z); + if (Tile::shouldTick[id]) { + Tile::tiles[id]->tick(this, x + xo, y, z + zo, &random); + } + } TIMER_POP(); - } + } TIMER_POP(); //w.stop(); //w.printEvery(30, "ticktiles"); } bool Level::tickPendingTicks(bool force) { - int count = _tickNextTickSet.size(); - if (count > MAX_TICK_TILES_PER_TICK) count = MAX_TICK_TILES_PER_TICK; - for (int i = 0; i < count; i++) { + int count = _tickNextTickSet.size(); + if (count > MAX_TICK_TILES_PER_TICK) count = MAX_TICK_TILES_PER_TICK; + for (int i = 0; i < count; i++) { TickDataSet::iterator td = _tickNextTickSet.begin(); - if (!force && td->delay > levelData.getTime()) { - break; - } + if (!force && td->delay > levelData.getTime()) { + break; + } int r = 8; - if (hasChunksAt(td->x - r, td->y - r, td->z - r, td->x + r, td->y + r, td->z + r)) { - int id = getTile(td->x, td->y, td->z); - if (id == td->tileId && id > 0) { - Tile::tiles[id]->tick(this, td->x, td->y, td->z, &random); - } - } - _tickNextTickSet.erase(td); - } - return _tickNextTickSet.size() != 0; + if (hasChunksAt(td->x - r, td->y - r, td->z - r, td->x + r, td->y + r, td->z + r)) { + int id = getTile(td->x, td->y, td->z); + if (id == td->tileId && id > 0) { + Tile::tiles[id]->tick(this, td->x, td->y, td->z, &random); + } + } + _tickNextTickSet.erase(td); + } + return _tickNextTickSet.size() != 0; } /*public*/ void Level::loadPlayer(Player* player, bool doAddPlayer /*= true*/) { if (player) { CompoundTag* loadedPlayerTag = levelData.getLoadedPlayerTag(); - if (loadedPlayerTag != NULL) { - player->load(loadedPlayerTag); - levelData.setLoadedPlayerTag(NULL); - } else { + if (loadedPlayerTag != NULL) { + player->load(loadedPlayerTag); + levelData.setLoadedPlayerTag(NULL); + } else { levelData.setLoadedPlayerTo(player); } if (doAddPlayer) addEntity(player); } - //} catch (Exception e) { - // e.printStackTrace(); - //} + //} catch (Exception e) { + // e.printStackTrace(); + //} } bool Level::findPath(Path* path, Entity* from, Entity* to, float maxDist, bool canOpenDoors, bool avoidWater) { - TIMER_PUSH("pathfind"); + TIMER_PUSH("pathfind"); int x = Mth::floor(from->x); - int y = Mth::floor(from->y); - int z = Mth::floor(from->z); + int y = Mth::floor(from->y); + int z = Mth::floor(from->z); - int r = (int) (maxDist + 16); - int x1 = x - r; - int y1 = y - r; - int z1 = z - r; - int x2 = x + r; - int y2 = y + r; - int z2 = z + r; + int r = (int) (maxDist + 16); + int x1 = x - r; + int y1 = y - r; + int z1 = z - r; + int x2 = x + r; + int y2 = y + r; + int z2 = z + r; //LOGI("trying to move! 1: %ld\n", levelData.getTime()); - Region region(this, x1, y1, z1, x2, y2, z2); + Region region(this, x1, y1, z1, x2, y2, z2); _pathFinder->setLevelSource(®ion); _pathFinder->canOpenDoors = canOpenDoors; _pathFinder->avoidWater = avoidWater; @@ -399,24 +399,24 @@ bool Level::findPath(Path* path, Entity* from, Entity* to, float maxDist, bool c } bool Level::findPath(Path* path, Entity* from, int xBest, int yBest, int zBest, float maxDist, bool canOpenDoors, bool avoidWater) { - TIMER_PUSH("pathfind"); + TIMER_PUSH("pathfind"); int x = Mth::floor(from->x); - int y = Mth::floor(from->y); - int z = Mth::floor(from->z); + int y = Mth::floor(from->y); + int z = Mth::floor(from->z); - int r = (int) (maxDist + 8); - int x1 = x - r; - int y1 = y - r; - int z1 = z - r; - int x2 = x + r; - int y2 = y + r; - int z2 = z + r; - Region region(this, x1, y1, z1, x2, y2, z2); + int r = (int) (maxDist + 8); + int x1 = x - r; + int y1 = y - r; + int z1 = z - r; + int x2 = x + r; + int y2 = y + r; + int z2 = z + r; + Region region(this, x1, y1, z1, x2, y2, z2); //LOGI("trying to move! 2: %ld\n", levelData.getTime()); _pathFinder->setLevelSource(®ion); _pathFinder->canOpenDoors = canOpenDoors; _pathFinder->avoidWater = avoidWater; - _pathFinder->findPath(path, from, xBest, yBest, zBest, maxDist); + _pathFinder->findPath(path, from, xBest, yBest, zBest, maxDist); TIMER_POP(); return true; } @@ -427,57 +427,57 @@ bool Level::findPath(Path* path, Entity* from, int xBest, int yBest, int zBest, */ /*protected*/ void Level::setInitialSpawn() { - isFindingSpawn = true; - int xSpawn = CHUNK_CACHE_WIDTH * CHUNK_WIDTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0; - int ySpawn = 64; - int zSpawn = CHUNK_CACHE_WIDTH * CHUNK_DEPTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0; - while (!dimension->isValidSpawn(xSpawn, zSpawn)) { - xSpawn += random.nextInt(32) - random.nextInt(32); - zSpawn += random.nextInt(32) - random.nextInt(32); + isFindingSpawn = true; + int xSpawn = CHUNK_CACHE_WIDTH * CHUNK_WIDTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0; + int ySpawn = 64; + int zSpawn = CHUNK_CACHE_WIDTH * CHUNK_DEPTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0; + while (!dimension->isValidSpawn(xSpawn, zSpawn)) { + xSpawn += random.nextInt(32) - random.nextInt(32); + zSpawn += random.nextInt(32) - random.nextInt(32); if (xSpawn < 4) xSpawn += 32; if (xSpawn >= LEVEL_WIDTH-4) xSpawn -= 32; if (zSpawn < 4) zSpawn += 32; if (zSpawn >= LEVEL_DEPTH-4) zSpawn -= 32; - } - levelData.setSpawn(xSpawn, ySpawn, zSpawn); - isFindingSpawn = false; + } + levelData.setSpawn(xSpawn, ySpawn, zSpawn); + isFindingSpawn = false; } /*public*/ void Level::validateSpawn() { - if (levelData.getYSpawn() <= 0) { - levelData.setYSpawn(64); - } - int xSpawn = levelData.getXSpawn(); - int zSpawn = levelData.getZSpawn(); - while (getTopTile(xSpawn, zSpawn) == 0 || getTopTile(xSpawn, zSpawn) == Tile::invisible_bedrock->id) { - xSpawn += random.nextInt(8) - random.nextInt(8); - zSpawn += random.nextInt(8) - random.nextInt(8); + if (levelData.getYSpawn() <= 0) { + levelData.setYSpawn(64); + } + int xSpawn = levelData.getXSpawn(); + int zSpawn = levelData.getZSpawn(); + while (getTopTile(xSpawn, zSpawn) == 0 || getTopTile(xSpawn, zSpawn) == Tile::invisible_bedrock->id) { + xSpawn += random.nextInt(8) - random.nextInt(8); + zSpawn += random.nextInt(8) - random.nextInt(8); if (xSpawn < 4) xSpawn += 8; if (xSpawn >= LEVEL_WIDTH-4) xSpawn -= 8; if (zSpawn < 4) zSpawn += 8; if (zSpawn >= LEVEL_DEPTH-4) zSpawn -= 8; - } - levelData.setXSpawn(xSpawn); - levelData.setZSpawn(zSpawn); + } + levelData.setXSpawn(xSpawn); + levelData.setZSpawn(zSpawn); } int Level::getTopTile(int x, int z) { - int y = 63; - while (!isEmptyTile(x, y + 1, z)) { - y++; - } - return getTile(x, y, z); + int y = 63; + while (!isEmptyTile(x, y + 1, z)) { + y++; + } + return getTile(x, y, z); } int Level::getTopTileY(int x, int z) { - int y = 63; - while (!isEmptyTile(x, y + 1, z)) { - y++; - } - return y; + int y = 63; + while (!isEmptyTile(x, y + 1, z)) { + y++; + } + return y; } // // void clearLoadedPlayerData() { @@ -513,101 +513,101 @@ void Level::saveLevelData() { //} int Level::getTile(int x, int y, int z) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return 0; - //} - if (y < 0) return 0; - if (y >= DEPTH) return 0; + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return 0; + //} + if (y < 0) return 0; + if (y >= DEPTH) return 0; //if (z == 128) { // int a = 0; //} //LOGI("%d ", z); - return getChunk(x >> 4, z >> 4)->getTile(x & 15, y, z & 15); + return getChunk(x >> 4, z >> 4)->getTile(x & 15, y, z & 15); } bool Level::isEmptyTile(int x, int y, int z) { - return getTile(x, y, z) == 0; + return getTile(x, y, z) == 0; } bool Level::hasChunkAt(int x, int y, int z) { - if (y < 0 || y >= Level::DEPTH) return false; - return hasChunk(x >> 4, z >> 4); + if (y < 0 || y >= Level::DEPTH) return false; + return hasChunk(x >> 4, z >> 4); } bool Level::hasChunksAt(int x, int y, int z, int r) { - return hasChunksAt(x - r, y - r, z - r, x + r, y + r, z + r); + return hasChunksAt(x - r, y - r, z - r, x + r, y + r, z + r); } bool Level::hasChunksAt(int x0, int y0, int z0, int x1, int y1, int z1) { - if (y1 < 0 || y0 >= Level::DEPTH) return false; + if (y1 < 0 || y0 >= Level::DEPTH) return false; - x0 >>= 4; - z0 >>= 4; - x1 >>= 4; - z1 >>= 4; + x0 >>= 4; + z0 >>= 4; + x1 >>= 4; + z1 >>= 4; - for (int x = x0; x <= x1; x++) - for (int z = z0; z <= z1; z++) - if (!hasChunk(x, z)) return false; + for (int x = x0; x <= x1; x++) + for (int z = z0; z <= z1; z++) + if (!hasChunk(x, z)) return false; - return true; + return true; } bool Level::hasChunk(int x, int z) { - return _chunkSource->hasChunk(x, z); + return _chunkSource->hasChunk(x, z); } LevelChunk* Level::getChunkAt(int x, int z) { - return getChunk(x >> 4, z >> 4); + return getChunk(x >> 4, z >> 4); } LevelChunk* Level::getChunk(int x, int z) { - return _chunkSource->getChunk(x, z); + return _chunkSource->getChunk(x, z); } bool Level::setTileAndDataNoUpdate(int x, int y, int z, int tile, int data) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return false; - //} - if (y < 0) return false; - if (y >= DEPTH) return false; - LevelChunk* c = getChunk(x >> 4, z >> 4); - return c->setTileAndData(x & 15, y, z & 15, tile, data); + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return false; + //} + if (y < 0) return false; + if (y >= DEPTH) return false; + LevelChunk* c = getChunk(x >> 4, z >> 4); + return c->setTileAndData(x & 15, y, z & 15, tile, data); } bool Level::setTileNoUpdate(int x, int y, int z, int tile) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return false; - //} - if (y < 0) return false; - if (y >= DEPTH) return false; - LevelChunk* c = getChunk(x >> 4, z >> 4); - return c->setTile(x & 15, y, z & 15, tile); + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return false; + //} + if (y < 0) return false; + if (y >= DEPTH) return false; + LevelChunk* c = getChunk(x >> 4, z >> 4); + return c->setTile(x & 15, y, z & 15, tile); } const Material* Level::getMaterial(int x, int y, int z) { - int t = getTile(x, y, z); - if (t == 0) return Material::air; - return Tile::tiles[t]->material; + int t = getTile(x, y, z); + if (t == 0) return Material::air; + return Tile::tiles[t]->material; } int Level::getData(int x, int y, int z) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return 0; - //} - if (y < 0) return 0; - if (y >= DEPTH) return 0; - LevelChunk* c = getChunk(x >> 4, z >> 4); - x &= 15; - z &= 15; - return c->getData(x, y, z); + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return 0; + //} + if (y < 0) return 0; + if (y >= DEPTH) return 0; + LevelChunk* c = getChunk(x >> 4, z >> 4); + x &= 15; + z &= 15; + return c->getData(x, y, z); } void Level::setData(int x, int y, int z, int data) { //// @newway //if (setDataNoUpdate(x, y, z, data)) { - // int t = getTile(x, y, z); + // int t = getTile(x, y, z); // if (Tile::sendTileData[t]) { // tileUpdated(x, y, z, t); // } else { @@ -616,20 +616,20 @@ void Level::setData(int x, int y, int z, int data) { //} // @oldway - if (setDataNoUpdate(x, y, z, data)) { - tileUpdated(x, y, z, getTile(x, y, z)); - } + if (setDataNoUpdate(x, y, z, data)) { + tileUpdated(x, y, z, getTile(x, y, z)); + } } bool Level::setDataNoUpdate(int x, int y, int z, int data) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return false; - //} - if (y < 0) return false; - if (y >= DEPTH) return false; - LevelChunk* c = getChunk(x >> 4, z >> 4); - x &= 15; - z &= 15; + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return false; + //} + if (y < 0) return false; + if (y >= DEPTH) return false; + LevelChunk* c = getChunk(x >> 4, z >> 4); + x &= 15; + z &= 15; //return c->setData(x, y, z, data); @@ -641,148 +641,148 @@ bool Level::setDataNoUpdate(int x, int y, int z, int data) { } bool Level::setTile(int x, int y, int z, int tile) { - if (setTileNoUpdate(x, y, z, tile)) { + if (setTileNoUpdate(x, y, z, tile)) { //printf("TILE UPDATED %d, %d, %d\n", x, y, z); - tileUpdated(x, y, z, tile); - return true; - } - return false; + tileUpdated(x, y, z, tile); + return true; + } + return false; } bool Level::setTileAndData(int x, int y, int z, int tile, int data) { - if (setTileAndDataNoUpdate(x, y, z, tile, data)) { - tileUpdated(x, y, z, tile); - return true; - } - return false; + if (setTileAndDataNoUpdate(x, y, z, tile, data)) { + tileUpdated(x, y, z, tile); + return true; + } + return false; } void Level::sendTileUpdated(int x, int y, int z) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->tileChanged(x, y, z); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->tileChanged(x, y, z); + } } /*protected*/ void Level::tileUpdated(int x, int y, int z, int tile) { - sendTileUpdated(x, y, z); - this->updateNeighborsAt(x, y, z, tile); + sendTileUpdated(x, y, z); + this->updateNeighborsAt(x, y, z, tile); } void Level::lightColumnChanged(int x, int z, int y0, int y1) { - if (y0 > y1) { - int tmp = y1; - y1 = y0; - y0 = tmp; - } - setTilesDirty(x, y0, z, x, y1, z); + if (y0 > y1) { + int tmp = y1; + y1 = y0; + y0 = tmp; + } + setTilesDirty(x, y0, z, x, y1, z); } void Level::setTileDirty(int x, int y, int z) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->setTilesDirty(x, y, z, x, y, z); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->setTilesDirty(x, y, z, x, y, z); + } } void Level::setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->setTilesDirty(x0, y0, z0, x1, y1, z1); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->setTilesDirty(x0, y0, z0, x1, y1, z1); + } } void Level::swap(int x1, int y1, int z1, int x2, int y2, int z2) { - int t1 = getTile(x1, y1, z1); - int d1 = getData(x1, y1, z1); - int t2 = getTile(x2, y2, z2); - int d2 = getData(x2, y2, z2); + int t1 = getTile(x1, y1, z1); + int d1 = getData(x1, y1, z1); + int t2 = getTile(x2, y2, z2); + int d2 = getData(x2, y2, z2); - setTileAndDataNoUpdate(x1, y1, z1, t2, d2); - setTileAndDataNoUpdate(x2, y2, z2, t1, d1); + setTileAndDataNoUpdate(x1, y1, z1, t2, d2); + setTileAndDataNoUpdate(x2, y2, z2, t1, d1); - updateNeighborsAt(x1, y1, z1, t2); - updateNeighborsAt(x2, y2, z2, t1); + updateNeighborsAt(x1, y1, z1, t2); + updateNeighborsAt(x2, y2, z2, t1); } void Level::updateNeighborsAt(int x, int y, int z, int tile) { - neighborChanged(x - 1, y, z, tile); - neighborChanged(x + 1, y, z, tile); - neighborChanged(x, y - 1, z, tile); - neighborChanged(x, y + 1, z, tile); - neighborChanged(x, y, z - 1, tile); - neighborChanged(x, y, z + 1, tile); + neighborChanged(x - 1, y, z, tile); + neighborChanged(x + 1, y, z, tile); + neighborChanged(x, y - 1, z, tile); + neighborChanged(x, y + 1, z, tile); + neighborChanged(x, y, z - 1, tile); + neighborChanged(x, y, z + 1, tile); } /*private*/ void Level::neighborChanged(int x, int y, int z, int type) { - if (noNeighborUpdate || isClientSide) return; - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL) tile->neighborChanged(this, x, y, z, type); + if (noNeighborUpdate || isClientSide) return; + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile != NULL) tile->neighborChanged(this, x, y, z, type); } bool Level::canSeeSky(int x, int y, int z) { - return getChunk(x >> 4, z >> 4)->isSkyLit(x & 15, y, z & 15); + return getChunk(x >> 4, z >> 4)->isSkyLit(x & 15, y, z & 15); } int Level::getRawBrightness(int x, int y, int z) { - return getRawBrightness(x, y, z, true); + return getRawBrightness(x, y, z, true); } int Level::getRawBrightness(int x, int y, int z, bool propagate) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return MAX_BRIGHTNESS; - //} + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return MAX_BRIGHTNESS; + //} - if (propagate) { - int id = getTile(x, y, z); - if (id == Tile::stoneSlabHalf->id || id == Tile::farmland->id) { - int br = getRawBrightness(x, y + 1, z, false); - int br1 = getRawBrightness(x + 1, y, z, false); - int br2 = getRawBrightness(x - 1, y, z, false); - int br3 = getRawBrightness(x, y, z + 1, false); - int br4 = getRawBrightness(x, y, z - 1, false); - if (br1 > br) br = br1; - if (br2 > br) br = br2; - if (br3 > br) br = br3; - if (br4 > br) br = br4; - return br; - } - } + if (propagate) { + int id = getTile(x, y, z); + if (id == Tile::stoneSlabHalf->id || id == Tile::farmland->id) { + int br = getRawBrightness(x, y + 1, z, false); + int br1 = getRawBrightness(x + 1, y, z, false); + int br2 = getRawBrightness(x - 1, y, z, false); + int br3 = getRawBrightness(x, y, z + 1, false); + int br4 = getRawBrightness(x, y, z - 1, false); + if (br1 > br) br = br1; + if (br2 > br) br = br2; + if (br3 > br) br = br3; + if (br4 > br) br = br4; + return br; + } + } - if (y < 0) return 0; - if (y >= DEPTH) { - int br = MAX_BRIGHTNESS - skyDarken; - if (br < 0) br = 0; - return br; - } + if (y < 0) return 0; + if (y >= DEPTH) { + int br = MAX_BRIGHTNESS - skyDarken; + if (br < 0) br = 0; + return br; + } - LevelChunk* c = getChunk(x >> 4, z >> 4); - x &= 15; - z &= 15; - return c->getRawBrightness(x, y, z, skyDarken); + LevelChunk* c = getChunk(x >> 4, z >> 4); + x &= 15; + z &= 15; + return c->getRawBrightness(x, y, z, skyDarken); } bool Level::isSkyLit(int x, int y, int z) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return false; - //} - if (y < 0) return false; - if (y >= DEPTH) return true; - if (!hasChunk(x >> 4, z >> 4)) return false; + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return false; + //} + if (y < 0) return false; + if (y >= DEPTH) return true; + if (!hasChunk(x >> 4, z >> 4)) return false; - LevelChunk* c = getChunk(x >> 4, z >> 4); - x &= 15; - z &= 15; + LevelChunk* c = getChunk(x >> 4, z >> 4); + x &= 15; + z &= 15; return c->isSkyLit(x, y, z); } int Level::getHeightmap(int x, int z) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return 0; - //} - if (!hasChunk(x >> 4, z >> 4)) return 0; + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return 0; + //} + if (!hasChunk(x >> 4, z >> 4)) return 0; - LevelChunk* c = getChunk(x >> 4, z >> 4); - return c->getHeightmap(x & 15, z & 15); + LevelChunk* c = getChunk(x >> 4, z >> 4); + return c->getHeightmap(x & 15, z & 15); } BiomeSource* Level::getBiomeSource() { @@ -793,45 +793,45 @@ Biome* Level::getBiome( int x, int z ) { } void Level::updateLightIfOtherThan(const LightLayer& layer, int x, int y, int z, int expected) { - if (dimension->hasCeiling && (&layer) == &LightLayer::Sky) return; + if (dimension->hasCeiling && (&layer) == &LightLayer::Sky) return; - if (!hasChunkAt(x, y, z)) return; + if (!hasChunkAt(x, y, z)) return; - if (&layer == &LightLayer::Sky) { - if (isSkyLit(x, y, z)) expected = 15; - } else if (&layer == &LightLayer::Block) { - int t = getTile(x, y, z); - if (Tile::lightEmission[t] > expected) expected = Tile::lightEmission[t]; - } + if (&layer == &LightLayer::Sky) { + if (isSkyLit(x, y, z)) expected = 15; + } else if (&layer == &LightLayer::Block) { + int t = getTile(x, y, z); + if (Tile::lightEmission[t] > expected) expected = Tile::lightEmission[t]; + } - if (getBrightness(layer, x, y, z) != expected) { - updateLight(layer, x, y, z, x, y, z); - } + if (getBrightness(layer, x, y, z) != expected) { + updateLight(layer, x, y, z, x, y, z); + } } int Level::getBrightness(const LightLayer& layer, int x, int y, int z) { - if (y < 0 || y >= DEPTH/* || x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE*/) { - return layer.surrounding; - } - int xc = x >> 4; - int zc = z >> 4; - if (!hasChunk(xc, zc)) return 0; - LevelChunk* c = getChunk(xc, zc); - return c->getBrightness(layer, x & 15, y, z & 15); + if (y < 0 || y >= DEPTH/* || x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE*/) { + return layer.surrounding; + } + int xc = x >> 4; + int zc = z >> 4; + if (!hasChunk(xc, zc)) return 0; + LevelChunk* c = getChunk(xc, zc); + return c->getBrightness(layer, x & 15, y, z & 15); } void Level::setBrightness(const LightLayer& layer, int x, int y, int z, int brightness) { - //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { - // return; - //} - if (y < 0) return; - if (y >= DEPTH) return; - if (!hasChunk(x >> 4, z >> 4)) return; - LevelChunk* c = getChunk(x >> 4, z >> 4); - c->setBrightness(layer, x & 15, y, z & 15, brightness); - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->tileBrightnessChanged(x, y, z); - } + //if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z > MAX_LEVEL_SIZE) { + // return; + //} + if (y < 0) return; + if (y >= DEPTH) return; + if (!hasChunk(x >> 4, z >> 4)) return; + LevelChunk* c = getChunk(x >> 4, z >> 4); + c->setBrightness(layer, x & 15, y, z & 15, brightness); + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->tileBrightnessChanged(x, y, z); + } } float Level::getBrightness(int x, int y, int z) { @@ -839,7 +839,7 @@ float Level::getBrightness(int x, int y, int z) { } bool Level::isDay() { - return this->skyDarken < 4; + return this->skyDarken < 4; } //HitResult Level::clip(const Vec3& a, const Vec3& b) { @@ -847,99 +847,99 @@ bool Level::isDay() { //} HitResult Level::clip(const Vec3& A, const Vec3& b, bool liquid /*= false*/, bool solidOnly /*= false*/) { - static Stopwatch sw; - //sw.printEvery(1000, "clip"); - SwStartStopper w(sw); + static Stopwatch sw; + //sw.printEvery(1000, "clip"); + SwStartStopper w(sw); - if (A.x != A.x || A.y != A.y || A.z != A.z) return HitResult(); //@kludge This is actually a way to do it + if (A.x != A.x || A.y != A.y || A.z != A.z) return HitResult(); //@kludge This is actually a way to do it if (b.x != b.x || b.y != b.y || b.z != b.z) return HitResult(); Vec3 a(A); - int xTile1 = Mth::floor(b.x); - int yTile1 = Mth::floor(b.y); - int zTile1 = Mth::floor(b.z); + int xTile1 = Mth::floor(b.x); + int yTile1 = Mth::floor(b.y); + int zTile1 = Mth::floor(b.z); - int xTile0 = Mth::floor(a.x); - int yTile0 = Mth::floor(a.y); - int zTile0 = Mth::floor(a.z); + int xTile0 = Mth::floor(a.x); + int yTile0 = Mth::floor(a.y); + int zTile0 = Mth::floor(a.z); - int maxIterations = 200; - while (maxIterations-- >= 0) { + int maxIterations = 200; + while (maxIterations-- >= 0) { if (a.x != a.x || a.y != a.y || a.z != a.z) return HitResult(); - if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) + if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1) return HitResult(); - float xClip = 999; - float yClip = 999; - float zClip = 999; + float xClip = 999; + float yClip = 999; + float zClip = 999; - if (xTile1 > xTile0) xClip = xTile0 + 1.000f; - if (xTile1 < xTile0) xClip = xTile0 + 0.000f; + if (xTile1 > xTile0) xClip = xTile0 + 1.000f; + if (xTile1 < xTile0) xClip = xTile0 + 0.000f; - if (yTile1 > yTile0) yClip = yTile0 + 1.000f; - if (yTile1 < yTile0) yClip = yTile0 + 0.000f; + if (yTile1 > yTile0) yClip = yTile0 + 1.000f; + if (yTile1 < yTile0) yClip = yTile0 + 0.000f; - if (zTile1 > zTile0) zClip = zTile0 + 1.000f; - if (zTile1 < zTile0) zClip = zTile0 + 0.000f; + if (zTile1 > zTile0) zClip = zTile0 + 1.000f; + if (zTile1 < zTile0) zClip = zTile0 + 0.000f; - float xDist = 999; - float yDist = 999; - float zDist = 999; + float xDist = 999; + float yDist = 999; + float zDist = 999; - float xd = b.x - a.x; - float yd = b.y - a.y; - float zd = b.z - a.z; + float xd = b.x - a.x; + float yd = b.y - a.y; + float zd = b.z - a.z; - if (xClip != 999) xDist = (xClip - a.x) / xd; - if (yClip != 999) yDist = (yClip - a.y) / yd; - if (zClip != 999) zDist = (zClip - a.z) / zd; + if (xClip != 999) xDist = (xClip - a.x) / xd; + if (yClip != 999) yDist = (yClip - a.y) / yd; + if (zClip != 999) zDist = (zClip - a.z) / zd; - int face = 0; - if (xDist < yDist && xDist < zDist) { - if (xTile1 > xTile0) face = 4; - else face = 5; + int face = 0; + if (xDist < yDist && xDist < zDist) { + if (xTile1 > xTile0) face = 4; + else face = 5; - a.x = xClip; - a.y += yd * xDist; - a.z += zd * xDist; - } else if (yDist < zDist) { - if (yTile1 > yTile0) face = 0; - else face = 1; + a.x = xClip; + a.y += yd * xDist; + a.z += zd * xDist; + } else if (yDist < zDist) { + if (yTile1 > yTile0) face = 0; + else face = 1; - a.x += xd * yDist; - a.y = yClip; - a.z += zd * yDist; - } else { - if (zTile1 > zTile0) face = 2; - else face = 3; + a.x += xd * yDist; + a.y = yClip; + a.z += zd * yDist; + } else { + if (zTile1 > zTile0) face = 2; + else face = 3; - a.x += xd * zDist; - a.y += yd * zDist; - a.z = zClip; - } + a.x += xd * zDist; + a.y += yd * zDist; + a.z = zClip; + } - Vec3 tPos(a.x, a.y, a.z); - xTile0 = (int) (tPos.x = (float)Mth::floor(a.x)); - if (face == 5) { - xTile0--; - tPos.x++; - } - yTile0 = (int) (tPos.y = (float)Mth::floor(a.y)); - if (face == 1) { - yTile0--; - tPos.y++; - } - zTile0 = (int) (tPos.z = (float)Mth::floor(a.z)); - if (face == 3) { - zTile0--; - tPos.z++; - } + Vec3 tPos(a.x, a.y, a.z); + xTile0 = (int) (tPos.x = (float)Mth::floor(a.x)); + if (face == 5) { + xTile0--; + tPos.x++; + } + yTile0 = (int) (tPos.y = (float)Mth::floor(a.y)); + if (face == 1) { + yTile0--; + tPos.y++; + } + zTile0 = (int) (tPos.z = (float)Mth::floor(a.z)); + if (face == 3) { + zTile0--; + tPos.z++; + } - int t = getTile(xTile0, yTile0, zTile0); - int data = getData(xTile0, yTile0, zTile0); - Tile* tile = Tile::tiles[t]; + int t = getTile(xTile0, yTile0, zTile0); + int data = getData(xTile0, yTile0, zTile0); + Tile* tile = Tile::tiles[t]; if (solidOnly && tile != NULL && tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) { // No collision @@ -948,27 +948,27 @@ HitResult Level::clip(const Vec3& A, const Vec3& b, bool liquid /*= false*/, boo HitResult r = tile->clip(this, xTile0, yTile0, zTile0, a, b); if (r.isHit()) return r; } - } - } - return HitResult(); + } + } + return HitResult(); } void Level::playSound(Entity* entity, const std::string& name, float volume, float pitch) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->playSound(name, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->playSound(name, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch); + } } void Level::playSound(float x, float y, float z, const std::string& name, float volume, float pitch) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->playSound(name, x, y, z, volume, pitch); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->playSound(name, x, y, z, volume, pitch); + } } void Level::levelEvent(Player* source, int type, int x, int y, int z, int data) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->levelEvent(source, type, x, y, z, data); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->levelEvent(source, type, x, y, z, data); + } } void Level::tileEvent(int x, int y, int z, int b0, int b1) { @@ -993,7 +993,7 @@ void Level::tileEvent(int x, int y, int z, int b0, int b1) { void Level::addParticle(const std::string& id, float x, float y, float z, float xd, float yd, float zd, int data /* = 0 */) { for (unsigned int i = 0; i < _listeners.size(); i++) - _listeners[i]->addParticle(id, x, y, z, xd, yd, zd, data); + _listeners[i]->addParticle(id, x, y, z, xd, yd, zd, data); } void Level::addParticle(ParticleType::Id id, float x, float y, float z, float xd, float yd, float zd, int data /* = 0 */) { @@ -1006,13 +1006,13 @@ bool Level::addEntity(Entity* e) { if (prev) removeEntity(prev); - int xc = Mth::floor(e->x / 16.f); - int zc = Mth::floor(e->z / 16.f); + int xc = Mth::floor(e->x / 16.f); + int zc = Mth::floor(e->z / 16.f); - //bool forced = false; - //if (e->isPlayer()) { - // forced = true; - //} + //bool forced = false; + //if (e->isPlayer()) { + // forced = true; + //} bool forced = true; if (forced/* || hasChunk(xc, zc)*/) { @@ -1034,10 +1034,10 @@ Entity* Level::getEntity(int entityId) // TODO: Lookup map /*for (unsigned int i = 0; i < entities.size(); i++) { - if (entities[i]->entityId == entityId) - { - return entities[i]; - } + if (entities[i]->entityId == entityId) + { + return entities[i]; + } } return NULL;*/ EntityMap::const_iterator cit = entityIdLookup.find(entityId); @@ -1046,16 +1046,16 @@ Entity* Level::getEntity(int entityId) /*protected*/ void Level::entityAdded(Entity* e) { - for (unsigned int i = 0; i < _listeners.size(); i++) { - _listeners[i]->entityAdded(e); - } + for (unsigned int i = 0; i < _listeners.size(); i++) { + _listeners[i]->entityAdded(e); + } } /*protected*/ void Level::entityRemoved(Entity* e) { - for (unsigned int j = 0; j < _listeners.size(); j++) { - _listeners[j]->entityRemoved(e); - } + for (unsigned int j = 0; j < _listeners.size(); j++) { + _listeners[j]->entityRemoved(e); + } } Mob* Level::getMob(int entityId) @@ -1065,10 +1065,10 @@ Mob* Level::getMob(int entityId) } void Level::removeEntity(Entity* e) { - e->remove(); + e->remove(); if (e->isPlayer() && e->reallyRemoveIfPlayer) { Util::remove(players, (Player*) e); - } + } } void Level::tileEntityChanged(int x, int y, int z, TileEntity* te) { @@ -1099,16 +1099,16 @@ void Level::tileEntityChanged(int x, int y, int z, TileEntity* te) { Biome::MobSpawnerData Level::getRandomMobSpawnAt(const MobCategory& mobCategory, int x, int y, int z) { Biome::MobList mobList = _chunkSource->getMobsAt(mobCategory, x, y, z); - if (mobList.empty()) return Biome::MobSpawnerData(); + if (mobList.empty()) return Biome::MobSpawnerData(); Biome::MobSpawnerData* data = (Biome::MobSpawnerData*) WeighedRandom::getRandomItem(&random, mobList); if (!data) return Biome::MobSpawnerData(); - return *data; + return *data; } void Level::addListener(LevelListener* listener) { - _listeners.push_back(listener); + _listeners.push_back(listener); } void Level::removeListener(LevelListener* listener) { @@ -1119,76 +1119,86 @@ void Level::removeListener(LevelListener* listener) { std::vector& Level::getCubes(const Entity* source, const AABB& box_) { //@attn: check the AABB* new/delete stuff boxes.clear(); const AABB* box = &box_; - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); - for (int x = x0; x < x1; x++) - for (int z = z0; z < z1; z++) { - if (hasChunkAt(x, Level::DEPTH / 2, z)) { - for (int y = y0 - 1; y < y1; y++) { - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL) { - tile->addAABBs(this, x, y, z, box, boxes); - } - } - } + for (int x = x0; x < x1; x++) + for (int z = z0; z < z1; z++) { + if (hasChunkAt(x, Level::DEPTH / 2, z)) { + for (int y = y0 - 1; y < y1; y++) { + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile != NULL) { + tile->addAABBs(this, x, y, z, box, boxes); + } + } + } else { //int breakPoint = 0; } - } - /* - float r = 0.25; - List ee = getEntities(source, box.grow(r, r, r)); - for (int i = 0; i < ee.size(); i++) { - AABB collideBox = ee.get(i).getCollideBox(); - if (collideBox != NULL && collideBox.intersects(box)) { - boxes.add(collideBox); - } + } + /* + float r = 0.25; + List ee = getEntities(source, box.grow(r, r, r)); + for (int i = 0; i < ee.size(); i++) { + AABB collideBox = ee.get(i).getCollideBox(); + if (collideBox != NULL && collideBox.intersects(box)) { + boxes.add(collideBox); + } - collideBox = source.getCollideAgainstBox(ee.get(i)); - if (collideBox != NULL && collideBox.intersects(box)) { - boxes.add(collideBox); - } - } - */ + collideBox = source.getCollideAgainstBox(ee.get(i)); + if (collideBox != NULL && collideBox.intersects(box)) { + boxes.add(collideBox); + } + } + */ - return boxes; + return boxes; } int Level::getSkyDarken(float a) { - float td = getTimeOfDay(a); + float td = getTimeOfDay(a); - float br = 1 - (Mth::cos(td * Mth::PI * 2) * 2 + 0.5f); - if (br < 0.0f) br = 0.0f; - if (br > 0.80f) br = 0.80f; //@note; was 1.0f - return ((int) (br * 11)); + float br = 1 - (Mth::cos(td * Mth::PI * 2) * 2 + 0.5f); + if (br < 0.0f) br = 0.0f; + if (br > 0.80f) br = 0.80f; //@note; was 1.0f + return ((int) (br * 11)); } Vec3 Level::getSkyColor(Entity* source, float a) { - float td = getTimeOfDay(a); + float td = getTimeOfDay(a); float br = Mth::cos(td * Mth::PI * 2) * 2 + 0.5f; - if (br < 0.0f) br = 0.0f; - if (br > 0.75f) br = 0.75f; //@note; was 1.0f + if (br < 0.0f) br = 0.0f; + if (br > 0.75f) br = 0.75f; //@note; was 1.0f -// int xx = Mth::floor(source->x); -// int zz = Mth::floor(source->z); -// float temp = 0.5;//(float) getBiomeSource().getTemperature(xx, zz); - int skyColor = 0x3070ff;//getBiomeSource().getBiome(xx, zz).getSkyColor(temp); + int xx = Mth::floor(source->x); + int zz = Mth::floor(source->z); + // float temp = 0.5;//(float) getBiomeSource().getTemperature(xx, zz); // unused in normal pe too, just hardcoded temp values for some reason. + float temp = (float) getBiomeSource()->getTemperature(xx, zz); + int skyColor; + if (dimension->FogType == 1){ // 1 is java styled fog which should use temperatures! + skyColor = getBiomeSource()->getBiome(xx, zz)->getSkyColor(temp); + } + else { // otherwise default to the normal pocket edition skycolor - float r = ((skyColor >> 16) & 0xff) / 255.0f; - float g = ((skyColor >> 8) & 0xff) / 255.0f; - float b = ((skyColor) & 0xff) / 255.0f; - r *= br; - g *= br; - b *= br; + skyColor = 0x3070ff; + } - return Vec3(r, g, b); + // int skyColor = 0x3070ff;//getBiomeSource().getBiome(xx, zz).getSkyColor(temp); // This is the vanilla way, add it as OPTION_SKY - shredder + + float r = ((skyColor >> 16) & 0xff) / 255.0f; + float g = ((skyColor >> 8) & 0xff) / 255.0f; + float b = ((skyColor) & 0xff) / 255.0f; + r *= br; + g *= br; + b *= br; + + return Vec3(r, g, b); } Vec3 Level::getCloudColor( float a ) { @@ -1238,8 +1248,8 @@ float Level::getTimeOfDay(float a) { } float Level::getSunAngle(float a) { - float td = getTimeOfDay(a); - return td * Mth::PI * 2; + float td = getTimeOfDay(a); + return td * Mth::PI * 2; } //Vec3 Level::getCloudColor(float a) { @@ -1261,70 +1271,70 @@ float Level::getSunAngle(float a) { //} Vec3 Level::getFogColor(float a) { - float td = getTimeOfDay(a); - return dimension->getFogColor(td, a); + float td = getTimeOfDay(a); + return dimension->getFogColor(td, a); } int Level::getTopSolidBlock(int x, int z) { - LevelChunk* levelChunk = getChunkAt(x, z); + LevelChunk* levelChunk = getChunkAt(x, z); - int y = Level::DEPTH - 1; + int y = Level::DEPTH - 1; - while (getMaterial(x, y, z)->blocksMotion() && y > 0) { - y--; - } + while (getMaterial(x, y, z)->blocksMotion() && y > 0) { + y--; + } - x &= 15; - z &= 15; + x &= 15; + z &= 15; - while (y > 0) { - int t = levelChunk->getTile(x, y, z); - if (t == 0 /*|| !(Tile::tiles[t]->material->blocksMotion() || Tile::tiles[t]->material->isLiquid())*/ + while (y > 0) { + int t = levelChunk->getTile(x, y, z); + if (t == 0 /*|| !(Tile::tiles[t]->material->blocksMotion() || Tile::tiles[t]->material->isLiquid())*/ || !(Tile::tiles[t]->material->blocksMotion()) || Tile::tiles[t]->material == Material::leaves) { - y--; - } else { - return y + 1; - } - } - return -1; + y--; + } else { + return y + 1; + } + } + return -1; } int Level::getLightDepth(int x, int z) { - return getChunkAt(x, z)->getHeightmap(x & 15, z & 15); + return getChunkAt(x, z)->getHeightmap(x & 15, z & 15); } float Level::getStarBrightness(float a) { - float td = getTimeOfDay(a); + float td = getTimeOfDay(a); - float br = 1 - (Mth::cos(td * Mth::PI * 2) * 2 + 0.75f); - if (br < 0.f) br = 0; - if (br > 1.f) br = 1; + float br = 1 - (Mth::cos(td * Mth::PI * 2) * 2 + 0.75f); + if (br < 0.f) br = 0; + if (br > 1.f) br = 1; - return br * br * 0.5f; + return br * br * 0.5f; } void Level::addToTickNextTick(int x, int y, int z, int tileId, int tickDelay) { TickNextTickData td(x, y, z, tileId); - int r = 8; - if (instaTick) { - if (hasChunksAt(td.x - r, td.y - r, td.z - r, td.x + r, td.y + r, td.z + r)) { - int id = getTile(td.x, td.y, td.z); - if (id == td.tileId && id > 0) { - Tile::tiles[id]->tick(this, td.x, td.y, td.z, &random); - } - } - return; - } + int r = 8; + if (instaTick) { + if (hasChunksAt(td.x - r, td.y - r, td.z - r, td.x + r, td.y + r, td.z + r)) { + int id = getTile(td.x, td.y, td.z); + if (id == td.tileId && id > 0) { + Tile::tiles[id]->tick(this, td.x, td.y, td.z, &random); + } + } + return; + } - if (hasChunksAt(x - r, y - r, z - r, x + r, y + r, z + r)) { - if (tileId > 0) { - td.setDelay(tickDelay + levelData.getTime()); - } + if (hasChunksAt(x - r, y - r, z - r, x + r, y + r, z + r)) { + if (tileId > 0) { + td.setDelay(tickDelay + levelData.getTime()); + } if (_tickNextTickSet.find(td) == _tickNextTickSet.end()) { _tickNextTickSet.insert(td); - } - } + } + } } void Level::tickEntities() { @@ -1332,52 +1342,52 @@ void Level::tickEntities() { TIMER_PUSH("remove"); //Util::removeAll(entities, _entitiesToRemove); - // for (int j = 0; j < (int)_entitiesToRemove.size(); j++) { - // Entity* e = _entitiesToRemove[j]; - // int xc = e->xChunk; - // int zc = e->zChunk; - // if (e->inChunk && hasChunk(xc, zc)) { - // getChunk(xc, zc)->removeEntity(e); - // } - // } - // for (int j = 0; j < (int)_entitiesToRemove.size(); j++) { - // entityRemoved(_entitiesToRemove[j]); + // for (int j = 0; j < (int)_entitiesToRemove.size(); j++) { + // Entity* e = _entitiesToRemove[j]; + // int xc = e->xChunk; + // int zc = e->zChunk; + // if (e->inChunk && hasChunk(xc, zc)) { + // getChunk(xc, zc)->removeEntity(e); + // } + // } + // for (int j = 0; j < (int)_entitiesToRemove.size(); j++) { + // entityRemoved(_entitiesToRemove[j]); // //LOGI("a1 &e@delt: %p", _entitiesToRemove[j]); // delete _entitiesToRemove[j]; // //LOGI("a2"); - // } - // _entitiesToRemove.clear(); + // } + // _entitiesToRemove.clear(); EntityList pendingRemovedEntities; std::vector zombies; TIMER_POP_PUSH("regular"); - for (unsigned int i = 0; i < entities.size(); i++) { - Entity* e = entities[i]; + for (unsigned int i = 0; i < entities.size(); i++) { + Entity* e = entities[i]; - if (!e->removed) { - tick(e); + if (!e->removed) { + tick(e); if (e->getEntityTypeId() == MobTypes::Zombie) { zombies.push_back((Zombie*)e); ((Zombie*)e)->setUseNewAi(false); // @note: this is set under } - } + } TIMER_PUSH("remove"); - if (e->removed && (!e->isPlayer() || e->reallyRemoveIfPlayer)) { - int xc = e->xChunk; - int zc = e->zChunk; - if (e->inChunk && hasChunk(xc, zc)) { - getChunk(xc, zc)->removeEntity(e); - } + if (e->removed && (!e->isPlayer() || e->reallyRemoveIfPlayer)) { + int xc = e->xChunk; + int zc = e->zChunk; + if (e->inChunk && hasChunk(xc, zc)) { + getChunk(xc, zc)->removeEntity(e); + } entityIdLookup.erase(e->entityId); entities.erase(entities.begin() + (i--)); - entityRemoved(e); + entityRemoved(e); pendingRemovedEntities.push_back(e); - } + } TIMER_POP(); - } - + } + TIMER_POP_PUSH("remove"); for (unsigned int i = 0; i < pendingRemovedEntities.size(); ++i) { Entity* e = pendingRemovedEntities[i]; @@ -1498,51 +1508,51 @@ void Level::setZombieAi(std::vector& zombies) { } void Level::tick(Entity* e) { - tick(e, true); + tick(e, true); } void Level::tick(Entity* e, bool actual) { - int xc = Mth::floor(e->x); - int zc = Mth::floor(e->z); - int r = 32; - if (actual && !hasChunksAt(xc - r, 0, zc - r, xc + r, 128, zc + r)) { - return; - } + int xc = Mth::floor(e->x); + int zc = Mth::floor(e->z); + int r = 32; + if (actual && !hasChunksAt(xc - r, 0, zc - r, xc + r, 128, zc + r)) { + return; + } - e->xOld = e->x; - e->yOld = e->y; - e->zOld = e->z; - e->yRotO = e->yRot; - e->xRotO = e->xRot; + e->xOld = e->x; + e->yOld = e->y; + e->zOld = e->z; + e->yRotO = e->yRot; + e->xRotO = e->xRot; - if (actual && e->inChunk) { - e->tick(); - } + if (actual && e->inChunk) { + e->tick(); + } TIMER_PUSH("chunkCheck"); - // SANITY!! + // SANITY!! if (e->x != e->x) e->x = e->xOld; // @note: checking for NaN, not sure about Infinite if (e->y != e->y) e->y = e->yOld; if (e->z != e->z) e->z = e->zOld; if (e->xRot != e->xRot) e->xRot = e->xRotO; if (e->yRot != e->yRot) e->yRot = e->yRotO; - int xcn = Mth::floor(e->x / 16.0f); - int ycn = Mth::floor(e->y / 16.0f); - int zcn = Mth::floor(e->z / 16.0f); + int xcn = Mth::floor(e->x / 16.0f); + int ycn = Mth::floor(e->y / 16.0f); + int zcn = Mth::floor(e->z / 16.0f); - if (!e->inChunk || (e->xChunk != xcn || e->yChunk != ycn || e->zChunk != zcn)) { - if (e->inChunk && hasChunk(e->xChunk, e->zChunk)) { - getChunk(e->xChunk, e->zChunk)->removeEntity(e, e->yChunk); - } + if (!e->inChunk || (e->xChunk != xcn || e->yChunk != ycn || e->zChunk != zcn)) { + if (e->inChunk && hasChunk(e->xChunk, e->zChunk)) { + getChunk(e->xChunk, e->zChunk)->removeEntity(e, e->yChunk); + } - if (hasChunk(xcn, zcn)) { - e->inChunk = true; - getChunk(xcn, zcn)->addEntity(e); - } else { - e->inChunk = false; - } - } + if (hasChunk(xcn, zcn)) { + e->inChunk = true; + getChunk(xcn, zcn)->addEntity(e); + } else { + e->inChunk = false; + } + } TIMER_POP(); // Save player info every n:th second @@ -1554,109 +1564,109 @@ void Level::tick(Entity* e, bool actual) { } bool Level::isUnobstructed(const AABB& aabb) { - EntityList& entities = getEntities(NULL, aabb); - for (unsigned int i = 0; i < entities.size(); i++) { - Entity* e = entities[i]; - if (!e->removed && e->blocksBuilding) return false; - } - return true; + EntityList& entities = getEntities(NULL, aabb); + for (unsigned int i = 0; i < entities.size(); i++) { + Entity* e = entities[i]; + if (!e->removed && e->blocksBuilding) return false; + } + return true; } bool Level::containsAnyLiquid(const AABB& box) { - int x0 = Mth::floor(box.x0); - int x1 = Mth::floor(box.x1 + 1); - int y0 = Mth::floor(box.y0); - int y1 = Mth::floor(box.y1 + 1); - int z0 = Mth::floor(box.z0); - int z1 = Mth::floor(box.z1 + 1); + int x0 = Mth::floor(box.x0); + int x1 = Mth::floor(box.x1 + 1); + int y0 = Mth::floor(box.y0); + int y1 = Mth::floor(box.y1 + 1); + int z0 = Mth::floor(box.z0); + int z1 = Mth::floor(box.z1 + 1); - if (box.x0 < 0) x0--; - if (box.y0 < 0) y0--; - if (box.z0 < 0) z0--; + if (box.x0 < 0) x0--; + if (box.y0 < 0) y0--; + if (box.z0 < 0) z0--; - for (int x = x0; x < x1; x++) - for (int y = y0; y < y1; y++) - for (int z = z0; z < z1; z++) { - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material->isLiquid()) { - return true; - } - } - return false; + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + for (int z = z0; z < z1; z++) { + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile != NULL && tile->material->isLiquid()) { + return true; + } + } + return false; } bool Level::containsFireTile(const AABB& box) { - int x0 = Mth::floor(box.x0); - int x1 = Mth::floor(box.x1 + 1); - int y0 = Mth::floor(box.y0); - int y1 = Mth::floor(box.y1 + 1); - int z0 = Mth::floor(box.z0); - int z1 = Mth::floor(box.z1 + 1); + int x0 = Mth::floor(box.x0); + int x1 = Mth::floor(box.x1 + 1); + int y0 = Mth::floor(box.y0); + int y1 = Mth::floor(box.y1 + 1); + int z0 = Mth::floor(box.z0); + int z1 = Mth::floor(box.z1 + 1); - if (hasChunksAt(x0, y0, z0, x1, y1, z1)) { - for (int x = x0; x < x1; x++) - for (int y = y0; y < y1; y++) - for (int z = z0; z < z1; z++) { - int t = getTile(x, y, z); + if (hasChunksAt(x0, y0, z0, x1, y1, z1)) { + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + for (int z = z0; z < z1; z++) { + int t = getTile(x, y, z); - if (t == ((Tile*)(Tile::fire))->id - || t == Tile::lava->id - || t == Tile::calmLava->id) { - return true; + if (t == ((Tile*)(Tile::fire))->id + || t == Tile::lava->id + || t == Tile::calmLava->id) { + return true; } - } - } - return false; + } + } + return false; } bool Level::containsMaterial(const AABB& box, const Material* material) { - int x0 = Mth::floor(box.x0); - int x1 = Mth::floor(box.x1 + 1); - int y0 = Mth::floor(box.y0); - int y1 = Mth::floor(box.y1 + 1); - int z0 = Mth::floor(box.z0); - int z1 = Mth::floor(box.z1 + 1); + int x0 = Mth::floor(box.x0); + int x1 = Mth::floor(box.x1 + 1); + int y0 = Mth::floor(box.y0); + int y1 = Mth::floor(box.y1 + 1); + int z0 = Mth::floor(box.z0); + int z1 = Mth::floor(box.z1 + 1); - for (int x = x0; x < x1; x++) - for (int y = y0; y < y1; y++) - for (int z = z0; z < z1; z++) { - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material == material) { - return true; - } - } - return false; + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + for (int z = z0; z < z1; z++) { + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile != NULL && tile->material == material) { + return true; + } + } + return false; } bool Level::containsLiquid(const AABB& box, const Material* material) { - int x0 = Mth::floor(box.x0); - int x1 = Mth::floor(box.x1 + 1); - int y0 = Mth::floor(box.y0); - int y1 = Mth::floor(box.y1 + 1); - int z0 = Mth::floor(box.z0); - int z1 = Mth::floor(box.z1 + 1); + int x0 = Mth::floor(box.x0); + int x1 = Mth::floor(box.x1 + 1); + int y0 = Mth::floor(box.y0); + int y1 = Mth::floor(box.y1 + 1); + int z0 = Mth::floor(box.z0); + int z1 = Mth::floor(box.z1 + 1); - for (int x = x0; x < x1; x++) - for (int y = y0; y < y1; y++) - for (int z = z0; z < z1; z++) { - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile != NULL && tile->material == material) { - int data = getData(x, y, z); - float yh1 = (float)(y + 1); - if (data < 8) { - yh1 = (float)y + 1.0f - (float)data / 8.0f; - } - if (yh1 >= box.y0) { - return true; - } - } - } - return false; + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + for (int z = z0; z < z1; z++) { + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile != NULL && tile->material == material) { + int data = getData(x, y, z); + float yh1 = (float)(y + 1); + if (data < 8) { + yh1 = (float)y + 1.0f - (float)data / 8.0f; + } + if (yh1 >= box.y0) { + return true; + } + } + } + return false; } /* in java, this returns an Explosion */ void Level::explode(Entity* source, float x, float y, float z, float r) { - explode(source, x, y, z, r, false); + explode(source, x, y, z, r, false); } /* in java, this returns an Explosion */ @@ -1672,29 +1682,29 @@ void Level::explode(Entity* source, float x, float y, float z, float r, bool fir } float Level::getSeenPercent(const Vec3& center, const AABB& bb) { - float xs = 1.0f / ((bb.x1 - bb.x0) * 2 + 1); - float ys = 1.0f / ((bb.y1 - bb.y0) * 2 + 1); - float zs = 1.0f / ((bb.z1 - bb.z0) * 2 + 1); - int hits = 0; - int count = 0; - for (float xx = 0; xx <= 1; xx += xs) - for (float yy = 0; yy <= 1; yy += ys) - for (float zz = 0; zz <= 1; zz += zs) { - float x = bb.x0 + (bb.x1 - bb.x0) * xx; - float y = bb.y0 + (bb.y1 - bb.y0) * yy; - float z = bb.z0 + (bb.z1 - bb.z0) * zz; + float xs = 1.0f / ((bb.x1 - bb.x0) * 2 + 1); + float ys = 1.0f / ((bb.y1 - bb.y0) * 2 + 1); + float zs = 1.0f / ((bb.z1 - bb.z0) * 2 + 1); + int hits = 0; + int count = 0; + for (float xx = 0; xx <= 1; xx += xs) + for (float yy = 0; yy <= 1; yy += ys) + for (float zz = 0; zz <= 1; zz += zs) { + float x = bb.x0 + (bb.x1 - bb.x0) * xx; + float y = bb.y0 + (bb.y1 - bb.y0) * yy; + float z = bb.z0 + (bb.z1 - bb.z0) * zz; if (!clip(Vec3(x, y, z), center).isHit()) hits++; - count++; - } + count++; + } - return hits / (float) count; + return hits / (float) count; } bool Level::isSolidBlockingTile(int x, int y, int z) { - Tile* tile = Tile::tiles[getTile(x, y, z)]; - if (tile == NULL) return false; - return tile->material->isSolidBlocking() && tile->isCubeShaped(); + Tile* tile = Tile::tiles[getTile(x, y, z)]; + if (tile == NULL) return false; + return tile->material->isSolidBlocking() && tile->isCubeShaped(); } bool Level::isSolidRenderTile(int x, int y, int z) { @@ -1705,18 +1715,18 @@ bool Level::isSolidRenderTile(int x, int y, int z) { void Level::extinguishFire(int x, int y, int z, int face) { switch (face) { - case Facing::DOWN : y--; break; - case Facing::UP : y++; break; - case Facing::NORTH: z--; break; - case Facing::SOUTH: z++; break; - case Facing::WEST : x--; break; - case Facing::EAST : x++; break; + case Facing::DOWN : y--; break; + case Facing::UP : y++; break; + case Facing::NORTH: z--; break; + case Facing::SOUTH: z++; break; + case Facing::WEST : x--; break; + case Facing::EAST : x++; break; } - if (getTile(x, y, z) == ((Tile*)Tile::fire)->id) { - //playSound(x + 0.5f, y + 0.5f, z + 0.5f, "random.fizz", 0.5f, 2.6f + (random.nextFloat() - random.nextFloat()) * 0.8f); - setTile(x, y, z, 0); - } + if (getTile(x, y, z) == ((Tile*)Tile::fire)->id) { + //playSound(x + 0.5f, y + 0.5f, z + 0.5f, "random.fizz", 0.5f, 2.6f + (random.nextFloat() - random.nextFloat()) * 0.8f); + setTile(x, y, z, 0); + } } // String gatherStats() { // return "All: " + this.entities.size(); @@ -1783,37 +1793,37 @@ void Level::removeTileEntity(int x, int y, int z) { // int Level::getLightsToUpdate() { - return _lightUpdates.size(); + return _lightUpdates.size(); } bool Level::updateLights() { - if (_maxRecurse >= 50) { - return false; - } + if (_maxRecurse >= 50) { + return false; + } //static int _MaxSize = 0; - _maxRecurse++; - //try { - int max = 500; - while ((int)_lightUpdates.size() > 0) { - if (--max <= 0) - { - _maxRecurse--; - return true; - } - LightUpdate l = _lightUpdates.back(); - _lightUpdates.pop_back(); - l.update(this); - //if ((int)_lightUpdates.size() > _MaxSize) - //{ - // LOGI("MAX_updsize_light: %d (%d)\n", _lightUpdates.size(), _MaxSize); - // _MaxSize = _lightUpdates.size(); - //} - } - _maxRecurse--; - return false; - //} finally { - //maxRecurse--; - //} + _maxRecurse++; + //try { + int max = 500; + while ((int)_lightUpdates.size() > 0) { + if (--max <= 0) + { + _maxRecurse--; + return true; + } + LightUpdate l = _lightUpdates.back(); + _lightUpdates.pop_back(); + l.update(this); + //if ((int)_lightUpdates.size() > _MaxSize) + //{ + // LOGI("MAX_updsize_light: %d (%d)\n", _lightUpdates.size(), _MaxSize); + // _MaxSize = _lightUpdates.size(); + //} + } + _maxRecurse--; + return false; + //} finally { + //maxRecurse--; + //} } void Level::setUpdateLights(bool doUpdate) { @@ -1821,96 +1831,96 @@ void Level::setUpdateLights(bool doUpdate) { } void Level::updateLight(const LightLayer& layer, int x0, int y0, int z0, int x1, int y1, int z1) { - updateLight(layer, x0, y0, z0, x1, y1, z1, true); + updateLight(layer, x0, y0, z0, x1, y1, z1, true); } static int maxLoop = 0; void Level::updateLight(const LightLayer& layer, int x0, int y0, int z0, int x1, int y1, int z1, bool join) { - if ((dimension->hasCeiling && &layer == &LightLayer::Sky) || !_updateLights) return; + if ((dimension->hasCeiling && &layer == &LightLayer::Sky) || !_updateLights) return; - maxLoop++; + maxLoop++; //if (x0 < -5 || z0 < -5) LOGI("x, z: %d, %d\n", x0, z0); - if (maxLoop == 50) { - maxLoop--; - return; - } - int xm = (x1 + x0) / 2; - int zm = (z1 + z0) / 2; - if (!hasChunkAt(xm, Level::DEPTH / 2, zm)) { - maxLoop--; - return; - } - if (getChunkAt(xm, zm)->isEmpty()) + if (maxLoop == 50) { + maxLoop--; + return; + } + int xm = (x1 + x0) / 2; + int zm = (z1 + z0) / 2; + if (!hasChunkAt(xm, Level::DEPTH / 2, zm)) { + maxLoop--; + return; + } + if (getChunkAt(xm, zm)->isEmpty()) { maxLoop--; return; } - int count = _lightUpdates.size(); - if (join) { - int toCheck = 5; - if (toCheck > count) toCheck = count; - for (int i = 0; i < toCheck; i++) { - LightUpdate& last = _lightUpdates[_lightUpdates.size() - i - 1]; - if (last.layer == &layer && last.expandToContain(x0, y0, z0, x1, y1, z1)) { - maxLoop--; - return; - } - } - } - _lightUpdates.push_back(LightUpdate(layer, x0, y0, z0, x1, y1, z1)); - int max = 1000000; - if ((int)_lightUpdates.size() > max) { - LOGI("More than %d updates, aborting lighting updates\n", max); - _lightUpdates.clear(); - } - maxLoop--; + int count = _lightUpdates.size(); + if (join) { + int toCheck = 5; + if (toCheck > count) toCheck = count; + for (int i = 0; i < toCheck; i++) { + LightUpdate& last = _lightUpdates[_lightUpdates.size() - i - 1]; + if (last.layer == &layer && last.expandToContain(x0, y0, z0, x1, y1, z1)) { + maxLoop--; + return; + } + } + } + _lightUpdates.push_back(LightUpdate(layer, x0, y0, z0, x1, y1, z1)); + int max = 1000000; + if ((int)_lightUpdates.size() > max) { + LOGI("More than %d updates, aborting lighting updates\n", max); + _lightUpdates.clear(); + } + maxLoop--; } // // // int xxo, yyo, zzo; // bool Level::updateSkyBrightness() { - int newDark = this->getSkyDarken(1); - if (newDark != skyDarken) { - skyDarken = newDark; + int newDark = this->getSkyDarken(1); + if (newDark != skyDarken) { + skyDarken = newDark; return true; - } + } return false; } void Level::setSpawnSettings(bool spawnEnemies, bool spawnFriendlies) { - //this->spawnEnemies = spawnEnemies; - //this->spawnFriendlies = spawnFriendlies; + //this->spawnEnemies = spawnEnemies; + //this->spawnFriendlies = spawnFriendlies; } void Level::animateTick(int xt, int yt, int zt) { - int r = 16; - Random animateRandom; + int r = 16; + Random animateRandom; - for (int i = 0; i < 100; i++) { - int x = xt + random.nextInt(r) - random.nextInt(r); - int y = yt + random.nextInt(r) - random.nextInt(r); - int z = zt + random.nextInt(r) - random.nextInt(r); - int t = getTile(x, y, z); - if (t > 0) { - Tile::tiles[t]->animateTick(this, x, y, z, &animateRandom); - } - } + for (int i = 0; i < 100; i++) { + int x = xt + random.nextInt(r) - random.nextInt(r); + int y = yt + random.nextInt(r) - random.nextInt(r); + int z = zt + random.nextInt(r) - random.nextInt(r); + int t = getTile(x, y, z); + if (t > 0) { + Tile::tiles[t]->animateTick(this, x, y, z, &animateRandom); + } + } } EntityList& Level::getEntities(Entity* except, const AABB& bb) { - _es.clear(); - int xc0 = Mth::floor((bb.x0 - 2) / 16); - int xc1 = Mth::floor((bb.x1 + 2) / 16); - int zc0 = Mth::floor((bb.z0 - 2) / 16); - int zc1 = Mth::floor((bb.z1 + 2) / 16); - for (int xc = xc0; xc <= xc1; xc++) - for (int zc = zc0; zc <= zc1; zc++) { - if (hasChunk(xc, zc)) { - getChunk(xc, zc)->getEntities(except, bb, _es); - } - } - return _es; + _es.clear(); + int xc0 = Mth::floor((bb.x0 - 2) / 16); + int xc1 = Mth::floor((bb.x1 + 2) / 16); + int zc0 = Mth::floor((bb.z0 - 2) / 16); + int zc1 = Mth::floor((bb.z1 + 2) / 16); + for (int xc = xc0; xc <= xc1; xc++) + for (int zc = zc0; zc <= zc1; zc++) { + if (hasChunk(xc, zc)) { + getChunk(xc, zc)->getEntities(except, bb, _es); + } + } + return _es; } // List getEntitiesOfClass(Class baseClass, AABB bb) { @@ -1929,7 +1939,7 @@ EntityList& Level::getEntities(Entity* except, const AABB& bb) { // } const EntityList& Level::getAllEntities() { - return entities; + return entities; } // int countInstanceOf(Class clas) { @@ -1943,10 +1953,10 @@ const EntityList& Level::getAllEntities() { // /* void Level::addEntities(const EntityList& list) { - entities.insert(entities.end(), list.begin(), list.end()); - for (int j = 0; j < (int)list.size(); j++) { - entityAdded(list[j]); - } +entities.insert(entities.end(), list.begin(), list.end()); +for (int j = 0; j < (int)list.size(); j++) { +entityAdded(list[j]); +} } */ @@ -1955,65 +1965,65 @@ void Level::addEntities(const EntityList& list) { //} void Level::prepare() { - while (_chunkSource->tick()) - ; + while (_chunkSource->tick()) + ; } bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities,unsigned char face) { - int targetType = getTile(x, y, z); - const Tile* targetTile = Tile::tiles[targetType]; - Tile* tile = Tile::tiles[tileId]; + int targetType = getTile(x, y, z); + const Tile* targetTile = Tile::tiles[targetType]; + Tile* tile = Tile::tiles[tileId]; - AABB* aabb = tile->getAABB(this, x, y, z); - if (ignoreEntities) aabb = NULL; - if (aabb != NULL && !isUnobstructed(*aabb)) return false; - if (targetTile == Tile::water || targetTile == Tile::calmWater || targetTile == Tile::lava || targetTile == Tile::calmLava || targetTile == (Tile*)(Tile::fire) || targetTile == Tile::topSnow) targetTile = NULL; - if (tileId > 0 && targetTile == NULL) { - if (tile->mayPlace(this, x, y, z, face)) { - return true; - } - } + AABB* aabb = tile->getAABB(this, x, y, z); + if (ignoreEntities) aabb = NULL; + if (aabb != NULL && !isUnobstructed(*aabb)) return false; + if (targetTile == Tile::water || targetTile == Tile::calmWater || targetTile == Tile::lava || targetTile == Tile::calmLava || targetTile == (Tile*)(Tile::fire) || targetTile == Tile::topSnow) targetTile = NULL; + if (tileId > 0 && targetTile == NULL) { + if (tile->mayPlace(this, x, y, z, face)) { + return true; + } + } - return false; + return false; } int Level::getSeaLevel() { - return SEA_LEVEL; + return SEA_LEVEL; } bool Level::getDirectSignal(int x, int y, int z, int dir) { - int t = getTile(x, y, z); - if (t == 0) return false; - return Tile::tiles[t]->getDirectSignal(this, x, y, z, dir); + int t = getTile(x, y, z); + if (t == 0) return false; + return Tile::tiles[t]->getDirectSignal(this, x, y, z, dir); } bool Level::hasDirectSignal(int x, int y, int z) { - if (getDirectSignal(x, y - 1, z, 0)) return true; - if (getDirectSignal(x, y + 1, z, 1)) return true; - if (getDirectSignal(x, y, z - 1, 2)) return true; - if (getDirectSignal(x, y, z + 1, 3)) return true; - if (getDirectSignal(x - 1, y, z, 4)) return true; - if (getDirectSignal(x + 1, y, z, 5)) return true; - return false; + if (getDirectSignal(x, y - 1, z, 0)) return true; + if (getDirectSignal(x, y + 1, z, 1)) return true; + if (getDirectSignal(x, y, z - 1, 2)) return true; + if (getDirectSignal(x, y, z + 1, 3)) return true; + if (getDirectSignal(x - 1, y, z, 4)) return true; + if (getDirectSignal(x + 1, y, z, 5)) return true; + return false; } bool Level::getSignal(int x, int y, int z, int dir) { - if (isSolidBlockingTile(x, y, z)) { - return hasDirectSignal(x, y, z); - } - int t = getTile(x, y, z); - if (t == 0) return false; - return Tile::tiles[t]->getSignal(this, x, y, z, dir); + if (isSolidBlockingTile(x, y, z)) { + return hasDirectSignal(x, y, z); + } + int t = getTile(x, y, z); + if (t == 0) return false; + return Tile::tiles[t]->getSignal(this, x, y, z, dir); } bool Level::hasNeighborSignal(int x, int y, int z) { - if (getSignal(x, y - 1, z, 0)) return true; - if (getSignal(x, y + 1, z, 1)) return true; - if (getSignal(x, y, z - 1, 2)) return true; - if (getSignal(x, y, z + 1, 3)) return true; - if (getSignal(x - 1, y, z, 4)) return true; - if (getSignal(x + 1, y, z, 5)) return true; - return false; + if (getSignal(x, y - 1, z, 0)) return true; + if (getSignal(x, y + 1, z, 1)) return true; + if (getSignal(x, y, z - 1, 2)) return true; + if (getSignal(x, y, z + 1, 3)) return true; + if (getSignal(x - 1, y, z, 4)) return true; + if (getSignal(x + 1, y, z, 5)) return true; + return false; } // void checkSession() { @@ -2021,44 +2031,44 @@ bool Level::hasNeighborSignal(int x, int y, int z) { // } // void Level::setTime(long time) { - this->levelData.setTime(time); + this->levelData.setTime(time); } long Level::getSeed() { - return levelData.getSeed(); + return levelData.getSeed(); } long Level::getTime() { - return levelData.getTime(); + return levelData.getTime(); } Pos Level::getSharedSpawnPos() { - return Pos(levelData.getXSpawn(), levelData.getYSpawn(), levelData.getZSpawn()); + return Pos(levelData.getXSpawn(), levelData.getYSpawn(), levelData.getZSpawn()); } void Level::setSpawnPos(Pos spawnPos) { - levelData.setSpawn(spawnPos.x, spawnPos.y, spawnPos.z); + levelData.setSpawn(spawnPos.x, spawnPos.y, spawnPos.z); } /* void Level::ensureAdded(Entity* entity) { - int xc = Mth::floor(entity->x / 16); - int zc = Mth::floor(entity->z / 16); - int r = 2; - for (int x = xc - r; x <= xc + r; x++) { - for (int z = zc - r; z <= zc + r; z++) { - this->getChunk(x, z); - } - } +int xc = Mth::floor(entity->x / 16); +int zc = Mth::floor(entity->z / 16); +int r = 2; +for (int x = xc - r; x <= xc + r; x++) { +for (int z = zc - r; z <= zc + r; z++) { +this->getChunk(x, z); +} +} - if (std::find(entities.begin(), entities.end(), entity) == entities.end()) { - entities.push_back(entity); - } +if (std::find(entities.begin(), entities.end(), entity) == entities.end()) { +entities.push_back(entity); +} } */ bool Level::mayInteract(Player* player, int xt, int yt, int zt) { - return true; + return true; } void Level::broadcastEntityEvent(Entity* e, char eventId) { @@ -2070,40 +2080,40 @@ void Level::broadcastEntityEvent(Entity* e, char eventId) { /* void Level::removeAllPendingEntityRemovals() { - //Util::removeAll(entities, _entitiesToRemove); - // //entities.removeAll(entitiesToRemove); - // for (int j = 0; j < (int)_entitiesToRemove.size(); j++) { - // Entity* e = _entitiesToRemove[j]; - // int xc = e->xChunk; - // int zc = e->zChunk; - // if (e->inChunk && hasChunk(xc, zc)) { - // getChunk(xc, zc)->removeEntity(e); - // } - // } +//Util::removeAll(entities, _entitiesToRemove); +// //entities.removeAll(entitiesToRemove); +// for (int j = 0; j < (int)_entitiesToRemove.size(); j++) { +// Entity* e = _entitiesToRemove[j]; +// int xc = e->xChunk; +// int zc = e->zChunk; +// if (e->inChunk && hasChunk(xc, zc)) { +// getChunk(xc, zc)->removeEntity(e); +// } +// } - // for (unsigned int j = 0; j < _entitiesToRemove.size(); j++) { - // entityRemoved(_entitiesToRemove[j]); - // } - // _entitiesToRemove.clear(); +// for (unsigned int j = 0; j < _entitiesToRemove.size(); j++) { +// entityRemoved(_entitiesToRemove[j]); +// } +// _entitiesToRemove.clear(); - for (unsigned int i = 0; i < entities.size(); i++) { - Entity* e = entities[i]; +for (unsigned int i = 0; i < entities.size(); i++) { +Entity* e = entities[i]; - if (e->removed) { - int xc = e->xChunk; - int zc = e->zChunk; - if (e->inChunk && hasChunk(xc, zc)) { - getChunk(xc, zc)->removeEntity(e); - } - entities.erase( entities.begin() + (i--) ); - entityRemoved(e); - } - } +if (e->removed) { +int xc = e->xChunk; +int zc = e->zChunk; +if (e->inChunk && hasChunk(xc, zc)) { +getChunk(xc, zc)->removeEntity(e); +} +entities.erase( entities.begin() + (i--) ); +entityRemoved(e); +} +} } */ ChunkSource* Level::getChunkSource() { - return _chunkSource; + return _chunkSource; } // void tileEvent(int x, int y, int z, int b0, int b1) { @@ -2112,11 +2122,11 @@ ChunkSource* Level::getChunkSource() { // } LevelStorage* Level::getLevelStorage() { - return levelStorage; + return levelStorage; } LevelData* Level::getLevelData() { - return &levelData; + return &levelData; } void Level::takePicture( TripodCamera* cam, Entity* e ) @@ -2138,7 +2148,7 @@ int Level::getEntitiesOfType( int entityType, const AABB& bb, EntityList& list ) getChunk(xc, zc)->getEntitiesOfType(entityType, bb, list); } } - return list.size() - count; + return list.size() - count; } int Level::getEntitiesOfClass( int type, const AABB& bb, EntityList& list ) { @@ -2208,9 +2218,9 @@ void Level::updateSkyDarken() void Level::removePlayer( Player* player ) { for (unsigned int i = 0; i < players.size(); ++i) - if (players[i] == player) { - players.erase( players.begin() + i ); - } + if (players[i] == player) { + players.erase( players.begin() + i ); + } } int Level::isNightMode() { @@ -2231,7 +2241,7 @@ bool Level::inRange( int x, int y, int z ) { // AdventureSettings // AdventureSettings::AdventureSettings() -: doTickTime(true), + : doTickTime(true), noPvP(false), noPvM(false), noMvP(false), diff --git a/src/world/level/biome/Biome.cpp b/src/world/level/biome/Biome.cpp index 609ed52..f97cab8 100755 --- a/src/world/level/biome/Biome.cpp +++ b/src/world/level/biome/Biome.cpp @@ -8,6 +8,8 @@ #include "../../entity/MobCategory.h" #include "../../level/tile/TallGrass.h" +#include "../../../util/Color.h" + Biome* Biome::rainForest = NULL; Biome* Biome::swampland = NULL; Biome* Biome::seasonalForest = NULL; @@ -208,11 +210,11 @@ float Biome::adjustDepth( float depth ) int Biome::getSkyColor( float temp ) { -// temp /= 3.f; -// if (temp < -1) temp = -1; -// if (temp > 1) temp = 1; - return 0x80808080; - //return Color.getHSBColor(224 / 360.0f - temp * 0.05f, 0.50f + temp * 0.1f, 1.0f).getRGB(); + temp /= 3.f; + if (temp < -1) temp = -1; + if (temp > 1) temp = 1; +// return 0x80808080;This is the vanilla way, add it as OPTION_SKY or leave it like this bcus this function literally never gets used anyways if level has vanilla sky color - shredder + return Color::getHSBColor(224 / 360.0f - temp * 0.05f, 0.50f + temp * 0.1f, 1.0f).getRGB(); } Biome::MobList& Biome::getMobs(const MobCategory& category) diff --git a/src/world/level/chunk/LevelChunk.cpp b/src/world/level/chunk/LevelChunk.cpp index bb373fb..ef13d1b 100755 --- a/src/world/level/chunk/LevelChunk.cpp +++ b/src/world/level/chunk/LevelChunk.cpp @@ -262,14 +262,14 @@ void LevelChunk::recalcHeight(int x, int yStart, int z) { /*public*/ void LevelChunk::skyBrightnessChanged() { -// int x0 = xt; -// int y0 = this->minHeight - 16; -// int z0 = zt; -// int x1 = xt + 16; -// int y1 = Level::DEPTH - 1; -// int z1 = zt + 16; + int x0 = xt; + int y0 = this->minHeight - 16; + int z0 = zt; + int x1 = xt + 16; + int y1 = Level::DEPTH - 1; + int z1 = zt + 16; - //level->setTilesDirty(x0, y0, z0, x1, y1, z1); + level->setTilesDirty(x0, y0, z0, x1, y1, z1); } /*public*/ diff --git a/src/world/level/dimension/Dimension.cpp b/src/world/level/dimension/Dimension.cpp index 1345c07..c565409 100755 --- a/src/world/level/dimension/Dimension.cpp +++ b/src/world/level/dimension/Dimension.cpp @@ -15,7 +15,8 @@ Dimension::Dimension() ultraWarm(false), hasCeiling(false), biomeSource(NULL), - id(0) + id(0), + fogColor(0x80daff) { } @@ -93,6 +94,18 @@ float* Dimension::getSunriseColor( float td, float a ) Vec3 Dimension::getFogColor( float td, float a ) { + if (FogType == 1) + { + fogColor = 0xc0d8ff; // 1 returns java beta styled fog color. + } + else if (FogType == 2) + { + fogColor = 0x406fe5; // 2 returns some type of unused fog color IDK what this one was used for possibly early pe?? + } + else // otherwise as default we return the mcpe fog color + { + fogColor = 0x80daff; + } float br = Mth::cos(td * Mth::PI * 2) * 2 + 0.5f; if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; @@ -104,7 +117,8 @@ Vec3 Dimension::getFogColor( float td, float a ) g *= br * 0.94f + 0.06f; b *= br * 0.91f + 0.09f; return Vec3(r, g, b); - //return Vec3(0.752941f, 0.847059f, 1); + + // } bool Dimension::mayRespawn() diff --git a/src/world/level/dimension/Dimension.h b/src/world/level/dimension/Dimension.h index e77dbe3..b33861c 100755 --- a/src/world/level/dimension/Dimension.h +++ b/src/world/level/dimension/Dimension.h @@ -49,8 +49,11 @@ public: bool hasCeiling; float brightnessRamp[16];//Level::MAX_BRIGHTNESS + 1]; int id; + + // shredder added + int FogType; // lets us choose between what fog we want ig protected: - static const long fogColor = 0x80daff;//0x406fe5;//0xc0d8ff; + long fogColor; //= 0x80daff;//0x406fe5;//0xc0d8ff; float sunriseCol[4]; }; diff --git a/src/world/level/dimension/NormalDayCycleDimension.h b/src/world/level/dimension/NormalDayCycleDimension.h index 8e44a1a..321b10a 100755 --- a/src/world/level/dimension/NormalDayCycleDimension.h +++ b/src/world/level/dimension/NormalDayCycleDimension.h @@ -9,6 +9,7 @@ class NormalDayCycleDimension: public Dimension { public: + float getTimeOfDay(long time, float a) { int dayStep = (int) (time % Level::TICKS_PER_DAY); float td = (dayStep + a) / Level::TICKS_PER_DAY - 0.25f; @@ -20,6 +21,18 @@ public: } Vec3 getFogColor( float td, float a ) { + if (FogType == 1) + { + fogColor = 0xc0d8ff; // 1 returns java beta styled fog color. + } + else if (FogType == 2) + { + fogColor = 0x406fe5; // 2 returns some type of unused fog color IDK what this one was used for possibly early pe?? + } + else // otherwise as default we return the mcpe fog color + { + fogColor = 0x80daff; + } float br = cos(td * Mth::PI * 2) * 2 + 0.5f; if (br < 0) br = 0; if (br > 1.f) br = 1.f; @@ -35,7 +48,7 @@ public: return Vec3(r, g, b); } - + }; #endif /*NET_MINECRAFT_WORLD_LEVEL_DIMENSION__NormalDayCycleDimension_H__*/