Added Double Tall Plants

TODO:
Add Sunflower
Add natural spawning of these flowers
This commit is contained in:
Tranqlmao 2026-03-20 01:53:28 -04:00
parent 547106b080
commit 07fd3222b8
11 changed files with 428 additions and 6 deletions

View file

@ -12,6 +12,7 @@
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.animal.h"
#include "..\..\..\Minecraft.World\JavaMath.h"
#include "..\..\..\Minecraft.World\TallGrass2.h"
// 4J JEV - Images for each tab.
IUIScene_CreativeMenu::TabSpec **IUIScene_CreativeMenu::specs = nullptr;
@ -231,7 +232,12 @@ void IUIScene_CreativeMenu::staticCtor()
ITEM_AUX(Tile::rose_Id, Rose::WHITE_TULIP)
ITEM_AUX(Tile::rose_Id, Rose::PINK_TULIP)
ITEM_AUX(Tile::rose_Id, Rose::OXEYE_DAISY)
// SUNFLOWER LOCATION
ITEM_AUX(Tile::tallgrass2_Id, TallGrass2::LILAC)
ITEM_AUX(Tile::tallgrass2_Id, TallGrass2::TALL_GRASS)
ITEM_AUX(Tile::tallgrass2_Id, TallGrass2::LARGE_FERN)
ITEM_AUX(Tile::tallgrass2_Id, TallGrass2::ROSE_BUSH)
ITEM_AUX(Tile::tallgrass2_Id, TallGrass2::PEONY)
ITEM(Tile::mushroom_brown_Id)
ITEM(Tile::mushroom_red_Id)
ITEM(Tile::cactus_Id)

View file

@ -1058,5 +1058,16 @@ void PreStitchedTextureMap::loadUVs()
ADD_ICON(24, 3, L"door_jungle_lower");
ADD_ICON(24, 4, L"door_spruce_lower");
ADD_ICON(21, 1, L"tallgrass2_tall_grass_lower");
ADD_ICON(20, 1, L"tallgrass2_tall_grass_upper");
ADD_ICON(21, 0, L"tallgrass2_large_fern_lower");
ADD_ICON(20, 0, L"tallgrass2_large_fern_upper");
ADD_ICON(21, 2, L"tallgrass2_peony_lower");
ADD_ICON(20, 2, L"tallgrass2_peony_upper");
ADD_ICON(21, 3, L"tallgrass2_rose_bush_lower");
ADD_ICON(20, 3, L"tallgrass2_rose_bush_upper");
ADD_ICON(21, 4, L"tallgrass2_lilac_lower");
ADD_ICON(20, 4, L"tallgrass2_lilac_upper");
}
}

View file

@ -2350,5 +2350,10 @@
#define IDS_ITEM_PRISMARINE_DARK_DESC 2344
#define IDS_ITEM_PRISMARINE_BRICK_DESC 2345
#define IDS_ITEM_PRISMARINE_CRYSTAL_DESC 2346
#define IDS_ITEM_PRISMARINE_SHARD_DESC 2346
#define IDS_ITEM_RABBIT_STEW 2347
#define IDS_ITEM_PRISMARINE_SHARD_DESC 2347
#define IDS_ITEM_RABBIT_STEW 2348
#define IDS_TILE_TALL_GRASS2 2349
#define IDS_TILE_LARGE_FERN 2350
#define IDS_TILE_LILAC 2351
#define IDS_TILE_ROSE_BUSH 2352
#define IDS_TILE_PEONY 2353

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "net.minecraft.world.level.tile.h"
#include "ColoredTileItem.h"
#include "Facing.h"
ColoredTileItem::ColoredTileItem(int id, bool stackedByData) : TileItem(id)
{
@ -57,4 +58,14 @@ unsigned int ColoredTileItem::getDescriptionId(shared_ptr<ItemInstance> instance
return descriptionPostfixes[id]; //TileItem::getDescriptionId(instance) + "." + descriptionPostfixes[id];
}
return TileItem::getDescriptionId(instance);
}
}
class TallGrass2TileItem : public ColoredTileItem
{
public:
TallGrass2TileItem(int id) : ColoredTileItem(id, true) {}
virtual Icon* getIcon(int auxValue) override
{
return Tile::tiles[getTileId()]->getTexture(Facing::UP, auxValue);
}
};

View file

@ -2833,6 +2833,7 @@
<ClInclude Include="SwampRiversLayer.h" />
<ClInclude Include="SwellGoal.h" />
<ClInclude Include="TakeFlowerGoal.h" />
<ClInclude Include="Tallgrass2.h" />
<ClInclude Include="TamableAnimal.h" />
<ClInclude Include="TargetGoal.h" />
<ClInclude Include="Team.h" />
@ -3675,6 +3676,7 @@
<ClCompile Include="StoneButtonTile.cpp" />
<ClCompile Include="StructureFeatureIO.cpp" />
<ClCompile Include="StructureFeatureSavedData.cpp" />
<ClCompile Include="Tallgrass2.cpp" />
<ClCompile Include="Team.cpp" />
<ClCompile Include="TreeTile2.cpp" />
<ClCompile Include="WeightedPressurePlateTile.cpp" />

View file

@ -827,6 +827,7 @@
<ClCompile Include="RoofedForestBiome.cpp" />
<ClCompile Include="PrismarineTile.cpp" />
<ClCompile Include="FishFoodItem.cpp" />
<ClCompile Include="Tallgrass2.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AABB.h" />
@ -1823,6 +1824,7 @@
<ClInclude Include="RoofedForestBiome.h" />
<ClInclude Include="PrismarineTile.h" />
<ClInclude Include="FishFoodItem.h" />
<ClInclude Include="Tallgrass2.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\Minecraft.Client\Xbox\res\audio\Minecraft.xgs" />

View file

@ -0,0 +1,292 @@
#include "stdafx.h"
#include "TallGrass2.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.biome.h"
#include "net.minecraft.world.item.h"
#include "net.minecraft.world.h"
#include "net.minecraft.h"
#include "..\Minecraft.Client\Minecraft.h"
#include "net.minecraft.stats.h"
static const unsigned int DESCRIPTION_IDS[TallGrass2::VARIANT_COUNT] = {
IDS_TILE_TALL_GRASS2, // 0 - Tall Grass
IDS_TILE_LARGE_FERN, // 1 - Large Fern
IDS_TILE_LILAC, // 2 - Lilac
IDS_TILE_ROSE_BUSH, // 3 - Rose Bush
IDS_TILE_PEONY, // 4 - Peony
};
static const wstring TEXTURE_BOTTOM[TallGrass2::VARIANT_COUNT] = {
L"tallgrass2_tall_grass_lower",
L"tallgrass2_large_fern_lower",
L"tallgrass2_lilac_lower",
L"tallgrass2_rose_bush_lower",
L"tallgrass2_peony_lower",
};
static const wstring TEXTURE_TOP[TallGrass2::VARIANT_COUNT] = {
L"tallgrass2_tall_grass_upper",
L"tallgrass2_large_fern_upper",
L"tallgrass2_lilac_upper",
L"tallgrass2_rose_bush_upper",
L"tallgrass2_peony_upper",
};
TallGrass2::TallGrass2(int id)
: Bush(id, Material::replaceable_plant)
{
this->updateDefaultShape();
}
void TallGrass2::updateDefaultShape()
{
float ss = 0.4f;
this->setShape(0.5f - ss, 0.0f, 0.5f - ss, 0.5f + ss, 1.0f, 0.5f + ss);
}
bool TallGrass2::blocksLight() { return false; }
bool TallGrass2::isSolidRender(bool) { return false; }
bool TallGrass2::isCubeShaped() { return false; }
int TallGrass2::getRenderShape() { return Tile::SHAPE_CROSS_TEXTURE; }
bool TallGrass2::isGrassColored(int variant)
{
return variant == TALL_GRASS || variant == LARGE_FERN;
}
void TallGrass2::registerIcons(IconRegister* iconRegister)
{
for (int i = 0; i < VARIANT_COUNT; i++)
{
iconBottom[i] = iconRegister->registerIcon(TEXTURE_BOTTOM[i]);
iconTop[i] = iconRegister->registerIcon(TEXTURE_TOP[i]);
}
icon = iconTop[TALL_GRASS];
}
Icon* TallGrass2::getTexture(int face, int data)
{
bool isUpper = (data & UPPER_BIT) != 0;
int variant = data & ~UPPER_BIT;
if (variant < 0 || variant >= VARIANT_COUNT) variant = 0;
if (face == Facing::UP && !isUpper) return iconTop[variant];
return isUpper ? iconTop[variant] : iconBottom[variant];
}
Icon* TallGrass2::getTexture(LevelSource* level, int x, int y, int z, int face)
{
int data = level->getData(x, y, z);
bool isUpper = (data & UPPER_BIT) != 0;
int variant = data & ~UPPER_BIT;
if (variant < 0 || variant >= VARIANT_COUNT) variant = 0;
return isUpper ? iconTop[variant] : iconBottom[variant];
}
int TallGrass2::getVariant(LevelSource* level, int x, int y, int z)
{
int data = level->getData(x, y, z);
bool isUpper = (data & UPPER_BIT) != 0;
int lowerData = isUpper ? level->getData(x, y - 1, z) : data;
int variant = lowerData & ~UPPER_BIT;
if (variant < 0 || variant >= VARIANT_COUNT) variant = 0;
return variant;
}
int TallGrass2::getColor(int auxData)
{
int variant = auxData & ~UPPER_BIT;
if (variant < 0 || variant >= VARIANT_COUNT) variant = 0;
if (!isGrassColored(variant)) return 0xFFFFFF;
return Minecraft::GetInstance()->getColourTable()->getColor(eMinecraftColour_Grass_Common);
}
int TallGrass2::getColor() const
{
return Minecraft::GetInstance()->getColourTable()->getColor(eMinecraftColour_Grass_Common);
}
int TallGrass2::getColor(LevelSource* level, int x, int y, int z)
{
return getColor(level, x, y, z, level->getData(x, y, z));
}
int TallGrass2::getColor(LevelSource* level, int x, int y, int z, int data)
{
int variant = data & ~UPPER_BIT;
if (variant < 0 || variant >= VARIANT_COUNT) variant = 0;
if (!isGrassColored(variant)) return 0xFFFFFF;
return level->getBiome(x, z)->getGrassColor();
}
bool TallGrass2::mayPlace(Level* level, int x, int y, int z)
{
if (y >= Level::maxBuildHeight - 1) return false;
return Bush::mayPlaceOn(level->getTile(x, y - 1, z))
&& level->getTile(x, y, z) == 0
&& level->getTile(x, y + 1, z) == 0;
}
void TallGrass2::finalizePlacement(Level* level, int x, int y, int z, int data)
{
if ((data & UPPER_BIT) != 0) return;
int variant = data & ~UPPER_BIT;
level->setTileAndData(x, y + 1, z, id, variant | UPPER_BIT, Tile::UPDATE_ALL);
level->setTilesDirty(x - 1, y - 1, z - 1, x + 1, y + 2, z + 1);
}
void TallGrass2::onPlace(Level* level, int x, int y, int z)
{
int data = level->getData(x, y, z);
if ((data & UPPER_BIT) != 0) return;
int variant = data & ~UPPER_BIT;
level->setTileAndData(x, y + 1, z, id, variant | UPPER_BIT, Tile::UPDATE_ALL);
level->setTilesDirty(x - 1, y - 1, z - 1, x + 1, y + 2, z + 1);
}
bool TallGrass2::canSurvive(Level* level, int x, int y, int z)
{
int data = level->getData(x, y, z);
bool isUpper = (data & UPPER_BIT) != 0;
if (isUpper)
return level->getTile(x, y - 1, z) == id;
return (level->getDaytimeRawBrightness(x, y, z) >= 8 || level->canSeeSky(x, y, z))
&& mayPlaceOn(level->getTile(x, y - 1, z));
}
void TallGrass2::neighborChanged(Level* level, int x, int y, int z, int type)
{
int data = level->getData(x, y, z);
bool isUpper = (data & UPPER_BIT) != 0;
if (!isUpper)
{
if (!canSurvive(level, x, y, z))
{
spawnResources(level, x, y, z, data, 0);
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS);
if (level->getTile(x, y + 1, z) == id)
level->removeTile(x, y + 1, z);
}
}
else
{
if (level->getTile(x, y - 1, z) != id)
level->removeTile(x, y, z);
}
}
void TallGrass2::tick(Level* level, int x, int y, int z, Random* random)
{
int data = level->getData(x, y, z);
bool isUpper = (data & UPPER_BIT) != 0;
if (!isUpper)
{
if (!canSurvive(level, x, y, z))
{
spawnResources(level, x, y, z, data, 0);
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS);
if (level->getTile(x, y + 1, z) == id)
level->removeTile(x, y + 1, z);
}
}
}
int TallGrass2::getResource(int data, Random* random, int playerBonusLevel)
{
return -1;
}
int TallGrass2::getResourceCountForLootBonus(int bonusLevel, Random* random)
{
return 1;
}
bool TallGrass2::isSilkTouchable()
{
return true;
}
shared_ptr<ItemInstance> TallGrass2::getSilkTouchItemInstance(int data)
{
if ((data & UPPER_BIT) != 0) return nullptr;
int variant = data & ~UPPER_BIT;
return std::make_shared<ItemInstance>(this, 1, variant);
}
void TallGrass2::playerDestroy(Level* level, shared_ptr<Player> player, int x, int y, int z, int data)
{
if (!level->isClientSide
&& player->getSelectedItem() != nullptr
&& player->getSelectedItem()->id == Item::shears->id)
{
player->awardStat(
GenericStats::blocksMined(id),
GenericStats::param_blocksMined(id, data, 1));
if ((data & UPPER_BIT) == 0)
{
int variant = data & ~UPPER_BIT;
popResource(level, x, y, z, std::make_shared<ItemInstance>(this, 1, variant));
}
}
else
{
Tile::playerDestroy(level, player, x, y, z, data);
}
}
void TallGrass2::playerWillDestroy(Level* level, int x, int y, int z, int data, shared_ptr<Player> player)
{
if (player->abilities.instabuild)
{
if ((data & UPPER_BIT) != 0)
{
if (level->getTile(x, y - 1, z) == id)
level->removeTile(x, y - 1, z);
}
else
{
if (level->getTile(x, y + 1, z) == id)
level->removeTile(x, y + 1, z);
}
}
}
int TallGrass2::cloneTileData(Level* level, int x, int y, int z)
{
return getVariant(level, x, y, z);
}
unsigned int TallGrass2::getDescriptionId(int iData)
{
if (iData < 0) iData = 0;
if (iData >= VARIANT_COUNT) iData = 0;
return DESCRIPTION_IDS[iData];
}
int TallGrass2::getPistonPushReaction()
{
return Material::PUSH_DESTROY;
}

View file

@ -0,0 +1,62 @@
#pragma once
#include "Bush.h"
class TallGrass2 : public Bush
{
friend class Tile;
public:
static const int TALL_GRASS = 0;
static const int LARGE_FERN = 1;
static const int LILAC = 2;
static const int ROSE_BUSH = 3;
static const int PEONY = 4;
static const int VARIANT_COUNT = 5;
static const int UPPER_BIT = 8;
private:
Icon* iconBottom[VARIANT_COUNT];
Icon* iconTop[VARIANT_COUNT];
protected:
TallGrass2(int id);
public:
virtual void updateDefaultShape() override;
virtual Icon* getTexture(int face, int data) override;
virtual Icon* getTexture(LevelSource* level, int x, int y, int z, int face) override;
virtual void registerIcons(IconRegister* iconRegister) override;
virtual int getRenderShape() override;
virtual bool blocksLight() override;
virtual bool isSolidRender(bool isServerLevel = false) override;
virtual bool isCubeShaped() override;
virtual int getColor(int auxData) override;
virtual int getColor() const override;
virtual int getColor(LevelSource* level, int x, int y, int z) override;
virtual int getColor(LevelSource* level, int x, int y, int z, int data) override;
virtual void finalizePlacement(Level* level, int x, int y, int z, int data) override;
virtual void onPlace(Level* level, int x, int y, int z) override;
virtual bool mayPlace(Level* level, int x, int y, int z) override;
virtual void neighborChanged(Level* level, int x, int y, int z, int type) override;
virtual bool canSurvive(Level* level, int x, int y, int z) override;
virtual void tick(Level* level, int x, int y, int z, Random* random) override;
virtual int getResource(int data, Random* random, int playerBonusLevel) override;
virtual int getResourceCountForLootBonus(int bonusLevel, Random* random) override;
virtual void playerDestroy(Level* level, shared_ptr<Player> player, int x, int y, int z, int data) override;
virtual void playerWillDestroy(Level* level, int x, int y, int z, int data, shared_ptr<Player> player) override;
virtual int cloneTileData(Level* level, int x, int y, int z) override;
virtual unsigned int getDescriptionId(int iData = -1) override;
virtual int getPistonPushReaction() override;
protected:
virtual bool isSilkTouchable() override;
virtual shared_ptr<ItemInstance> getSilkTouchItemInstance(int data) override;
private:
int getVariant(LevelSource* level, int x, int y, int z);
bool isGrassColored(int variant);
};

View file

@ -16,6 +16,10 @@
#include "net.minecraft.world.h"
#include "net.minecraft.h"
#include "Tile.h"
#include "Tallgrass2.h"
#include "facing.h"
@ -257,6 +261,8 @@ Tile* Tile::prismarine = nullptr;
Tile* Tile::tree2Trunk = nullptr;
Tile* Tile::packed_ice = nullptr;
TallGrass2* Tile::tallgrass2 = nullptr;
DWORD Tile::tlsIdxShape = TlsAlloc();
Tile::ThreadStorage::ThreadStorage()
@ -276,6 +282,24 @@ void Tile::ReleaseThreadStorage()
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
delete tls;
}
class TallGrass2TileItem : public ColoredTileItem
{
public:
TallGrass2TileItem(int id) : ColoredTileItem(id, true) {}
virtual Icon* getIcon(int auxValue) override
{
return Tile::tiles[getTileId()]->getTexture(Facing::UP, auxValue);
}
virtual int getColor(shared_ptr<ItemInstance> item, int spriteLayer) override
{
int variant = item->getAuxValue();
if (variant == TallGrass2::TALL_GRASS || variant == TallGrass2::LARGE_FERN)
return Tile::tiles[getTileId()]->getColor(variant);
return 0xFFFFFF;
}
};
void Tile::staticCtor()
{
@ -510,6 +534,7 @@ void Tile::staticCtor()
Tile::seaLantern = (new SeaLanternTile(169, Material::glass))->setBaseItemTypeAndMaterial(Item::eBaseItemType_torch, Item::eMaterial_glowstone)->setDestroyTime(0.3f)->setSoundType(Tile::SOUND_GLASS)->setLightEmission(1.0f)->setIconName(L"glowstone")->setDescriptionId(IDS_TILE_SEA_LANTERN)->setUseDescriptionId(IDS_DESC_GLOWSTONE);
Tile::prismarine = (new PrismarineTile(168))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(1.5f)->setExplodeable(10)->setSoundType(SOUND_STONE)->setIconName(L"prismarine")->setDescriptionId(IDS_TILE_PRISMARINE)->setUseDescriptionId(IDS_ITEM_PRISMARINE_DESC);
Tile::tallgrass2 = static_cast<TallGrass2*>((new TallGrass2(175))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tallgrass2_tall_grass_upper")->setDescriptionId(IDS_TILE_TALL_GRASS2)->setUseDescriptionId(IDS_DESC_TALL_GRASS)->disableMipmap()->sendTileData(0xFF));
// Special cases for certain items since they can have different icons
Item::items[wool_Id] = ( new WoolTileItem(Tile::wool_Id- 256) )->setIconName(L"cloth")->setDescriptionId(IDS_TILE_CLOTH)->setUseDescriptionId(IDS_DESC_WOOL);
@ -548,7 +573,9 @@ void Tile::staticCtor()
Item::items[red_sandstone_Id] = (new MultiTextureTileItem(Tile::red_sandstone_Id - 256, red_sandstone, (int*)RedSandStoneTile::SANDSTONE_NAMES, RedSandStoneTile::SANDSTONE_BLOCK_NAMES))->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_SANDSTONE)->setUseDescriptionId(IDS_DESC_SANDSTONE);
Item::items[tree2Trunk_Id] = (new MultiTextureTileItem(Tile::tree2Trunk_Id - 256, tree2Trunk, (int*)TreeTile2::TREE_NAMES, TreeTile2::TREE_NAMES_LENGTH))->setIconName(L"log")->setDescriptionId(IDS_TILE_LOG)->setUseDescriptionId(IDS_DESC_LOG);
Item::items[sponge_Id] = (new MultiTextureTileItem(Tile::sponge_Id - 256, sponge, (int*)Sponge::SPONGE_NAMES, Sponge::SPONGE_NAMES_LENGTH))->setIconName(L"sponge")->setDescriptionId(IDS_TILE_SPONGE)->setUseDescriptionId(IDS_DESC_SPONGE);
int tallgrass2IdsData[5] = { IDS_TILE_TALL_GRASS2, IDS_TILE_LARGE_FERN, IDS_TILE_LILAC, IDS_TILE_ROSE_BUSH, IDS_TILE_PEONY };
intArray tallgrass2Ids = intArray(tallgrass2IdsData, 5);
Item::items[tallgrass2_Id] = static_cast<TallGrass2TileItem*>((new TallGrass2TileItem(Tile::tallgrass2_Id - 256))->setDescriptionId(IDS_TILE_TALL_GRASS2)->setUseDescriptionId(IDS_DESC_TALL_GRASS))->setDescriptionPostfixes(tallgrass2Ids);
for (int i = 0; i < 256; i++)
{
@ -1632,6 +1659,7 @@ int Tile::SoundType::getPlaceSound() const
}
/*
4J: These are necessary on the PS3.
(and 4 and Vita).

View file

@ -42,6 +42,7 @@ class TileEntity;
class HalfSlabTile;
class Icon;
class IconRegister;
class TallGrass2;
class ChunkRebuildData;
@ -380,7 +381,7 @@ public:
static const int clayHardened_Id = 172;
static const int coalBlock_Id = 173;
static const int packed_ice_Id = 174;
//175 double_plant
static const int tallgrass2_Id = 175;
//176 standing_banner
//177 wall_banner
static const int invertedDaylightDetector_Id = 178;
@ -613,6 +614,8 @@ public:
static Tile* packed_ice;
static Tile* seaLantern;
static Tile* prismarine;
static TallGrass2* tallgrass2;
static void staticCtor();