TU43 Release 1

+ Mending & FrostWalker (Needs some tlc)
+ Path Blocks
+ All Beetroot Items
- Some SWF & Texture atlasChanges
This commit is contained in:
Tranqlmao
2026-07-06 23:28:11 -04:00
parent b5707e8898
commit 37cd621561
41 changed files with 770 additions and 25 deletions
+88
View File
@@ -0,0 +1,88 @@
#include "stdafx.h"
#include "net.minecraft.world.h"
#include "net.minecraft.world.item.h"
#include "net.minecraft.world.level.h"
#include "BeetrootTile.h"
BeetrootTile::BeetrootTile(int id) : CropTile(id)
{
}
Icon *BeetrootTile::getTexture(int face, int data)
{
if (data < 0 || data > 3) data = 3;
return icons[data];
}
int BeetrootTile::getBaseSeedId()
{
return Item::beetroot_seeds_Id;
}
int BeetrootTile::getBasePlantId()
{
return Item::beetroot_Id;
}
void BeetrootTile::tick(Level *level, int x, int y, int z, Random *random)
{
Bush::tick(level, x, y, z, random);
if (level->getRawBrightness(x, y + 1, z) >= Level::MAX_BRIGHTNESS - 6)
{
int age = level->getData(x, y, z);
if (age < 3)
{
if (random->nextInt(3) != 0)
{
float growthSpeed = 1.0f;
if (random->nextInt(static_cast<int>(25 / growthSpeed) + 1) == 0)
{
age++;
level->setData(x, y, z, age, Tile::UPDATE_CLIENTS);
}
}
}
}
}
void BeetrootTile::growCrops(Level *level, int x, int y, int z)
{
int stage = level->getData(x, y, z) + 1;
if (stage > 3) stage = 3;
level->setData(x, y, z, stage, Tile::UPDATE_CLIENTS);
}
int BeetrootTile::getResource(int data, Random *random, int playerBonusLevel)
{
if (data == 3)
{
return getBasePlantId();
}
return getBaseSeedId();
}
void BeetrootTile::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonus)
{
Bush::spawnResources(level, x, y, z, data, odds, 0);
if (level->isClientSide)
{
return;
}
if (data >= 3)
{
int seedCount = 1 + level->random->nextInt(4);
for (int i = 0; i < seedCount; i++)
{
popResource(level, x, y, z, std::make_shared<ItemInstance>(getBaseSeedId(), 1, 0));
}
}
}
void BeetrootTile::registerIcons(IconRegister *iconRegister)
{
for (int i = 0; i < 4; i++)
{
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" + std::to_wstring(i));
}
}
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include "CropTile.h"
class BeetrootTile : public CropTile
{
friend class ChunkRebuildData;
private:
Icon *icons[4];
public:
BeetrootTile(int id);
Icon *getTexture(int face, int data);
protected:
int getBaseSeedId();
int getBasePlantId();
public:
void tick(Level *level, int x, int y, int z, Random *random);
void growCrops(Level *level, int x, int y, int z);
int getResource(int data, Random *random, int playerBonusLevel);
void spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonus);
void registerIcons(IconRegister *iconRegister);
};
+16 -3
View File
@@ -234,12 +234,25 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
}
return true;
}
else if (tile == Tile::wheat_Id)
else if (tile == Tile::wheat_Id)
{
if (level->getData(x, y, z) == 7) return false;
if(!bTestUseOnOnly)
{
if (!level->isClientSide)
{
if (!level->isClientSide)
{
static_cast<CropTile *>(Tile::tiles[tile])->growCrops(level, x, y, z);
itemInstance->count--;
}
}
return true;
}
else if (tile == Tile::beetroots_Id)
{
if (level->getData(x, y, z) == 3) return false;
if (!bTestUseOnOnly)
{
if (!level->isClientSide)
{
static_cast<CropTile *>(Tile::tiles[tile])->growCrops(level, x, y, z);
itemInstance->count--;
+11 -1
View File
@@ -4,6 +4,8 @@
#include "Enchantment.h"
#include "WaterWalkerEnchantment.h"
#include "FrostWalkerEnchantment.h"
#include "MendingEnchantment.h"
#include "LuckOfTheSeaEnchantment.h"
#include "LureEnchantment.h"
@@ -19,6 +21,7 @@ Enchantment *Enchantment::projectileProtection = nullptr;
Enchantment *Enchantment::drownProtection = nullptr;
Enchantment *Enchantment::waterWorker = nullptr;
Enchantment *Enchantment::waterWalker = nullptr;
Enchantment *Enchantment::frostWalker = nullptr;
Enchantment *Enchantment::thorns = nullptr;
// weapon
@@ -45,6 +48,9 @@ Enchantment *Enchantment::arrowInfinite = nullptr;
Enchantment *Enchantment::lure = nullptr;
Enchantment *Enchantment::luckOfTheSea = nullptr;
// misc / treasure
Enchantment *Enchantment::mending = nullptr;
void Enchantment::staticCtor()
{
allDamageProtection = new ProtectionEnchantment(0, FREQ_COMMON, ProtectionEnchantment::ALL);
@@ -55,6 +61,7 @@ void Enchantment::staticCtor()
drownProtection = new OxygenEnchantment(5, FREQ_RARE);
waterWorker = new WaterWorkerEnchantment(6, FREQ_RARE);
waterWalker = new WaterWalkerEnchantment(8, FREQ_RARE);
frostWalker = new FrostWalkerEnchantment(9, FREQ_RARE);
thorns = new ThornsEnchantment(7, FREQ_VERY_RARE);
// weapon
@@ -81,10 +88,13 @@ void Enchantment::staticCtor()
lure = new LureEnchantment(64, FREQ_RARE);
luckOfTheSea = new LuckOfTheSeaEnchantment(65, FREQ_RARE);
// misc / treasure
mending = new MendingEnchantment(70, FREQ_RARE);
for(unsigned int i = 0; i < 256; ++i)
{
Enchantment *enchantment = enchantments[i];
if (enchantment != nullptr)
if (enchantment != nullptr && !enchantment->isTreasureEnchantment())
{
validEnchantments.push_back(enchantment);
}
+5
View File
@@ -26,6 +26,7 @@ public :
static Enchantment *drownProtection;
static Enchantment *waterWorker;
static Enchantment *waterWalker;
static Enchantment *frostWalker;
static Enchantment *thorns;
// weapon
@@ -52,6 +53,9 @@ public :
static Enchantment *lure;
static Enchantment *luckOfTheSea;
// misc / treasure
static Enchantment *mending;
const int id;
static void staticCtor();
@@ -81,6 +85,7 @@ public:
virtual int getDamageProtection(int level, DamageSource *source);
virtual float getDamageBonus(int level, shared_ptr<LivingEntity> target);
virtual bool isCompatibleWith(Enchantment *other) const;
virtual bool isTreasureEnchantment() const { return false; }
virtual Enchantment *setDescriptionId(int id);
virtual int getDescriptionId();
virtual HtmlString getFullname(int level);
+30
View File
@@ -239,11 +239,41 @@ int EnchantmentHelper::getWaterWalker(shared_ptr<LivingEntity> source)
return getEnchantmentLevel(Enchantment::waterWalker->id, source->getEquipmentSlots() );
}
int EnchantmentHelper::getFrostWalker(shared_ptr<LivingEntity> source)
{
return getEnchantmentLevel(Enchantment::frostWalker->id, source->getEquipmentSlots());
}
int EnchantmentHelper::getArmorThorns(shared_ptr<LivingEntity> source)
{
return getEnchantmentLevel(Enchantment::thorns->id, source->getEquipmentSlots());
}
shared_ptr<ItemInstance> EnchantmentHelper::getMendingItem(shared_ptr<LivingEntity> source)
{
int mendId = Enchantment::mending->id;
vector<shared_ptr<ItemInstance>> candidates;
shared_ptr<ItemInstance> held = source->getCarriedItem();
if (held != nullptr && held->isDamaged() && getEnchantmentLevel(mendId, held) > 0)
{
candidates.push_back(held);
}
ItemInstanceArray armor = source->getEquipmentSlots();
for (unsigned int i = 0; i < armor.length; ++i)
{
shared_ptr<ItemInstance> piece = armor[i];
if (piece != nullptr && piece->isDamaged() && getEnchantmentLevel(mendId, piece) > 0)
{
candidates.push_back(piece);
}
}
if (candidates.empty()) return nullptr;
return candidates[random.nextInt((int)candidates.size())];
}
shared_ptr<ItemInstance> EnchantmentHelper::getRandomItemWith(Enchantment *enchantment, shared_ptr<LivingEntity> source)
{
ItemInstanceArray items = source->getEquipmentSlots();
+2
View File
@@ -81,7 +81,9 @@ public:
static int getKillingLootBonus(shared_ptr<LivingEntity> source);
static bool hasWaterWorkerBonus(shared_ptr<LivingEntity> source);
static int getWaterWalker(shared_ptr<LivingEntity> source);
static int getFrostWalker(shared_ptr<LivingEntity> source);
static int getArmorThorns(shared_ptr<LivingEntity> source);
static shared_ptr<ItemInstance> getMendingItem(shared_ptr<LivingEntity> source);
static shared_ptr<ItemInstance> getRandomItemWith(Enchantment *enchantment, shared_ptr<LivingEntity> source);
/**
+16 -1
View File
@@ -4,6 +4,7 @@
#include "net.minecraft.world.phys.h"
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.world.damagesource.h"
#include "net.minecraft.world.item.enchantment.h"
#include "com.mojang.nbt.h"
#include "JavaMath.h"
#include "SharedConstants.h"
@@ -198,7 +199,21 @@ void ExperienceOrb::playerTouch(shared_ptr<Player> player)
// 4J - sound change brought forward from 1.2.3
playSound(eSoundType_RANDOM_ORB, 0.1f, 0.5f * ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.8f));
player->take(shared_from_this(), 1);
player->increaseXp(value);
shared_ptr<ItemInstance> mendItem = EnchantmentHelper::getMendingItem(dynamic_pointer_cast<LivingEntity>(player));
if (mendItem != nullptr)
{
int repair = value * 2;
int damage = mendItem->getDamageValue();
if (repair > damage) repair = damage;
mendItem->setAuxValue(mendItem->getAuxValue() - repair);
value -= repair / 2;
}
if (value > 0)
{
player->increaseXp(value);
}
remove();
}
}
@@ -0,0 +1,63 @@
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.world.entity.h"
#include "Material.h"
#include "Mth.h"
#include "FrostWalkerEnchantment.h"
FrostWalkerEnchantment::FrostWalkerEnchantment(int id, int frequency) : Enchantment(id, frequency, EnchantmentCategory::armor_feet)
{
setDescriptionId(IDS_ENCHANTMENT_FROST_WALKER);
}
int FrostWalkerEnchantment::getMinCost(int level)
{
return level * 10;
}
int FrostWalkerEnchantment::getMaxCost(int level)
{
return getMinCost(level) + 15;
}
int FrostWalkerEnchantment::getMaxLevel()
{
return 2;
}
void FrostWalkerEnchantment::freezeNearby(shared_ptr<LivingEntity> living, Level *level, int px, int py, int pz, int enchLevel)
{
if (!living->onGround) return;
int radius = 2 + enchLevel;
if (radius > 16) radius = 16;
float f = (float)radius;
int r = radius;
for (int dx = -r; dx <= r; dx++)
{
for (int dz = -r; dz <= r; dz++)
{
int bx = px + dx;
int by = py - 1;
int bz = pz + dz;
double ddx = (bx + 0.5) - living->x;
double ddy = (by + 0.5) - living->y;
double ddz = (bz + 0.5) - living->z;
if (ddx * ddx + ddy * ddy + ddz * ddz > (double)(f * f)) continue;
if (level->getTile(bx, by + 1, bz) != 0) continue;
Material *ground = level->getMaterial(bx, by, bz);
if (ground != Material::water) continue;
if (level->getData(bx, by, bz) != 0) continue;
if (Tile::frosted_ice->mayPlace(level, bx, by, bz))
{
level->setTileAndData(bx, by, bz, Tile::frosted_ice_Id, 0, Tile::UPDATE_ALL);
}
}
}
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include "Enchantment.h"
class Level;
class LivingEntity;
class FrostWalkerEnchantment : public Enchantment
{
public:
FrostWalkerEnchantment(int id, int freq);
virtual int getMinCost(int level) override;
virtual int getMaxCost(int level) override;
virtual int getMaxLevel() override;
virtual bool isTreasureEnchantment() const override { return true; }
static void freezeNearby(shared_ptr<LivingEntity> living, Level *level, int px, int py, int pz, int enchLevel);
};
+147
View File
@@ -0,0 +1,147 @@
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.dimension.h"
#include "net.minecraft.world.item.enchantment.h"
#include "net.minecraft.world.food.h"
#include "net.minecraft.stats.h"
#include "FrostedIceTile.h"
#include "Random.h"
#include "IconRegister.h"
const int FrostedIceTile::MAX_AGE;
FrostedIceTile::FrostedIceTile(int id) : IceTile(id)
{
// Inherits ice friction/sound from IceTile. Scheduled ticks drive the melt.
for (int i = 0; i < 4; i++) m_ageIcons[i] = nullptr;
}
void FrostedIceTile::registerIcons(IconRegister *iconRegister)
{
m_ageIcons[0] = iconRegister->registerIcon(L"frosted_ice_0");
m_ageIcons[1] = iconRegister->registerIcon(L"frosted_ice_1");
m_ageIcons[2] = iconRegister->registerIcon(L"frosted_ice_2");
m_ageIcons[3] = iconRegister->registerIcon(L"frosted_ice_3");
icon = m_ageIcons[0];
}
Icon *FrostedIceTile::getTexture(int face, int data)
{
int age = data;
if (age < 0) age = 0;
if (age > MAX_AGE) age = MAX_AGE;
return m_ageIcons[age];
}
int FrostedIceTile::randomTickDelay(Random *random)
{
return 20 + random->nextInt(21); // 20-40 ticks
}
void FrostedIceTile::onPlace(Level *level, int x, int y, int z)
{
// Schedule the first melt check 60-120 ticks after forming
level->addToTickNextTick(x, y, z, id, 60 + level->random->nextInt(61));
}
int FrostedIceTile::countIceNeighbours(Level *level, int x, int y, int z)
{
static const int off[6][3] = {
{ 0, -1, 0 }, { 0, 1, 0 }, { 0, 0, -1 }, { 0, 0, 1 }, { -1, 0, 0 }, { 1, 0, 0 }
};
int count = 0;
for (int i = 0; i < 6; i++)
{
if (level->getTile(x + off[i][0], y + off[i][1], z + off[i][2]) == id)
{
if (++count >= 4) return count;
}
}
return count;
}
void FrostedIceTile::meltToWater(Level *level, int x, int y, int z)
{
if (level->dimension->ultraWarm)
{
level->removeTile(x, y, z);
return;
}
level->setTileAndUpdate(x, y, z, Tile::water_Id);
level->updateNeighborsAt(x, y, z, Tile::water_Id);
}
bool FrostedIceTile::slightlyMelt(Level *level, int x, int y, int z, Random *random, bool spreadToNeighbours)
{
int age = level->getData(x, y, z);
if (age < MAX_AGE)
{
level->setData(x, y, z, age + 1, Tile::UPDATE_CLIENTS);
level->addToTickNextTick(x, y, z, id, randomTickDelay(random));
return false;
}
meltToWater(level, x, y, z);
if (spreadToNeighbours)
{
static const int off[6][3] = {
{ 0, -1, 0 }, { 0, 1, 0 }, { 0, 0, -1 }, { 0, 0, 1 }, { -1, 0, 0 }, { 1, 0, 0 }
};
for (int i = 0; i < 6; i++)
{
int nx = x + off[i][0], ny = y + off[i][1], nz = z + off[i][2];
if (level->getTile(nx, ny, nz) == id)
slightlyMelt(level, nx, ny, nz, random, false);
}
}
return true;
}
void FrostedIceTile::tick(Level *level, int x, int y, int z, Random *random)
{
if (level->isClientSide) return;
int age = level->getData(x, y, z);
int light = level->getRawBrightness(x, y, z);
if ((random->nextInt(3) == 0 || countIceNeighbours(level, x, y, z) < 4)
&& light > 11 - age - Tile::lightBlock[id])
{
slightlyMelt(level, x, y, z, random, true);
}
else
{
level->addToTickNextTick(x, y, z, id, randomTickDelay(random));
}
}
void FrostedIceTile::neighborChanged(Level *level, int x, int y, int z, int neighborId)
{
// If a neighbouring frosted ice melts away leaving us poorly supported, melt too
if (neighborId == id && countIceNeighbours(level, x, y, z) < 2)
{
meltToWater(level, x, y, z);
}
}
int FrostedIceTile::getResourceCount(Random *random)
{
return 0; // never drops anything, even with silk touch
}
void FrostedIceTile::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data)
{
// Frosted ice yields nothing and turns to water like normal ice
if (level->dimension->ultraWarm)
{
level->removeTile(x, y, z);
return;
}
Material *below = level->getMaterial(x, y - 1, z);
if (below->blocksMotion() || below->isLiquid())
{
level->setTileAndUpdate(x, y, z, Tile::water_Id);
}
}
+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include "IceTile.h"
class Random;
class Icon;
class IconRegister;
class FrostedIceTile : public IceTile
{
public:
static const int MAX_AGE = 3;
FrostedIceTile(int id);
virtual void registerIcons(IconRegister *iconRegister);
virtual Icon *getTexture(int face, int data);
virtual void onPlace(Level *level, int x, int y, int z);
virtual void tick(Level *level, int x, int y, int z, Random *random);
virtual void neighborChanged(Level *level, int x, int y, int z, int neighborId);
virtual int getResourceCount(Random *random);
virtual void playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data);
private:
Icon *m_ageIcons[4];
bool slightlyMelt(Level *level, int x, int y, int z, Random *random, bool spreadToNeighbours);
void meltToWater(Level *level, int x, int y, int z);
int countIceNeighbours(Level *level, int x, int y, int z);
int randomTickDelay(Random *random);
};
+60
View File
@@ -0,0 +1,60 @@
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "Material.h"
#include "IconRegister.h"
#include "Facing.h"
#include "GrassPathTile.h"
GrassPathTile::GrassPathTile(int id) : Tile(id, Material::dirt), iconTop(nullptr)
{
}
void GrassPathTile::updateDefaultShape()
{
setShape(0, 0, 0, 1, 15 / 16.0f, 1);
}
bool GrassPathTile::isSolidRender(bool isServerLevel)
{
return false;
}
bool GrassPathTile::isCubeShaped()
{
return false;
}
void GrassPathTile::registerIcons(IconRegister *iconRegister)
{
iconTop = iconRegister->registerIcon(L"grass_path_top");
icon = iconRegister->registerIcon(L"grass_path_side");
}
Icon *GrassPathTile::getTexture(int face, int data)
{
if (face == Facing::UP) return iconTop;
return icon;
}
void GrassPathTile::checkAndConvert(Level *level, int x, int y, int z)
{
if (level->getMaterial(x, y + 1, z)->blocksMotion())
{
level->setTileAndUpdate(x, y, z, Tile::dirt_Id);
}
}
void GrassPathTile::neighborChanged(Level *level, int x, int y, int z, int neighborId)
{
checkAndConvert(level, x, y, z);
}
int GrassPathTile::getResource(int data, Random *random, int playerBonusLevel)
{
return Tile::dirt_Id;
}
int GrassPathTile::getResourceCount(Random *random)
{
return 1;
}
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include "Tile.h"
class GrassPathTile : public Tile
{
Icon *iconTop;
public:
GrassPathTile(int id);
virtual void updateDefaultShape() override;
virtual bool isSolidRender(bool isServerLevel = false) override;
virtual bool isCubeShaped() override;
virtual void neighborChanged(Level *level, int x, int y, int z, int neighborId) override;
virtual void registerIcons(IconRegister *iconRegister) override;
virtual Icon *getTexture(int face, int data) override;
virtual int getResource(int data, Random *random, int playerBonusLevel) override;
virtual int getResourceCount(Random *random) override;
private:
void checkAndConvert(Level *level, int x, int y, int z);
};
+11
View File
@@ -274,6 +274,10 @@ Item* Item::prismarine_shard = nullptr;
Item* Item::elytra = nullptr;
Item* Item::beetroot = nullptr;
Item* Item::beetroot_seeds = nullptr;
Item* Item::beetroot_soup = nullptr;
void Item::staticCtor()
{
@@ -541,6 +545,10 @@ void Item::staticCtor()
Item::prismarine_crystal = (new Item(154))->setIconName(L"prismarineCrystal")->setDescriptionId(IDS_ITEM_PRISMARINE_CRYSTAL)->setUseDescriptionId(IDS_ITEM_PRISMARINE_CRYSTAL_DESC);
Item::prismarine_shard = (new Item(153))->setIconName(L"prismarineShard")->setDescriptionId(IDS_ITEM_PRISMARINE_SHARD)->setUseDescriptionId(IDS_ITEM_PRISMARINE_SHARD_DESC);
Item::elytra = (new ElytraItem())->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth)->setIconName(L"elytra")->setDescriptionId(IDS_ITEM_ELYTRA)->setUseDescriptionId(IDS_ITEM_ELYTRA);
Item::beetroot = (new FoodItem(178, 1, 0.6f, false))->setIconName(L"beetroot")->setDescriptionId(IDS_BEETROOT)->setUseDescriptionId(IDS_DESC_BEETROOT);
Item::beetroot_seeds = (new SeedItem(179, Tile::beetroots_Id, Tile::farmland_Id))->setIconName(L"beetroot_seeds")->setDescriptionId(IDS_BEETROOT_SEEDS)->setUseDescriptionId(IDS_DESC_BEETROOT_SEEDS);
Item::beetroot_soup = (new BowlFoodItem(180, 6))->setIconName(L"beetroot_soup")->setDescriptionId(IDS_ITEM_BEETROOT_SOUP)->setUseDescriptionId(IDS_DESC_BEETROOT_SOUP);
}
@@ -1195,5 +1203,8 @@ const int Item::carrot_on_a_stick_Id ;
const int Item::pumpkin_pie_Id ;
const int Item::enchanted_book_Id ;
const int Item::quartz_Id ;
const int Item::beetroot_Id ;
const int Item::beetroot_seeds_Id ;
const int Item::beetroot_soup_Id ;
#endif
+8
View File
@@ -439,6 +439,10 @@ public:
static Item* prismarine_shard;
static Item* elytra;
static Item* beetroot;
static Item* beetroot_seeds;
static Item* beetroot_soup;
static const int iron_shovel_Id = 256;
static const int iron_pickaxe_Id = 257;
@@ -671,6 +675,10 @@ public:
static const int elytra_Id = 443;
static const int beetroot_Id = 434;
static const int beetroot_seeds_Id = 435;
static const int beetroot_soup_Id = 436;
//TU31
+10
View File
@@ -288,6 +288,16 @@ void LivingEntity::baseTick()
animStepO = animStep;
if (!level->isClientSide && isAlive())
{
int frostWalkerLevel = EnchantmentHelper::getFrostWalker(dynamic_pointer_cast<LivingEntity>(shared_from_this()));
if (frostWalkerLevel > 0)
{
FrostWalkerEnchantment::freezeNearby(dynamic_pointer_cast<LivingEntity>(shared_from_this()), level,
Mth::floor(x), Mth::floor(y), Mth::floor(z), frostWalkerLevel);
}
}
yBodyRotO = yBodyRot;
yHeadRotO = yHeadRot;
yRotO = yRot;
+29
View File
@@ -0,0 +1,29 @@
#include "stdafx.h"
#include "net.minecraft.world.item.h"
#include "ItemInstance.h"
#include "MendingEnchantment.h"
MendingEnchantment::MendingEnchantment(int id, int frequency) : Enchantment(id, frequency, EnchantmentCategory::all)
{
setDescriptionId(IDS_ENCHANTMENT_MENDING);
}
int MendingEnchantment::getMinCost(int level)
{
return level * 25;
}
int MendingEnchantment::getMaxCost(int level)
{
return getMinCost(level) + 50;
}
int MendingEnchantment::getMaxLevel()
{
return 1;
}
bool MendingEnchantment::canEnchant(shared_ptr<ItemInstance> item)
{
return item->isDamageableItem();
}
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include "Enchantment.h"
class MendingEnchantment : public Enchantment
{
public:
MendingEnchantment(int id, int freq);
virtual int getMinCost(int level) override;
virtual int getMaxCost(int level) override;
virtual int getMaxLevel() override;
virtual bool isTreasureEnchantment() const override { return true; }
virtual bool canEnchant(shared_ptr<ItemInstance> item) override;
};
+27
View File
@@ -1,6 +1,9 @@
#include "stdafx.h"
#include "net.minecraft.world.entity.player.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.tile.h"
#include "ItemInstance.h"
#include "ShovelItem.h"
TileArray *ShovelItem::diggables = nullptr;
@@ -24,6 +27,30 @@ ShovelItem::ShovelItem(int id, const Tier *tier) : DiggerItem(id, 1, tier, digga
{
}
bool ShovelItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
{
if (!player->mayUseItemAt(x, y, z, face, instance)) return false;
int targetType = level->getTile(x, y, z);
int above = level->getTile(x, y + 1, z);
if (face != 0 && above == 0 && (targetType == Tile::grass_Id || targetType == Tile::dirt_Id))
{
if (!bTestUseOnOnly)
{
Tile *tile = Tile::grass_path;
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, tile->soundType->getStepSound(), (tile->soundType->getVolume() + 1) / 2, tile->soundType->getPitch() * 0.8f);
if (level->isClientSide) return true;
level->setTileAndUpdate(x, y, z, tile->id);
instance->hurtAndBreak(1, player);
}
return true;
}
return false;
}
bool ShovelItem::canDestroySpecial(Tile *tile)
{
if (tile == Tile::topSnow) return true;
+1
View File
@@ -11,5 +11,6 @@ public:
static void staticCtor();
ShovelItem(int id, const Tier *tier);
bool useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) override;
bool canDestroySpecial(Tile *tile);
};
+9 -1
View File
@@ -266,6 +266,9 @@ Tile* Tile::prismarine = nullptr;
Tile* Tile::log2 = nullptr;
Tile* Tile::packedIce = nullptr;
FrostedIceTile* Tile::frosted_ice = nullptr;
GrassPathTile* Tile::grass_path = nullptr;
BeetrootTile* Tile::beetroots = nullptr;
Tile* Tile::barrier = nullptr;
TallGrass2* Tile::double_plant = nullptr;
@@ -577,6 +580,9 @@ void Tile::staticCtor()
//
Tile::packedIce = (new PackedIceTile(174))->setDestroyTime(0.5f)->setSoundType(SOUND_GLASS)->setIconName(L"packed_ice")->setDescriptionId(IDS_TILE_PACKED_ICE)->setUseDescriptionId(IDS_DESC_PACKED_ICE);
Tile::beetroots = static_cast<BeetrootTile*>((new BeetrootTile(beetroots_Id))->setIconName(L"beetroots")->setDescriptionId(IDS_TILE_BEETROOTS)->setUseDescriptionId(IDS_DESC_BEETROOT_SEEDS)->disableMipmap());
Tile::grass_path = static_cast<GrassPathTile*>((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<FrostedIceTile*>((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::daylight_detector_inverted = static_cast<DaylightDetectorTile*>((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();
@@ -670,7 +676,7 @@ void Tile::staticCtor()
{
propagate = true;
}
if (i == Tile::farmland_Id) propagate = true;
if (i == Tile::farmland_Id || i == Tile::grass_path_Id) propagate = true;
if (Tile::transculent[i])
{
propagate = true;
@@ -1906,4 +1912,6 @@ const int Tile::carpet_Id;
const int Tile::acacia_stairs_Id;
const int Tile::dark_oak_stairs_Id;
const int Tile::slime_Id;
const int Tile::beetroots_Id;
const int Tile::grass_path_Id;
#endif
+9 -3
View File
@@ -44,6 +44,9 @@ class HalfSlabTile;
class Icon;
class IconRegister;
class TallGrass2;
class FrostedIceTile;
class GrassPathTile;
class BeetrootTile;
class ChunkRebuildData;
@@ -441,10 +444,10 @@ public:
//purpur_double_slab 204
//purpur_slab 205
//end_bricks 206
//beetroots 207
//grass_path 208
static const int beetroots_Id = 207;
static const int grass_path_Id = 208;
//end_gateway 209
//frosted_ice 212
static const int frosted_ice_Id = 212;
//magma 213
//nether_wart_block 214
//red_nether_brick 215
@@ -662,6 +665,9 @@ public:
static HalfSlabTile* stoneSlab2Half;
static Tile* log2;
static Tile* packedIce;
static FrostedIceTile* frosted_ice;
static GrassPathTile* grass_path;
static BeetrootTile* beetroots;
static Tile* seaLantern;
static Tile* prismarine;
@@ -1273,6 +1273,10 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_ITEM_ENCHANTMENT
"${CMAKE_CURRENT_SOURCE_DIR}/WaterWorkerEnchantment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/WaterWalkerEnchantment.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/WaterWalkerEnchantment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/FrostWalkerEnchantment.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/FrostWalkerEnchantment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/MendingEnchantment.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/MendingEnchantment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/net.minecraft.world.item.enchantment.h"
)
source_group("net/minecraft/world/item/enchantment" FILES ${_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_ITEM_ENCHANTMENT})
@@ -2039,6 +2043,12 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_TILE
"${CMAKE_CURRENT_SOURCE_DIR}/Rose.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/TreeTile2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/PackedIceTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/FrostedIceTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/FrostedIceTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/GrassPathTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/GrassPathTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/BeetrootTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/BeetrootTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/RedSandStoneTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SeaLanternTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/PrismarineTile.cpp"
@@ -27,4 +27,7 @@
#include "LuckOfTheSeaEnchantment.h"
#include "LureEnchantment.h"
#include "LureEnchantment.h"
#include "FrostWalkerEnchantment.h"
#include "MendingEnchantment.h"
@@ -55,6 +55,7 @@
#include "HopperTile.h"
#include "HugeMushroomTile.h"
#include "IceTile.h"
#include "FrostedIceTile.h"
#include "JukeboxTile.h"
#include "LadderTile.h"
#include "LeafTile.h"
@@ -144,5 +145,7 @@
#include "PackedIceTile.h"
#include "StoneSlabTile2.h"
#include "GrassPathTile.h"
#include "BeetrootTile.h"