diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index 15a17978..fed940bb 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -438,6 +438,8 @@ enum eMinecraftColour eMinecraftColour_Mob_Witch_Colour2, eMinecraftColour_Mob_Horse_Colour1, eMinecraftColour_Mob_Horse_Colour2, + eMinecraftColour_Mob_Rabbit_Colour1, + eMinecraftColour_Mob_Rabbit_Colour2, eMinecraftColour_Armour_Default_Leather_Colour, diff --git a/Minecraft.Client/Common/Colours/ColourTable.cpp b/Minecraft.Client/Common/Colours/ColourTable.cpp index 07326b8c..9d079095 100644 --- a/Minecraft.Client/Common/Colours/ColourTable.cpp +++ b/Minecraft.Client/Common/Colours/ColourTable.cpp @@ -256,6 +256,9 @@ const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = L"Mob_Witch_Colour2", L"Mob_Horse_Colour1", L"Mob_Horse_Colour2", + L"Mob_Rabbit_Colour1", + L"Mob_Rabbit_Colour2", + L"Armour_Default_Leather_Colour", L"Under_Water_Clear_Colour", diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 01666132..16437c55 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -392,9 +392,11 @@ void IUIScene_CreativeMenu::staticCtor() ITEM_AUX(Item::spawnEgg_Id, 96); // Mooshroom ITEM_AUX(Item::spawnEgg_Id, 98); // Ozelot ITEM_AUX(Item::spawnEgg_Id, 100); // Horse + ITEM_AUX(Item::spawnEgg_Id, 100 | ((EntityHorse::TYPE_DONKEY + 1) << 12) ); // Donkey ITEM_AUX(Item::spawnEgg_Id, 100 | ((EntityHorse::TYPE_MULE + 1) << 12)); // Mule ITEM_AUX(Item::spawnEgg_Id, 120); // Villager + ITEM_AUX(Item::spawnEgg_Id, 101); // Rabbit Brown ITEM(Item::record_01_Id) ITEM(Item::record_02_Id) ITEM(Item::record_03_Id) diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/black.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/black.png new file mode 100644 index 00000000..5e99fff9 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/black.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/brown.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/brown.png new file mode 100644 index 00000000..76d8265a Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/brown.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/caerbannog.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/caerbannog.png new file mode 100644 index 00000000..e8f06fdd Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/caerbannog.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/gold.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/gold.png new file mode 100644 index 00000000..68aa6e82 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/gold.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/salt.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/salt.png new file mode 100644 index 00000000..b9704895 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/salt.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/toast.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/toast.png new file mode 100644 index 00000000..1f8cc852 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/toast.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/white.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/white.png new file mode 100644 index 00000000..96faf538 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/white.png differ diff --git a/Minecraft.Client/Common/res/1_2_2/mob/rabbit/white_splotched.png b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/white_splotched.png new file mode 100644 index 00000000..c4d265c3 Binary files /dev/null and b/Minecraft.Client/Common/res/1_2_2/mob/rabbit/white_splotched.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/black.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/black.png new file mode 100644 index 00000000..5e99fff9 Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/black.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/brown.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/brown.png new file mode 100644 index 00000000..76d8265a Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/brown.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/caerbannog.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/caerbannog.png new file mode 100644 index 00000000..e8f06fdd Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/caerbannog.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/gold.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/gold.png new file mode 100644 index 00000000..68aa6e82 Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/gold.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/salt.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/salt.png new file mode 100644 index 00000000..b9704895 Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/salt.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/toast.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/toast.png new file mode 100644 index 00000000..1f8cc852 Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/toast.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/white.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/white.png new file mode 100644 index 00000000..96faf538 Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/white.png differ diff --git a/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/white_splotched.png b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/white_splotched.png new file mode 100644 index 00000000..c4d265c3 Binary files /dev/null and b/Minecraft.Client/Common/res/TitleUpdate/res/mob/rabbit/white_splotched.png differ diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index 01972e56..b848ca6f 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -82,6 +82,7 @@ #include "ZombieRenderer.h" #include "BatRenderer.h" #include "CaveSpiderRenderer.h" +#include "RabbitRenderer.h" double EntityRenderDispatcher::xOff = 0.0; double EntityRenderDispatcher::yOff = 0.0; @@ -132,6 +133,8 @@ EntityRenderDispatcher::EntityRenderDispatcher() renderers[eTYPE_WITHERBOSS] = new WitherBossRenderer(); + renderers[eTYPE_RABBIT] = new RabbitRenderer(); + renderers[eTYPE_ENTITY] = new DefaultRenderer(); renderers[eTYPE_PAINTING] = new PaintingRenderer(); renderers[eTYPE_ITEM_FRAME] = new ItemFrameRenderer(); diff --git a/Minecraft.Client/Minecraft.Client.vcxproj b/Minecraft.Client/Minecraft.Client.vcxproj index d97cbc38..e24355eb 100644 --- a/Minecraft.Client/Minecraft.Client.vcxproj +++ b/Minecraft.Client/Minecraft.Client.vcxproj @@ -20711,6 +20711,8 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU + + true true @@ -37928,6 +37930,8 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CUtrue true + + true true diff --git a/Minecraft.Client/Minecraft.Client.vcxproj.filters b/Minecraft.Client/Minecraft.Client.vcxproj.filters index 23b754fa..9ea3d45b 100644 --- a/Minecraft.Client/Minecraft.Client.vcxproj.filters +++ b/Minecraft.Client/Minecraft.Client.vcxproj.filters @@ -3793,6 +3793,12 @@ Header Files + + net\minecraft\client\model + + + net\minecraft\client\renderer\entity + @@ -5949,6 +5955,12 @@ include\lce_filesystem + + net\minecraft\client\model + + + net\minecraft\client\renderer\entity + diff --git a/Minecraft.Client/RabbitModel.cpp b/Minecraft.Client/RabbitModel.cpp new file mode 100644 index 00000000..82ca5fa4 --- /dev/null +++ b/Minecraft.Client/RabbitModel.cpp @@ -0,0 +1,110 @@ +#include "stdafx.h" +#include "RabbitModel.h" +#include "ModelPart.h" +#include "..\Minecraft.World\Mth.h" +#include "../Minecraft.World/Rabbit.h" + +#define PI 3.14159265358979323846f + +RabbitModel::RabbitModel() : Model() +{ + this->texWidth = 64; + this->texHeight = 32; + + // head part + head = new ModelPart(this, 32, 0); + head->addBox(-2.5F, -4.0F, -5.0F, 5, 4, 5); + head->setPos(0.0F, 16.0F, -1.0F); + + rightEar = new ModelPart(this, 52, 0); + rightEar->addBox(-2.5F, -9.0F, -1.0F, 2, 5, 1); + rightEar->setPos(0.0F, 0.0F, 0.0F); + rightEar->yRot = -PI / 12.0f; + + leftEar = new ModelPart(this, 58, 0); + leftEar->addBox(0.5F, -9.0F, -1.0F, 2, 5, 1); + leftEar->setPos(0.0F, 0.0F, 0.0F); + leftEar->yRot = PI / 12.0f; + + nose = new ModelPart(this, 32, 9); + nose->addBox(-0.5F, -2.5F, -5.5F, 1, 1, 1); + nose->setPos(0.0F, 0.0F, 0.0F); + + head->addChild(rightEar); + head->addChild(leftEar); + head->addChild(nose); + + // body part + body = new ModelPart(this, 0, 0); + body->addBox(-3.0F, -2.0F, -10.0F, 6, 5, 10); + body->setPos(0.0F, 19.0F, 8.0F); + body->xRot = -PI / 9.0f; + + tail = new ModelPart(this, 52, 6); + tail->addBox(-1.5F, -1.5F, 0.0F, 3, 3, 2); + tail->setPos(0.0F, 20.0F, 7.0F); + tail->xRot = -0.3490659F; + + // front legs + leftHindThigh = new ModelPart(this, 30, 15); + leftHindThigh->addBox(-1.0F, 0.0F, 0.0F, 2, 4, 5); + leftHindThigh->setPos(3.0F, 17.5F, 3.7F); + leftHindThigh->xRot = -0.36651915F; + + leftHindFoot = new ModelPart(this, 26, 24); + leftHindFoot->addBox(-1.0F, 5.5F, -3.7F, 2, 1, 7); + leftHindFoot->setPos(0.0F, 0.0F, 0.0F); + leftHindFoot->xRot = 0.36651915F; + leftHindThigh->addChild(leftHindFoot); + + rightHindThigh = new ModelPart(this, 16, 15); + rightHindThigh->addBox(-1.0F, 0.0F, 0.0F, 2, 4, 5); + rightHindThigh->setPos(-3.0F, 17.5F, 3.7F); + rightHindThigh->xRot = -0.36651915F; + + rightHindFoot = new ModelPart(this, 8, 24); + rightHindFoot->addBox(-1.0F, 5.5F, -3.7F, 2, 1, 7); + rightHindFoot->setPos(0.0F, 0.0F, 0.0F); + rightHindFoot->xRot = 0.36651915F; + rightHindThigh->addChild(rightHindFoot); + + // back legs + leftFrontLeg = new ModelPart(this, 8, 15); + leftFrontLeg->addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2); + leftFrontLeg->setPos(3.0F, 17.0F, -1.0F); + leftFrontLeg->xRot = -0.19198622F; + + rightFrontLeg = new ModelPart(this, 0, 15); + rightFrontLeg->addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2); + rightFrontLeg->setPos(-3.0F, 17.0F, -1.0F); + rightFrontLeg->xRot = -0.19198622F; +} + +void RabbitModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) +{ + shared_ptr rabbit = dynamic_pointer_cast(entity); + + // head animation + head->xRot = xRot * (PI / 180.0f); + head->yRot = yRot * (PI / 180.0f); + + // jump animation + float jumpCompletion = 0.0f; + if (rabbit) jumpCompletion = rabbit->getJumpCompletion(bob); + + float jumpSin = Mth::sin(jumpCompletion * PI); + + leftHindThigh->xRot = -0.36651915F + (jumpSin * 50.0f * (PI / 180.0f)); + rightHindThigh->xRot = -0.36651915F + (jumpSin * 50.0f * (PI / 180.0f)); + leftFrontLeg->xRot = -0.19198622F + (jumpSin * -40.0f * (PI / 180.0f)); + rightFrontLeg->xRot = -0.19198622F + (jumpSin * -40.0f * (PI / 180.0f)); + + + head->render(scale, usecompiled); + body->render(scale, usecompiled); + tail->render(scale, usecompiled); + leftHindThigh->render(scale, usecompiled); + rightHindThigh->render(scale, usecompiled); + leftFrontLeg->render(scale, usecompiled); + rightFrontLeg->render(scale, usecompiled); +} \ No newline at end of file diff --git a/Minecraft.Client/RabbitModel.h b/Minecraft.Client/RabbitModel.h new file mode 100644 index 00000000..fdfe3a2f --- /dev/null +++ b/Minecraft.Client/RabbitModel.h @@ -0,0 +1,29 @@ +#pragma once +#include "Model.h" + +class RabbitModel : public Model +{ +private: + ModelPart *head; + ModelPart *nose; + ModelPart *leftEar; + ModelPart *rightEar; + + ModelPart *body; + ModelPart *tail; + ModelPart *leftFrontLeg; + ModelPart *rightFrontLeg; + + ModelPart *leftHindThigh; + ModelPart *leftHindFoot; + ModelPart *rightHindThigh; + ModelPart *rightHindFoot; + +public: + RabbitModel(); + + virtual void render(shared_ptr entity, + float time, float r, float bob, + float yRot, float xRot, + float scale, bool usecompiled) override; +}; \ No newline at end of file diff --git a/Minecraft.Client/RabbitRenderer.cpp b/Minecraft.Client/RabbitRenderer.cpp new file mode 100644 index 00000000..7f3d1331 --- /dev/null +++ b/Minecraft.Client/RabbitRenderer.cpp @@ -0,0 +1,51 @@ +#include "stdafx.h" +#include "RabbitRenderer.h" +#include "RabbitModel.h" +#include "MobRenderer.h" +#include "../Minecraft.World/Rabbit.h" + + +ResourceLocation RabbitRenderer::LOC_BROWN = ResourceLocation(TN_MOB_RABBIT_BROWN); +ResourceLocation RabbitRenderer::LOC_WHITE = ResourceLocation(TN_MOB_RABBIT_WHITE); +ResourceLocation RabbitRenderer::LOC_BLACK = ResourceLocation(TN_MOB_RABBIT_BLACK); +ResourceLocation RabbitRenderer::LOC_GOLD = ResourceLocation(TN_MOB_RABBIT_GOLD); +ResourceLocation RabbitRenderer::LOC_SALT = ResourceLocation(TN_MOB_RABBIT_SALT); +ResourceLocation RabbitRenderer::LOC_WHITE_SPLOTCHED = ResourceLocation(TN_MOB_RABBIT_WHITE_SPLOTCHED); +ResourceLocation RabbitRenderer::LOC_TOAST = ResourceLocation(TN_MOB_RABBIT_TOAST); +ResourceLocation RabbitRenderer::LOC_EVIL = ResourceLocation(TN_MOB_RABBIT_CAERBANNOG); + +RabbitRenderer::RabbitRenderer() : MobRenderer(new RabbitModel(), 0.3f) +{ + +} + +ResourceLocation *RabbitRenderer::getTextureLocation(shared_ptr entity) +{ + shared_ptr mob = dynamic_pointer_cast(entity); + if (mob == nullptr) return &LOC_BROWN; + + // easter egg toast + if (mob->hasCustomName() && mob->getCustomName() == L"Toast") + { + return &LOC_TOAST; + } + + // variants + switch (mob->getVariant()) + { + case Rabbit::Variant::WHITE: return &LOC_WHITE; + case Rabbit::Variant::BLACK: return &LOC_BLACK; + case Rabbit::Variant::GOLD: return &LOC_GOLD; + case Rabbit::Variant::SALT: return &LOC_SALT; + case Rabbit::Variant::WHITE_SPLOTCHED: return &LOC_WHITE_SPLOTCHED; + case Rabbit::Variant::EVIL: return &LOC_EVIL; + case Rabbit::Variant::BROWN: + default: return &LOC_BROWN; + } +} + +void RabbitRenderer::scale(shared_ptr _mob, float a) +{ + + glScalef(0.65f, 0.65f, 0.65f); +} \ No newline at end of file diff --git a/Minecraft.Client/RabbitRenderer.h b/Minecraft.Client/RabbitRenderer.h new file mode 100644 index 00000000..74e94083 --- /dev/null +++ b/Minecraft.Client/RabbitRenderer.h @@ -0,0 +1,27 @@ +#pragma once +#include "MobRenderer.h" + +class Rabbit; +class LivingEntity; + +class RabbitRenderer : public MobRenderer +{ +private: + + static ResourceLocation LOC_BROWN; + static ResourceLocation LOC_WHITE; + static ResourceLocation LOC_BLACK; + static ResourceLocation LOC_GOLD; + static ResourceLocation LOC_SALT; + static ResourceLocation LOC_WHITE_SPLOTCHED; + static ResourceLocation LOC_TOAST; + static ResourceLocation LOC_EVIL; + +public: + RabbitRenderer(); + + virtual ResourceLocation *getTextureLocation(shared_ptr entity) override; + +protected: + virtual void scale(shared_ptr mob, float a) override; +}; \ No newline at end of file diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index ba7c0282..13efd3e7 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -156,6 +156,17 @@ const wchar_t *Textures::preLoaded[TN_COUNT] = L"mob/wither/wither_armor", L"mob/wither/wither_invulnerable", + //TU31 + L"mob/rabbit/brown", + L"mob/rabbit/white", + L"mob/rabbit/black", + L"mob/rabbit/gold", + L"mob/rabbit/salt", + L"mob/rabbit/white_splotched", + L"mob/rabbit/toast", + L"mob/rabbit/caerbannog", + + L"item/trapped", L"item/trapped_double", //L"item/christmas", diff --git a/Minecraft.Client/Textures.h b/Minecraft.Client/Textures.h index 1fca5610..73cf15cd 100644 --- a/Minecraft.Client/Textures.h +++ b/Minecraft.Client/Textures.h @@ -146,6 +146,16 @@ typedef enum _TEXTURE_NAME TN_MOB_WITHER_ARMOR, TN_MOB_WITHER_INVULNERABLE, + //TU31 + TN_MOB_RABBIT_BROWN, + TN_MOB_RABBIT_WHITE, + TN_MOB_RABBIT_BLACK, + TN_MOB_RABBIT_GOLD, + TN_MOB_RABBIT_SALT, + TN_MOB_RABBIT_WHITE_SPLOTCHED, + TN_MOB_RABBIT_TOAST, + TN_MOB_RABBIT_CAERBANNOG, + TN_TILE_TRAP_CHEST, TN_TILE_LARGE_TRAP_CHEST, //TN_TILE_XMAS_CHEST, diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 9e3bc4c5..388f0afa 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -116,6 +116,8 @@ Biome::Biome(int id) : id(id) friendlies_chicken.push_back(new MobSpawnerData(eTYPE_CHICKEN, 10, 4, 4)); // 4J - moved chickens to their own category friendlies.push_back(new MobSpawnerData(eTYPE_COW, 8, 4, 4)); + friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 7, 1, 2)); + enemies.push_back(new MobSpawnerData(eTYPE_SPIDER, 10, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_ZOMBIE, 10, 4, 4)); enemies.push_back(new MobSpawnerData(eTYPE_SKELETON, 10, 4, 4)); diff --git a/Minecraft.World/Class.h b/Minecraft.World/Class.h index 25802c3f..103c0f1b 100644 --- a/Minecraft.World/Class.h +++ b/Minecraft.World/Class.h @@ -136,6 +136,7 @@ enum eINSTANCEOF eTYPE_SHEEP = eTYPE_ANIMAL | eTYPE_ANIMALS_SPAWN_LIMIT_CHECK | 0x2, 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_COW = eTYPE_ANIMAL | eTYPE_ANIMALS_SPAWN_LIMIT_CHECK | BIT_COW, eTYPE_MUSHROOMCOW = eTYPE_COW | 0x1, @@ -409,6 +410,7 @@ public: classes->push_back( SUBCLASS(eTYPE_SHEEP )->addParent( eTYPE_ANIMAL)->addParent(eTYPE_ANIMALS_SPAWN_LIMIT_CHECK ) ); classes->push_back( SUBCLASS(eTYPE_PIG )->addParent( eTYPE_ANIMAL)->addParent(eTYPE_ANIMALS_SPAWN_LIMIT_CHECK ) ); classes->push_back( SUBCLASS(eTYPE_CHICKEN )->addParent( eTYPE_ANIMAL ) ); + classes->push_back( SUBCLASS(eTYPE_COW )->addParent( eTYPE_ANIMAL)->addParent(eTYPE_ANIMALS_SPAWN_LIMIT_CHECK ) ); classes->push_back( SUBCLASS(eTYPE_MUSHROOMCOW )->addParent( eTYPE_COW ) ); classes->push_back( SUBCLASS(eTYPE_WATERANIMAL )->addParent(eTYPE_PATHFINDER_MOB) ); diff --git a/Minecraft.World/EntityIO.cpp b/Minecraft.World/EntityIO.cpp index 9c7c64d4..876de250 100644 --- a/Minecraft.World/EntityIO.cpp +++ b/Minecraft.World/EntityIO.cpp @@ -104,6 +104,10 @@ void EntityIO::staticCtor() setId(Ocelot::create, eTYPE_OCELOT, L"Ozelot", 98, eMinecraftColour_Mob_Ocelot_Colour1, eMinecraftColour_Mob_Ocelot_Colour2, IDS_OZELOT); setId(VillagerGolem::create, eTYPE_VILLAGERGOLEM, L"VillagerGolem", 99); setId(EntityHorse::create, eTYPE_HORSE, L"EntityHorse", 100, eMinecraftColour_Mob_Horse_Colour1, eMinecraftColour_Mob_Horse_Colour2, IDS_HORSE); + setId(Rabbit::create, eTYPE_RABBIT, L"Rabbit", 101, + eMinecraftColour_Mob_Rabbit_Colour1, + eMinecraftColour_Mob_Rabbit_Colour2, IDS_HORSE);//change IDS_RABBIT later + setId(Villager::create, eTYPE_VILLAGER, L"Villager", 120, eMinecraftColour_Mob_Villager_Colour1, eMinecraftColour_Mob_Villager_Colour2, IDS_VILLAGER); @@ -112,6 +116,7 @@ void EntityIO::staticCtor() // 4J Added setId(DragonFireball::create, eTYPE_DRAGON_FIREBALL, L"DragonFireball", 1000); + // 4J-PB - moved to allow the eggs to be named and coloured in the Creative Mode menu // 4J Added for custom spawn eggs setId(EntityHorse::create, eTYPE_HORSE, L"EntityHorse", 100 | ((EntityHorse::TYPE_DONKEY + 1) << 12), eMinecraftColour_Mob_Horse_Colour1, eMinecraftColour_Mob_Horse_Colour2, IDS_DONKEY); @@ -125,6 +130,8 @@ void EntityIO::staticCtor() setId(Ocelot::create, eTYPE_OCELOT, L"Ozelot", 98 | ((Ocelot::TYPE_SIAMESE + 1) << 12), eMinecraftColour_Mob_Ocelot_Colour1, eMinecraftColour_Mob_Ocelot_Colour2, IDS_OZELOT ); setId(Spider::create, eTYPE_SPIDER, L"Spider", 52 | (2 << 12), eMinecraftColour_Mob_Spider_Colour1, eMinecraftColour_Mob_Spider_Colour2, IDS_SKELETON ); #endif + + } shared_ptr EntityIO::newEntity(const wstring& id, Level *level) diff --git a/Minecraft.World/Minecraft.World.vcxproj b/Minecraft.World/Minecraft.World.vcxproj index b6af9153..d3683776 100644 --- a/Minecraft.World/Minecraft.World.vcxproj +++ b/Minecraft.World/Minecraft.World.vcxproj @@ -2704,6 +2704,7 @@ + @@ -3629,6 +3630,7 @@ + diff --git a/Minecraft.World/Minecraft.World.vcxproj.filters b/Minecraft.World/Minecraft.World.vcxproj.filters index bf872596..c7273fdd 100644 --- a/Minecraft.World/Minecraft.World.vcxproj.filters +++ b/Minecraft.World/Minecraft.World.vcxproj.filters @@ -3197,6 +3197,9 @@ net\minecraft\world\inventory + + net\minecraft\world\entity\animal + @@ -5626,5 +5629,8 @@ net\minecraft\world\item + + net\minecraft\world\entity\animal + \ No newline at end of file diff --git a/Minecraft.World/Rabbit.cpp b/Minecraft.World/Rabbit.cpp new file mode 100644 index 00000000..881c9d8f --- /dev/null +++ b/Minecraft.World/Rabbit.cpp @@ -0,0 +1,125 @@ +#include "stdafx.h" +#include "Rabbit.h" +#include "SynchedEntityData.h" +#include "AttributeInstance.h" +#include "SharedMonsterAttributes.h" +#include "net.minecraft.world.item.h" +#include "net.minecraft.world.entity.ai.goal.h" +#include "net.minecraft.world.entity.ai.navigation.h" +#include "net.minecraft.world.level.h" +#include "com.mojang.nbt.h" +#include "SoundTypes.h" + +Rabbit::Rabbit(Level *level) : Animal(level) +{ + jumpCompletion = 0.0f; + jumpTicks = 0; + moreCarrotTicks = 0; + + + this->defineSynchedData(); + this->registerAttributes(); + this->setHealth(this->getMaxHealth()); + + this->setSize(0.4f, 0.5f); + this->getNavigation()->setAvoidWater(true); + + // AI Goals + goalSelector.addGoal(1, new FloatGoal(this)); + goalSelector.addGoal(2, new PanicGoal(this, 2.2f)); + goalSelector.addGoal(3, new BreedGoal(this, 0.8f)); + goalSelector.addGoal(4, new TemptGoal(this, 1.0f, Item::carrots_Id, false)); + goalSelector.addGoal(6, new RandomStrollGoal(this, 0.6f)); + goalSelector.addGoal(7, new LookAtPlayerGoal(this, typeid(Player), 10.0f)); +} + +float Rabbit::getJumpCompletion(float partialTick) const { + return jumpCompletion; +} + +Rabbit::Variant Rabbit::getVariant() const { + + return (Variant)entityData->getInteger(DATA_TYPE_ID); +} + +void Rabbit::setVariant(Variant v) { + entityData->set(DATA_TYPE_ID, (int)v); +} + +void Rabbit::defineSynchedData() { + Animal::defineSynchedData(); + entityData->define(DATA_TYPE_ID, (int)Variant::BROWN); +} + +void Rabbit::registerAttributes() { + Animal::registerAttributes(); + getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(3.0); + + getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.3); +} + +bool Rabbit::useNewAi() { + return true; +} + + + +void Rabbit::tick() { + Animal::tick(); + + if (!onGround) { + jumpTicks++; + } else { + + bool canJump = (tickCount % 5 == 0); + + if (!getNavigation()->isDone() && jumpTicks == 0 && canJump) { + + + this->yd = 0.32f; + + + float speed = (float)getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->getValue(); + this->moveRelative(0.0f, 1.0f, speed); + + + this->hasImpulse = true; + } + jumpTicks = 0; + } + + + jumpCompletion = onGround ? jumpCompletion * 0.8f : (float)jumpTicks / 5.0f; + if (jumpCompletion > 1.0f) jumpCompletion = 1.0f; +} + +bool Rabbit::isFood(shared_ptr item) { + if (item == nullptr || item->getItem() == nullptr) return false; + + + int id = item->getItem()->id; + return id == Item::carrots_Id || id == Item::carrots_Id || id == Item::carrotGolden_Id; +} + +shared_ptr Rabbit::getBreedOffspring(shared_ptr target) { + if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) + return std::make_shared(level); + return nullptr; +} + + +int Rabbit::getAmbientSound() { return eSoundType_MOB_BAT_IDLE; } +int Rabbit::getHurtSound() { return eSoundType_MOB_BAT_HURT; } +int Rabbit::getDeathSound() { return eSoundType_MOB_BAT_DEATH; } + +void Rabbit::readAdditionalSaveData(CompoundTag *tag) { + Animal::readAdditionalSaveData(tag); + if (tag->contains(L"RabbitType")) { + setVariant((Variant)tag->getInt(L"RabbitType")); + } +} + +void Rabbit::addAdditonalSaveData(CompoundTag *tag) { + Animal::addAdditonalSaveData(tag); + tag->putInt(L"RabbitType", (int)getVariant()); +} \ No newline at end of file diff --git a/Minecraft.World/Rabbit.h b/Minecraft.World/Rabbit.h new file mode 100644 index 00000000..d60ca5f7 --- /dev/null +++ b/Minecraft.World/Rabbit.h @@ -0,0 +1,56 @@ +#pragma once +#include "Animal.h" + +class Rabbit : public Animal +{ +public: + enum class Variant + { + BROWN = 0, + WHITE = 1, + BLACK = 2, + GOLD = 3, + SALT = 4, + WHITE_SPLOTCHED = 5, + EVIL = 99, + }; + + eINSTANCEOF GetType() { return eTYPE_RABBIT; } + static Entity *create(Level *level) { return new Rabbit(level); } + +private: + static const int DATA_TYPE_ID = 16; + + float jumpCompletion; + int jumpTicks; + int moreCarrotTicks; + +public: + Rabbit(Level *level); + virtual ~Rabbit() {} + + float getJumpCompletion(float partialTick) const; + + Variant getVariant() const; + void setVariant(Variant v); + + virtual bool useNewAi() override; + virtual void tick() override; + +protected: + virtual void registerAttributes() override; + virtual void defineSynchedData() override; + + virtual int getAmbientSound() override; + virtual int getHurtSound() override; + virtual int getDeathSound() override; + virtual float getSoundVolume() override { return 0.6f; } + virtual bool makeStepSound() override { return true; } + +public: + virtual bool isFood(shared_ptr item) override; + virtual shared_ptr getBreedOffspring(shared_ptr target) override; + + virtual void readAdditionalSaveData(CompoundTag *tag) override; + virtual void addAdditonalSaveData(CompoundTag *tag) override; +}; \ No newline at end of file diff --git a/Minecraft.World/net.minecraft.world.entity.animal.h b/Minecraft.World/net.minecraft.world.entity.animal.h index 2bcb81f1..fc2c4de4 100644 --- a/Minecraft.World/net.minecraft.world.entity.animal.h +++ b/Minecraft.World/net.minecraft.world.entity.animal.h @@ -9,6 +9,7 @@ #include "WaterAnimal.h" #include "Wolf.h" + // 1.0.1 #include "Golem.h" #include "MushroomCow.h" @@ -19,4 +20,7 @@ #include "VillagerGolem.h" // 1.6.4 -#include "EntityHorse.h" \ No newline at end of file +#include "EntityHorse.h" + +//TU31 +#include "Rabbit.h" \ No newline at end of file