diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index 32f824ea..b27f89bb 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -33,6 +33,15 @@ ChatScreen::ChatScreen() ChatScreen::s_chatIndex = 0; } +ChatScreen::ChatScreen(const wstring &initialMessage) +{ + frame = 0; + message = initialMessage; + cursorIndex = static_cast(message.length()); + s_historyIndex = -1; + ChatScreen::s_chatIndex = 0; +} + void ChatScreen::init() { Keyboard::enableRepeatEvents(true); diff --git a/Minecraft.Client/ChatScreen.h b/Minecraft.Client/ChatScreen.h index 70d65e8c..4c70f38c 100644 --- a/Minecraft.Client/ChatScreen.h +++ b/Minecraft.Client/ChatScreen.h @@ -22,6 +22,7 @@ private: public: ChatScreen(); + ChatScreen(const wstring &initialMessage); virtual void init(); virtual void removed(); virtual void tick(); diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index f546a289..50ff0da0 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -469,7 +469,6 @@ enum eMinecraftColour eMinecraftColour_Mob_Guardian_Colour2, eMinecraftColour_Mob_ElderGuardian_Colour1, eMinecraftColour_Mob_ElderGuardian_Colour2, - eMinecraftColour_Armour_Default_Leather_Colour, eMinecraftColour_Under_Water_Clear_Colour, @@ -568,6 +567,9 @@ enum eMinecraftColour //eHTMLColor_e_dark = 0x3f3f15, //r:3f , g: 3f, b: 15, i: 1e //eHTMLColor_f_dark = 0x3f3f3f, //r:3f , g: 3f, b: 3f, i: 1f + eMinecraftColour_Mob_PolarBear_Colour1, + eMinecraftColour_Mob_PolarBear_Colour2, + eMinecraftColour_COUNT, }; diff --git a/Minecraft.Client/Common/Audio/SoundNames.cpp b/Minecraft.Client/Common/Audio/SoundNames.cpp index 7c0dd382..afc3343c 100644 --- a/Minecraft.Client/Common/Audio/SoundNames.cpp +++ b/Minecraft.Client/Common/Audio/SoundNames.cpp @@ -287,7 +287,14 @@ const WCHAR *ConsoleSoundEngine::wchSoundNames[eSoundType_MAX]= L"mob.guardian.curse", L"mob.guardian.elder_death", L"mob.guardian.elder_hit", - L"mob.guardian.elder_idle" + L"mob.guardian.elder_idle", + + L"mob.polarbear.babyidle", + L"mob.polarbear.idle", + L"mob.polarbear.hurt", + L"mob.polarbear.death", + L"mob.polarbear.step", + L"mob.polarbear.warning" }; diff --git a/Minecraft.Client/Common/Colours/ColourTable.cpp b/Minecraft.Client/Common/Colours/ColourTable.cpp index 6e6b4755..7cbd849a 100644 --- a/Minecraft.Client/Common/Colours/ColourTable.cpp +++ b/Minecraft.Client/Common/Colours/ColourTable.cpp @@ -344,6 +344,8 @@ const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = L"Color_EnchantTextFocus", L"Color_EnchantTextDisabled", L"Color_RenamedItemTitle", + L"Mob_PolarBear_Colour1", + L"Mob_PolarBear_Colour2", }; void ColourTable::staticCtor() diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 0933db4a..d3e41d58 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -167,7 +167,12 @@ void IUIScene_CreativeMenu::staticCtor() ITEM_AUX(Tile::dirt_Id, DirtTile::PODZOL) ITEM(Tile::grass_path_Id) ITEM(Tile::nether_brick_Id) + ITEM(Tile::red_nether_brick_Id) ITEM(Tile::end_stone_Id) + ITEM(Tile::end_bricks_Id) + ITEM(Tile::magma_Id) + ITEM(Tile::nether_wart_block_Id) + ITEM(Tile::bone_block_Id) ITEM_AUX(Tile::quartz_block_Id,QuartzBlockTile::TYPE_CHISELED) ITEM_AUX(Tile::quartz_block_Id,QuartzBlockTile::TYPE_LINES_Y) ITEM(Tile::trapdoor_Id) @@ -499,6 +504,7 @@ void IUIScene_CreativeMenu::staticCtor() ITEM_AUX(Item::spawn_egg_Id, 100 | ((EntityHorse::TYPE_MULE + 1) << 12)); // Mule ITEM_AUX(Item::spawn_egg_Id, 120); // Villager ITEM_AUX(Item::spawn_egg_Id, 101); // Rabbit Brown + ITEM_AUX(Item::spawn_egg_Id, 107); // Polar Bear ITEM(Item::record_13_Id) ITEM(Item::record_cat_Id) ITEM(Item::record_blocks_Id) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index db4bd631..8121bb90 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -668,15 +668,11 @@ void UIController::loadSkins() } if(m_iggyLibraries[eLibrary_Platform] == IGGY_INVALID_LIBRARY) { -<<<<<<< Updated upstream - m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinHDWin.swf", L"platformskin.swf"); -======= m_iggyLibraries[eLibrary_Platform] = loadSkin(L"Graphics\\ControlType\\HD\\windowsHD.swf", L"platformskinHD.swf"); if(m_iggyLibraries[eLibrary_Platform] == IGGY_INVALID_LIBRARY) { m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinHDWin.swf", L"platformskinHD.swf"); } ->>>>>>> Stashed changes } // Non-HD skin set (720p/480p scenes import these) diff --git a/Minecraft.Client/Common/res/1_2_2/mob/bear/polarbear.png b/Minecraft.Client/Common/res/1_2_2/mob/bear/polarbear.png new file mode 100644 index 00000000..a340db83 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/bear/polarbear.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml b/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml index 3bc4010f..9aaf82ea 100644 --- a/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml +++ b/Minecraft.Client/Common/res/TitleUpdate/res/colours.xml @@ -291,6 +291,8 @@ if __name__=="__main__": notecolors() + + diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index accda0f7..43db7d3c 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -82,6 +82,8 @@ #include "BatRenderer.h" #include "CaveSpiderRenderer.h" #include "RabbitRenderer.h" +#include "PolarBearRenderer.h" +#include "PolarBearModel.h" #include "ArmorStandRenderer.h" #include "EndermiteRenderer.h" @@ -142,6 +144,7 @@ EntityRenderDispatcher::EntityRenderDispatcher() renderers[eTYPE_WITHERBOSS] = new WitherBossRenderer(); renderers[eTYPE_RABBIT] = new RabbitRenderer(); + renderers[eTYPE_POLARBEAR] = new PolarBearRenderer(new PolarBearModel(), 0.7f); renderers[eTYPE_ENTITY] = new DefaultRenderer(); diff --git a/Minecraft.Client/PolarBearModel.cpp b/Minecraft.Client/PolarBearModel.cpp new file mode 100644 index 00000000..bdd8b730 --- /dev/null +++ b/Minecraft.Client/PolarBearModel.cpp @@ -0,0 +1,78 @@ +#include "stdafx.h" +#include "PolarBearModel.h" +#include "ModelPart.h" + +PolarBearModel::PolarBearModel() : QuadrupedModel(10, 0) +{ + texWidth = 128; + texHeight = 64; + + float g = 0; + + head = new ModelPart(this, 0, 0); + head->addBox(-3.5f, -3, -3, 7, 7, 7, g); + head->setPos(0, 10, -16); + head->texOffs(0, 44)->addBox(-2.5f, 1, -6, 5, 3, 3, g); + head->texOffs(26, 0)->addBox(-4.5f, -4, -1, 2, 2, 1, g); + head->texOffs(26, 0)->addBox(2.5f, -4, -1, 2, 2, 1, g); + + body = new ModelPart(this, 0, 19); + body->addBox(-5, -13, -7, 14, 14, 11, g); + body->texOffs(39, 0)->addBox(-4, -25, -7, 12, 12, 10, g); + body->setPos(-2, 9, 12); + + leg0 = new ModelPart(this, 50, 22); + leg0->addBox(-2, 0, -2, 4, 10, 8, g); + leg0->setPos(-4.5f, 14, 6); + + leg1 = new ModelPart(this, 50, 22); + leg1->addBox(-2, 0, -2, 4, 10, 8, g); + leg1->setPos(4.5f, 14, 6); + + leg2 = new ModelPart(this, 50, 40); + leg2->addBox(-2, 0, -2, 4, 10, 6, g); + leg2->setPos(-3.5f, 14, -8); + + leg3 = new ModelPart(this, 50, 40); + leg3->addBox(-2, 0, -2, 4, 10, 6, g); + leg3->setPos(3.5f, 14, -8); + + head->compile(1.0f / 16.0f); + body->compile(1.0f / 16.0f); + leg0->compile(1.0f / 16.0f); + leg1->compile(1.0f / 16.0f); + leg2->compile(1.0f / 16.0f); + leg3->compile(1.0f / 16.0f); +} + +void PolarBearModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) +{ + setupAnim(time, r, bob, yRot, xRot, scale, entity); + + if (young) + { + glPushMatrix(); + glScalef(0.6666667f, 0.6666667f, 0.6666667f); + glTranslatef(0, scale * 16.0f, scale * 4.0f); + head->render(scale, usecompiled); + glPopMatrix(); + glPushMatrix(); + glScalef(0.5f, 0.5f, 0.5f); + glTranslatef(0, scale * 24.0f, 0); + body->render(scale, usecompiled); + leg0->render(scale, usecompiled); + leg1->render(scale, usecompiled); + leg2->render(scale, usecompiled); + leg3->render(scale, usecompiled); + glPopMatrix(); + } + else + { + head->render(scale, usecompiled); + body->render(scale, usecompiled); + leg0->render(scale, usecompiled); + leg1->render(scale, usecompiled); + leg2->render(scale, usecompiled); + leg3->render(scale, usecompiled); + } +} diff --git a/Minecraft.Client/PolarBearModel.h b/Minecraft.Client/PolarBearModel.h new file mode 100644 index 00000000..c0b6db97 --- /dev/null +++ b/Minecraft.Client/PolarBearModel.h @@ -0,0 +1,9 @@ +#pragma once +#include "QuadrupedModel.h" + +class PolarBearModel : public QuadrupedModel +{ +public: + PolarBearModel(); + virtual void render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled); +}; diff --git a/Minecraft.Client/PolarBearRenderer.cpp b/Minecraft.Client/PolarBearRenderer.cpp new file mode 100644 index 00000000..dec207e1 --- /dev/null +++ b/Minecraft.Client/PolarBearRenderer.cpp @@ -0,0 +1,18 @@ +#include "stdafx.h" +#include "PolarBearRenderer.h" + +ResourceLocation PolarBearRenderer::POLARBEAR_LOCATION = ResourceLocation(TN_MOB_POLARBEAR); + +PolarBearRenderer::PolarBearRenderer(Model *model, float shadow) : MobRenderer(model, shadow) +{ +} + +void PolarBearRenderer::render(shared_ptr _mob, double x, double y, double z, float rot, float a) +{ + MobRenderer::render(_mob, x, y, z, rot, a); +} + +ResourceLocation *PolarBearRenderer::getTextureLocation(shared_ptr mob) +{ + return &POLARBEAR_LOCATION; +} diff --git a/Minecraft.Client/PolarBearRenderer.h b/Minecraft.Client/PolarBearRenderer.h new file mode 100644 index 00000000..ec23307e --- /dev/null +++ b/Minecraft.Client/PolarBearRenderer.h @@ -0,0 +1,14 @@ +#pragma once +#include "MobRenderer.h" + +class PolarBearRenderer : public MobRenderer +{ +private: + static ResourceLocation POLARBEAR_LOCATION; + +public: + PolarBearRenderer(Model *model, float shadow); + + virtual void render(shared_ptr _mob, double x, double y, double z, float rot, float a); + virtual ResourceLocation *getTextureLocation(shared_ptr mob); +}; diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index d5205282..06918fde 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -194,6 +194,7 @@ const wchar_t *Textures::preLoaded[TN_COUNT] = L"mob/guardian", L"mob/guardian_elder", L"mob/guardian_beam", + L"mob/bear/polarbear", #ifdef _LARGE_WORLDS L"misc/additionalmapicons", diff --git a/Minecraft.Client/Textures.h b/Minecraft.Client/Textures.h index 48eec6a4..74e2aea5 100644 --- a/Minecraft.Client/Textures.h +++ b/Minecraft.Client/Textures.h @@ -180,7 +180,7 @@ typedef enum _TEXTURE_NAME TN_MOB_GUARDIAN, TN_MOB_GUARDIAN_ELDER, TN_MOB_GUARDIAN_BEAM, - + TN_MOB_POLARBEAR, #ifdef _LARGE_WORLDS TN_MISC_ADDITIONALMAPICONS, diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index a28a6091..07574f73 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -2191,6 +2191,12 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, pMinecraft->setScreen(new ChatScreen()); SetFocus(g_hWnd); } + if (g_KBMInput.IsKeyPressed(VK_OEM_2) && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL) + { + g_KBMInput.ClearCharBuffer(); + pMinecraft->setScreen(new ChatScreen(L"/")); + SetFocus(g_hWnd); + } #if 0 // has the game defined profile data been changed (by a profile load) diff --git a/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml b/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml index 22e373f7..13867127 100644 --- a/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml +++ b/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml @@ -9029,6 +9029,10 @@ All Ender Chests in a world are linked. Items placed into an Ender Chest are acc Rabbit + + Polar Bear + + A harmless creature. May drop a rabbit hide or a rabbit's foot when killed. @@ -9485,6 +9489,11 @@ All Ender Chests in a world are linked. Items placed into an Ender Chest are acc Dirt Path Beetroot + End Stone Bricks + Magma Block + Nether Wart Block + Red Nether Bricks + Bone Block Beetroot Beetroot Seeds Beetroot Stew diff --git a/Minecraft.Client/cmake/sources/Common.cmake b/Minecraft.Client/cmake/sources/Common.cmake index 454419f9..98119931 100644 --- a/Minecraft.Client/cmake/sources/Common.cmake +++ b/Minecraft.Client/cmake/sources/Common.cmake @@ -924,6 +924,10 @@ set(_MINECRAFT_CLIENT_COMMON_NET_MINECRAFT_CLIENT_RENDERER_ENTITY "${CMAKE_CURRENT_SOURCE_DIR}/ZombieRenderer.h" "${CMAKE_CURRENT_SOURCE_DIR}/RabbitRenderer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/RabbitRenderer.h" + "${CMAKE_CURRENT_SOURCE_DIR}/PolarBearModel.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/PolarBearModel.h" + "${CMAKE_CURRENT_SOURCE_DIR}/PolarBearRenderer.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/PolarBearRenderer.h" "${CMAKE_CURRENT_SOURCE_DIR}/ArmorStandRenderer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/EndermiteRenderer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/EndermiteRenderer.h" diff --git a/Minecraft.Client/stubs.cpp b/Minecraft.Client/stubs.cpp index 6caaaf2c..ddf2d99d 100644 --- a/Minecraft.Client/stubs.cpp +++ b/Minecraft.Client/stubs.cpp @@ -60,6 +60,7 @@ static const int s_keyToVK[] = { VK_SUBTRACT,// KEY_SUBTRACT = 53 VK_LEFT, // KEY_LEFT = 54 VK_RIGHT, // KEY_RIGHT = 55 + VK_OEM_2, // KEY_SLASH = 56 }; static const int s_keyToVKCount = sizeof(s_keyToVK) / sizeof(s_keyToVK[0]); diff --git a/Minecraft.Client/stubs.h b/Minecraft.Client/stubs.h index 60aa4885..97792a26 100644 --- a/Minecraft.Client/stubs.h +++ b/Minecraft.Client/stubs.h @@ -250,6 +250,7 @@ public: static const int KEY_SUBTRACT = 53; static const int KEY_LEFT = 54; static const int KEY_RIGHT = 55; + static const int KEY_SLASH = 56; #ifdef _WINDOWS64 // Map LWJGL-style key constant to Windows VK code diff --git a/Minecraft.World/BoneBlockTile.cpp b/Minecraft.World/BoneBlockTile.cpp new file mode 100644 index 00000000..c9ca2881 --- /dev/null +++ b/Minecraft.World/BoneBlockTile.cpp @@ -0,0 +1,22 @@ +#include "stdafx.h" +#include "net.minecraft.world.h" +#include "net.minecraft.world.entity.player.h" +#include "IconRegister.h" +#include "BoneBlockTile.h" + +BoneBlockTile::BoneBlockTile(int id) : HayBlockTile(id) +{ + material = Material::stone; +} + +void BoneBlockTile::playerDestroy(Level *level, shared_ptr player, int x, int y, int z, int data) +{ + if (player->canDestroy(this)) + Tile::playerDestroy(level, player, x, y, z, data); +} + +void BoneBlockTile::registerIcons(IconRegister *iconRegister) +{ + iconTop = iconRegister->registerIcon(L"bone_block_top"); + icon = iconRegister->registerIcon(L"bone_block_side"); +} diff --git a/Minecraft.World/BoneBlockTile.h b/Minecraft.World/BoneBlockTile.h new file mode 100644 index 00000000..28ccec55 --- /dev/null +++ b/Minecraft.World/BoneBlockTile.h @@ -0,0 +1,10 @@ +#pragma once +#include "HayBlockTile.h" + +class BoneBlockTile : public HayBlockTile +{ +public: + BoneBlockTile(int id); + virtual void registerIcons(IconRegister *iconRegister) override; + virtual void playerDestroy(Level *level, shared_ptr player, int x, int y, int z, int data) override; +}; diff --git a/Minecraft.World/Class.h b/Minecraft.World/Class.h index 09107147..83bb538e 100644 --- a/Minecraft.World/Class.h +++ b/Minecraft.World/Class.h @@ -138,6 +138,7 @@ enum eINSTANCEOF eTYPE_PIG = eTYPE_ANIMAL | eTYPE_ANIMALS_SPAWN_LIMIT_CHECK | 0x3, eTYPE_CHICKEN = eTYPE_ANIMAL | 0x4, eTYPE_RABBIT = eTYPE_ANIMAL | eTYPE_ANIMALS_SPAWN_LIMIT_CHECK | 0x5, + eTYPE_POLARBEAR = eTYPE_ANIMAL | eTYPE_ANIMALS_SPAWN_LIMIT_CHECK | 0x6, eTYPE_COW = eTYPE_ANIMAL | eTYPE_ANIMALS_SPAWN_LIMIT_CHECK | BIT_COW, eTYPE_MUSHROOMCOW = eTYPE_COW | 0x1, diff --git a/Minecraft.World/EntityIO.cpp b/Minecraft.World/EntityIO.cpp index f866e8b9..80379f5a 100644 --- a/Minecraft.World/EntityIO.cpp +++ b/Minecraft.World/EntityIO.cpp @@ -118,6 +118,10 @@ void EntityIO::staticCtor() eMinecraftColour_Mob_Rabbit_Colour1, eMinecraftColour_Mob_Rabbit_Colour2, IDS_RABBIT); + setId(PolarBear::create, eTYPE_POLARBEAR, L"PolarBear", 107, + eMinecraftColour_Mob_PolarBear_Colour1, + eMinecraftColour_Mob_PolarBear_Colour2, IDS_POLAR_BEAR); + setId(ArmorStand::create, eTYPE_ARMORSTAND, L"ArmorStand", 102); //change IDS_Endermite later diff --git a/Minecraft.World/HoeItem.cpp b/Minecraft.World/HoeItem.cpp index c6855cf5..5978c10b 100644 --- a/Minecraft.World/HoeItem.cpp +++ b/Minecraft.World/HoeItem.cpp @@ -38,7 +38,14 @@ bool HoeItem::useOn(shared_ptr instance, shared_ptr player return false; } -bool HoeItem::isHandEquipped() +float HoeItem::getDestroySpeed(shared_ptr itemInstance, Tile *tile) +{ + if (tile != nullptr && (tile->id == Tile::nether_wart_block_Id || tile->id == Tile::hayBlock->id)) + return tier->getSpeed(); + return Item::getDestroySpeed(itemInstance, tile); +} + +bool HoeItem::isHandEquipped() { return true; } diff --git a/Minecraft.World/HoeItem.h b/Minecraft.World/HoeItem.h index a4d015ac..bb3dd370 100644 --- a/Minecraft.World/HoeItem.h +++ b/Minecraft.World/HoeItem.h @@ -14,6 +14,7 @@ public: virtual bool useOn(shared_ptr instance, shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false); virtual bool isHandEquipped(); + virtual float getDestroySpeed(shared_ptr itemInstance, Tile *tile) override; const Tier *getTier(); }; \ No newline at end of file diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index 5b1e7f9b..ed710c5f 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -208,6 +208,15 @@ void LivingEntity::baseTick() hurt(DamageSource::inWall, 1); } + if (!level->isClientSide && isAlive() && onGround && !isSneaking() && tickCount % 10 == 0) + { + int tileBelow = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1, Mth::floor(z)); + if (tileBelow == Tile::magma_Id) + { + hurt(DamageSource::inFire, 1); + } + } + if (isFireImmune() || level->isClientSide) clearFire(); shared_ptr thisPlayer = dynamic_pointer_cast(shared_from_this()); bool isInvulnerable = (thisPlayer != nullptr && thisPlayer->abilities.invulnerable); diff --git a/Minecraft.World/MagmaTile.cpp b/Minecraft.World/MagmaTile.cpp new file mode 100644 index 00000000..ccc979cf --- /dev/null +++ b/Minecraft.World/MagmaTile.cpp @@ -0,0 +1,8 @@ +#include "stdafx.h" +#include "net.minecraft.world.level.h" +#include "MagmaTile.h" + +MagmaTile::MagmaTile(int id) : Tile(id, Material::stone) +{ + setLightEmission(0.2f); +} diff --git a/Minecraft.World/MagmaTile.h b/Minecraft.World/MagmaTile.h new file mode 100644 index 00000000..51abbf83 --- /dev/null +++ b/Minecraft.World/MagmaTile.h @@ -0,0 +1,8 @@ +#pragma once +#include "Tile.h" + +class MagmaTile : public Tile +{ +public: + MagmaTile(int id); +}; diff --git a/Minecraft.World/PolarBear.cpp b/Minecraft.World/PolarBear.cpp new file mode 100644 index 00000000..deea853c --- /dev/null +++ b/Minecraft.World/PolarBear.cpp @@ -0,0 +1,209 @@ +#include "stdafx.h" +#include "com.mojang.nbt.h" +#include "net.minecraft.world.level.tile.h" +#include "net.minecraft.world.phys.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.item.h" +#include "net.minecraft.world.entity.h" +#include "net.minecraft.world.entity.animal.h" +#include "net.minecraft.world.entity.ai.attributes.h" +#include "net.minecraft.world.entity.ai.goal.h" +#include "net.minecraft.world.entity.ai.goal.target.h" +#include "net.minecraft.world.entity.ai.navigation.h" +#include "net.minecraft.world.entity.player.h" +#include "net.minecraft.world.damagesource.h" +#include "SharedMonsterAttributes.h" +#include "PolarBear.h" +#include "../Minecraft.Client/Textures.h" +#include "SoundTypes.h" + +PolarBear::PolarBear(Level *level) : Animal(level) +{ + this->defineSynchedData(); + registerAttributes(); + setHealth(getMaxHealth()); + + m_standing = false; + clientSideStandAnimation = clientSideStandAnimationO = 0.0f; + warningSoundTicks = 0; + cubDefenseCooldown = 0; + + setSize(1.3f, 1.4f); + + getNavigation()->setAvoidWater(true); + goalSelector.addGoal(0, new FloatGoal(this)); + goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.25, true)); + goalSelector.addGoal(1, new PanicGoal(this, 2.0)); + goalSelector.addGoal(4, new FollowParentGoal(this, 1.25)); + goalSelector.addGoal(5, new RandomStrollGoal(this, 1.0)); + goalSelector.addGoal(6, new LookAtPlayerGoal(this, typeid(Player), 6)); + goalSelector.addGoal(7, new RandomLookAroundGoal(this)); + + targetSelector.addGoal(1, new HurtByTargetGoal(this, true)); +} + +bool PolarBear::useNewAi() +{ + return true; +} + +void PolarBear::registerAttributes() +{ + Animal::registerAttributes(); + + getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(30); + getAttribute(SharedMonsterAttributes::FOLLOW_RANGE)->setBaseValue(20); + getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.25f); + + getAttributes()->registerAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->setBaseValue(6); +} + +shared_ptr PolarBear::getBreedOffspring(shared_ptr target) +{ + return std::make_shared(level); +} + +bool PolarBear::isFood(shared_ptr itemInstance) +{ + return false; +} + +int PolarBear::getAmbientSound() +{ + return isBaby() ? eSoundType_MOB_POLARBEAR_BABY_AMBIENT : eSoundType_MOB_POLARBEAR_AMBIENT; +} + +int PolarBear::getHurtSound() +{ + return eSoundType_MOB_POLARBEAR_HURT; +} + +int PolarBear::getDeathSound() +{ + return eSoundType_MOB_POLARBEAR_DEATH; +} + +void PolarBear::playStepSound(int xt, int yt, int zt, int t) +{ + playSound(eSoundType_MOB_POLARBEAR_STEP, 0.15f, 1.0f); +} + +void PolarBear::playWarningSound() +{ + if (warningSoundTicks <= 0) + { + playSound(eSoundType_MOB_POLARBEAR_WARNING, 1.0f, getVoicePitch()); + warningSoundTicks = 40; + } +} + +void PolarBear::setTarget(shared_ptr newTarget) +{ + shared_ptr old = getTarget(); + Animal::setTarget(newTarget); + if (newTarget != nullptr && old == nullptr && !isBaby()) + { + playWarningSound(); + } +} + +int PolarBear::getDeathLoot() +{ + return Item::fish_Id; +} + +bool PolarBear::doHurtTarget(shared_ptr target) +{ + if (isBaby()) + { + return false; + } + float dmg = (float)getAttribute(SharedMonsterAttributes::ATTACK_DAMAGE)->getValue(); + return target->hurt(DamageSource::mobAttack(dynamic_pointer_cast(shared_from_this())), dmg); +} + +bool PolarBear::isStanding() +{ + return m_standing; +} + +void PolarBear::setStanding(bool standing) +{ + m_standing = standing; +} + +float PolarBear::getStandingAnimationScale(float a) +{ + return (clientSideStandAnimationO + (clientSideStandAnimation - clientSideStandAnimationO) * a) / 6.0f; +} + +void PolarBear::aiStep() +{ + Animal::aiStep(); + + if (level->isClientSide) + { + clientSideStandAnimationO = clientSideStandAnimation; + if (isStanding()) + { + clientSideStandAnimation = Mth::clamp(clientSideStandAnimation + 1.0f, 0.0f, 6.0f); + } + else + { + clientSideStandAnimation = Mth::clamp(clientSideStandAnimation - 1.0f, 0.0f, 6.0f); + } + } + + if (warningSoundTicks > 0) + { + --warningSoundTicks; + } + + if (!level->isClientSide && !isBaby() && getTarget() == nullptr) + { + if (cubDefenseCooldown > 0) + { + --cubDefenseCooldown; + } + else + { + cubDefenseCooldown = 10; + bool cubNear = false; + vector > *bears = level->getEntitiesOfClass(typeid(PolarBear), bb->grow(8.0, 4.0, 8.0)); + for (auto &it : *bears) + { + shared_ptr other = dynamic_pointer_cast(it); + if (other != nullptr && other.get() != this && other->isBaby()) + { + cubNear = true; + break; + } + } + delete bears; + if (cubNear) + { + shared_ptr p = level->getNearestAttackablePlayer(shared_from_this(), 16.0); + if (p != nullptr) + { + setTarget(dynamic_pointer_cast(p)); + } + } + } + } +} + +MobGroupData *PolarBear::finalizeMobSpawn(MobGroupData *groupData, int extraData) +{ + groupData = Animal::finalizeMobSpawn(groupData); + + if (groupData == nullptr || dynamic_cast(groupData) == nullptr) + { + groupData = new PolarBearGroupData(); + } + else + { + setAge(CUB_AGE); + } + + return groupData; +} diff --git a/Minecraft.World/PolarBear.h b/Minecraft.World/PolarBear.h new file mode 100644 index 00000000..1b83d00c --- /dev/null +++ b/Minecraft.World/PolarBear.h @@ -0,0 +1,59 @@ +#pragma once + +#include "Animal.h" +#include "MobGroupData.h" + +class DamageSource; + +class PolarBear : public Animal +{ +public: + eINSTANCEOF GetType() { return eTYPE_POLARBEAR; } + static Entity *create(Level *level) { return new PolarBear(level); } + +private: + static const int CUB_AGE = -23488; + + float clientSideStandAnimationO; + float clientSideStandAnimation; + int warningSoundTicks; + int cubDefenseCooldown; + +public: + PolarBear(Level *level); + + virtual bool useNewAi(); + +protected: + virtual void registerAttributes(); + +public: + virtual shared_ptr getBreedOffspring(shared_ptr target); + virtual bool isFood(shared_ptr itemInstance); + +protected: + virtual int getAmbientSound(); + virtual int getHurtSound(); + virtual int getDeathSound(); + virtual int getDeathLoot(); + virtual void playStepSound(int xt, int yt, int zt, int t); + +public: + virtual bool doHurtTarget(shared_ptr target); + virtual bool isStanding(); + void setStanding(bool standing); + float getStandingAnimationScale(float a); + + void playWarningSound(); + virtual void setTarget(shared_ptr target); + + virtual void aiStep(); + virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); + +private: + bool m_standing; +}; + +class PolarBearGroupData : public MobGroupData +{ +}; diff --git a/Minecraft.World/SoundTypes.h b/Minecraft.World/SoundTypes.h index a2d1bf4d..131760c4 100644 --- a/Minecraft.World/SoundTypes.h +++ b/Minecraft.World/SoundTypes.h @@ -275,7 +275,14 @@ enum eSOUND_TYPE eSoundType_MOB_ELDER_GUARDIAN_DEATH, eSoundType_MOB_ELDER_GUARDIAN_HIT, eSoundType_MOB_ELDER_GUARDIAN_IDLE, - + + eSoundType_MOB_POLARBEAR_BABY_AMBIENT, + eSoundType_MOB_POLARBEAR_AMBIENT, + eSoundType_MOB_POLARBEAR_HURT, + eSoundType_MOB_POLARBEAR_DEATH, + eSoundType_MOB_POLARBEAR_STEP, + eSoundType_MOB_POLARBEAR_WARNING, + eSoundType_MAX }; diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index 254a8d3d..a929a380 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -269,6 +269,11 @@ Tile* Tile::packedIce = nullptr; FrostedIceTile* Tile::frosted_ice = nullptr; GrassPathTile* Tile::grass_path = nullptr; BeetrootTile* Tile::beetroots = nullptr; +Tile* Tile::end_bricks = nullptr; +MagmaTile* Tile::magma = nullptr; +Tile* Tile::nether_wart_block = nullptr; +Tile* Tile::red_nether_brick = nullptr; +BoneBlockTile* Tile::bone_block = nullptr; Tile* Tile::barrier = nullptr; TallGrass2* Tile::double_plant = nullptr; @@ -584,6 +589,12 @@ void Tile::staticCtor() Tile::grass_path = static_cast((new GrassPathTile(grass_path_Id))->setDestroyTime(0.65f)->setSoundType(SOUND_GRAVEL)->setIconName(L"grass_path_top")->setDescriptionId(IDS_TILE_GRASS_PATH)->setUseDescriptionId(IDS_DESC_DIRT)->sendTileData()); Tile::frosted_ice = static_cast((new FrostedIceTile(frosted_ice_Id))->setDestroyTime(0.5f)->setLightBlock(3)->setSoundType(Tile::SOUND_GLASS)->setIconName(L"ice")->setDescriptionId(IDS_TILE_FROSTED_ICE)->setUseDescriptionId(IDS_DESC_ICE)->setNotCollectStatistics()); + Tile::end_bricks = (new Tile(end_bricks_Id, Material::stone))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(3.0f)->setExplodeable(9)->setSoundType(SOUND_STONE)->setIconName(L"end_bricks")->setDescriptionId(IDS_TILE_END_BRICKS)->setUseDescriptionId(IDS_DESC_STONE); + Tile::magma = static_cast((new MagmaTile(magma_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_stone)->setDestroyTime(0.5f)->setExplodeable(6)->setSoundType(SOUND_STONE)->setIconName(L"magma")->setDescriptionId(IDS_TILE_MAGMA)->setUseDescriptionId(IDS_DESC_STONE)); + Tile::nether_wart_block = (new Tile(nether_wart_block_Id, Material::grass))->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_wheat)->setDestroyTime(0.5f)->setSoundType(SOUND_WOOD)->setIconName(L"nether_wart_block")->setDescriptionId(IDS_TILE_NETHER_WART_BLOCK)->setUseDescriptionId(IDS_DESC_STONE); + Tile::red_nether_brick = (new Tile(red_nether_brick_Id, Material::stone))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(6)->setSoundType(SOUND_STONE)->setIconName(L"red_nether_brick")->setDescriptionId(IDS_TILE_RED_NETHER_BRICK)->setUseDescriptionId(IDS_DESC_STONE); + Tile::bone_block = static_cast((new BoneBlockTile(bone_block_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(1.5f)->setExplodeable(10)->setSoundType(SOUND_STONE)->setIconName(L"bone_block_side")->setDescriptionId(IDS_TILE_BONE_BLOCK)->setUseDescriptionId(IDS_DESC_STONE)->sendTileData()); + Tile::daylight_detector_inverted = static_cast((new DaylightDetectorTile(178, true))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR)); Tile::red_sandstone = (new RedSandStoneTile(red_sandstone_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_sand)->setSoundType(Tile::SOUND_STONE)->setDestroyTime(0.8f)->sendTileData()->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_RED_SANDSTONE)->sendTileData(); Tile::stairs_red_sandstone = (new StairTile(red_sandstone_stairs_Id, Tile::red_sandstone, 0))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sand)->setIconName(L"stairsRedSandstone")->setDescriptionId(IDS_TILE_STAIRS_RED_SANDSTONE)->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); @@ -1914,4 +1925,9 @@ const int Tile::dark_oak_stairs_Id; const int Tile::slime_Id; const int Tile::beetroots_Id; const int Tile::grass_path_Id; +const int Tile::end_bricks_Id; +const int Tile::magma_Id; +const int Tile::nether_wart_block_Id; +const int Tile::red_nether_brick_Id; +const int Tile::bone_block_Id; #endif diff --git a/Minecraft.World/Tile.h b/Minecraft.World/Tile.h index 10677db9..5e57055a 100644 --- a/Minecraft.World/Tile.h +++ b/Minecraft.World/Tile.h @@ -47,6 +47,8 @@ class TallGrass2; class FrostedIceTile; class GrassPathTile; class BeetrootTile; +class MagmaTile; +class BoneBlockTile; class ChunkRebuildData; @@ -443,15 +445,15 @@ public: //purpur_stairs 203 //purpur_double_slab 204 //purpur_slab 205 - //end_bricks 206 + static const int end_bricks_Id = 206; static const int beetroots_Id = 207; static const int grass_path_Id = 208; //end_gateway 209 static const int frosted_ice_Id = 212; - //magma 213 - //nether_wart_block 214 - //red_nether_brick 215 - //bone_block 216 + static const int magma_Id = 213; + static const int nether_wart_block_Id = 214; + static const int red_nether_brick_Id = 215; + static const int bone_block_Id = 216; //structure_void 217 // // @@ -668,6 +670,11 @@ public: static FrostedIceTile* frosted_ice; static GrassPathTile* grass_path; static BeetrootTile* beetroots; + static Tile* end_bricks; + static MagmaTile* magma; + static Tile* nether_wart_block; + static Tile* red_nether_brick; + static BoneBlockTile* bone_block; static Tile* seaLantern; static Tile* prismarine; diff --git a/Minecraft.World/cmake/sources/Common.cmake b/Minecraft.World/cmake/sources/Common.cmake index 7cc02d80..3c240fed 100644 --- a/Minecraft.World/cmake/sources/Common.cmake +++ b/Minecraft.World/cmake/sources/Common.cmake @@ -792,6 +792,8 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_ENTITY_ANIMAL "${CMAKE_CURRENT_SOURCE_DIR}/Wolf.h" "${CMAKE_CURRENT_SOURCE_DIR}/Rabbit.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Rabbit.h" + "${CMAKE_CURRENT_SOURCE_DIR}/PolarBear.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/PolarBear.h" "${CMAKE_CURRENT_SOURCE_DIR}/net.minecraft.world.entity.animal.h" ) source_group("net/minecraft/world/entity/animal" FILES ${_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_ENTITY_ANIMAL}) @@ -2049,6 +2051,10 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_TILE "${CMAKE_CURRENT_SOURCE_DIR}/GrassPathTile.h" "${CMAKE_CURRENT_SOURCE_DIR}/BeetrootTile.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/BeetrootTile.h" + "${CMAKE_CURRENT_SOURCE_DIR}/MagmaTile.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/MagmaTile.h" + "${CMAKE_CURRENT_SOURCE_DIR}/BoneBlockTile.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/BoneBlockTile.h" "${CMAKE_CURRENT_SOURCE_DIR}/RedSandStoneTile.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SeaLanternTile.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/PrismarineTile.cpp" diff --git a/Minecraft.World/net.minecraft.world.entity.animal.h b/Minecraft.World/net.minecraft.world.entity.animal.h index fc2c4de4..73f660db 100644 --- a/Minecraft.World/net.minecraft.world.entity.animal.h +++ b/Minecraft.World/net.minecraft.world.entity.animal.h @@ -23,4 +23,5 @@ #include "EntityHorse.h" //TU31 -#include "Rabbit.h" \ No newline at end of file +#include "Rabbit.h" +#include "PolarBear.h" \ No newline at end of file diff --git a/Minecraft.World/net.minecraft.world.level.tile.h b/Minecraft.World/net.minecraft.world.level.tile.h index e27a8afc..de065ea7 100644 --- a/Minecraft.World/net.minecraft.world.level.tile.h +++ b/Minecraft.World/net.minecraft.world.level.tile.h @@ -147,5 +147,7 @@ #include "StoneSlabTile2.h" #include "GrassPathTile.h" #include "BeetrootTile.h" +#include "MagmaTile.h" +#include "BoneBlockTile.h"