Minor fixes

1. Improve const correctness in a few places (such as `Container::getMaxStackSize()` -> `Container::getMaxStackSize() const`)

2. Use C++11 varargs for `I18n::get`, `Entity::newDoubleList` and `Language::getElement`
This commit is contained in:
void_17
2026-03-03 06:14:34 +07:00
parent 41ded31af8
commit 13c8bafad5
48 changed files with 176 additions and 217 deletions

View File

@@ -12,7 +12,7 @@ ArmorSlot::ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x
{
}
int ArmorSlot::getMaxStackSize()
int ArmorSlot::getMaxStackSize() const
{
return 1;
}

View File

@@ -16,7 +16,7 @@ public:
ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x, int y);
virtual ~ArmorSlot() {}
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual bool mayPlace(shared_ptr<ItemInstance> item);
Icon *getNoItemIcon();
//virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added

View File

@@ -134,7 +134,7 @@ bool BeaconMenu::PaymentSlot::mayPlace(shared_ptr<ItemInstance> item)
return false;
}
int BeaconMenu::PaymentSlot::getMaxStackSize()
int BeaconMenu::PaymentSlot::getMaxStackSize() const
{
return 1;
}

View File

@@ -14,7 +14,7 @@ private:
PaymentSlot(shared_ptr<Container> container, int slot, int x, int y);
bool mayPlace(shared_ptr<ItemInstance> item);
int getMaxStackSize();
int getMaxStackSize() const;
};
public:

View File

@@ -346,7 +346,7 @@ void BeaconTileEntity::setCustomName(const wstring &name)
this->name = name;
}
int BeaconTileEntity::getMaxStackSize()
int BeaconTileEntity::getMaxStackSize() const
{
return 1;
}

View File

@@ -64,7 +64,7 @@ public:
wstring getCustomName();
bool hasCustomName();
void setCustomName(const wstring &name);
int getMaxStackSize();
int getMaxStackSize() const;
bool stillValid(shared_ptr<Player> player);
void startOpen();
void stopOpen();

View File

@@ -101,7 +101,7 @@ shared_ptr<ItemInstance> BrewingStandMenu::quickMoveStack(shared_ptr<Player> pla
else if (slotIndex >= INV_SLOT_START && slotIndex < INV_SLOT_END)
{
// 4J-PB - if the item is an ingredient, quickmove it into the ingredient slot
if( (Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id) ) &&
if( (Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id) ) &&
(!IngredientSlot->hasItem() || (stack->id==IngredientSlot->getItem()->id) ) )
{
if(!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT+1, false))
@@ -125,7 +125,7 @@ shared_ptr<ItemInstance> BrewingStandMenu::quickMoveStack(shared_ptr<Player> pla
else if (slotIndex >= USE_ROW_SLOT_START && slotIndex < USE_ROW_SLOT_END)
{
// 4J-PB - if the item is an ingredient, quickmove it into the ingredient slot
if((Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id)) &&
if((Item::items[stack->id]->hasPotionBrewingFormula() || (stack->id == Item::netherwart_seeds_Id)) &&
(!IngredientSlot->hasItem() || (stack->id==IngredientSlot->getItem()->id) ))
{
if(!moveItemStackTo(stack, INGREDIENT_SLOT, INGREDIENT_SLOT+1, false))
@@ -140,7 +140,7 @@ shared_ptr<ItemInstance> BrewingStandMenu::quickMoveStack(shared_ptr<Player> pla
{
return nullptr;
}
}
}
else if (!moveItemStackTo(stack, INV_SLOT_START, INV_SLOT_END, false))
{
return nullptr;
@@ -183,7 +183,7 @@ bool BrewingStandMenu::PotionSlot::mayPlace(shared_ptr<ItemInstance> item)
return mayPlaceItem(item);
}
int BrewingStandMenu::PotionSlot::getMaxStackSize()
int BrewingStandMenu::PotionSlot::getMaxStackSize() const
{
return 1;
}
@@ -231,7 +231,7 @@ bool BrewingStandMenu::IngredientsSlot::mayCombine(shared_ptr<ItemInstance> seco
return false;
}
int BrewingStandMenu::IngredientsSlot::getMaxStackSize()
int BrewingStandMenu::IngredientsSlot::getMaxStackSize() const
{
return 64;
}

View File

@@ -47,7 +47,7 @@ private:
PotionSlot(shared_ptr<Player> player, shared_ptr<Container> container, int slot, int x, int y);
virtual bool mayPlace(shared_ptr<ItemInstance> item);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void onTake(shared_ptr<Player> player, shared_ptr<ItemInstance> carried);
static bool mayPlaceItem(shared_ptr<ItemInstance> item);
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
@@ -59,7 +59,7 @@ private:
IngredientsSlot(shared_ptr<Container> container, int slot, int x, int y);
virtual bool mayPlace(shared_ptr<ItemInstance> item);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual bool mayCombine(shared_ptr<ItemInstance> item); // 4J Added
};
};

View File

@@ -10,7 +10,7 @@
int slotsForUp [] = { BrewingStandTileEntity::INGREDIENT_SLOT };
int slotsForOtherFaces [] = { 0, 1, 2 };
intArray BrewingStandTileEntity::SLOTS_FOR_UP = intArray(slotsForUp, 1);
intArray BrewingStandTileEntity::SLOTS_FOR_UP = intArray(slotsForUp, 1);
intArray BrewingStandTileEntity::SLOTS_FOR_OTHER_FACES = intArray(slotsForOtherFaces, 3);
BrewingStandTileEntity::BrewingStandTileEntity()
@@ -156,7 +156,7 @@ bool BrewingStandTileEntity::isBrewable()
}
else
{
if (!Item::items[ingredient->id]->hasPotionBrewingFormula() && ingredient->id != Item::bucket_water_Id && ingredient->id != Item::netherwart_seeds_Id)
if (!Item::items[ingredient->id]->hasPotionBrewingFormula() && ingredient->id != Item::bucket_water_Id && ingredient->id != Item::netherwart_seeds_Id)
{
return false;
}
@@ -327,7 +327,7 @@ void BrewingStandTileEntity::save(CompoundTag *base)
for (int i = 0; i < items.length; i++)
{
if (items[i] != NULL)
if (items[i] != NULL)
{
CompoundTag *tag = new CompoundTag();
tag->putByte(L"Slot", (byte) i);
@@ -356,7 +356,7 @@ shared_ptr<ItemInstance> BrewingStandTileEntity::removeItem(unsigned int slot, i
if (slot >= 0 && slot < items.length && items[slot] != NULL)
{
if (items[slot]->count <= count)
if (items[slot]->count <= count)
{
shared_ptr<ItemInstance> item = items[slot];
items[slot] = nullptr;
@@ -364,8 +364,8 @@ shared_ptr<ItemInstance> BrewingStandTileEntity::removeItem(unsigned int slot, i
// 4J Stu - Fix for duplication glitch
if(item->count <= 0) return nullptr;
return item;
}
else
}
else
{
shared_ptr<ItemInstance> i = items[slot]->remove(count);
if (items[slot]->count == 0) items[slot] = nullptr;
@@ -397,7 +397,7 @@ void BrewingStandTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance>
}
}
int BrewingStandTileEntity::getMaxStackSize()
int BrewingStandTileEntity::getMaxStackSize() const
{
// this value is not used for the potion slots
return 64;

View File

@@ -12,7 +12,7 @@ public:
private:
ItemInstanceArray items;
static intArray SLOTS_FOR_UP;
static intArray SLOTS_FOR_UP;
static intArray SLOTS_FOR_OTHER_FACES;
int brewTime;
@@ -37,7 +37,7 @@ private:
void doBrew();
int applyIngredient(int currentBrew, shared_ptr<ItemInstance> ingredient);
public:
virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base);
@@ -45,7 +45,7 @@ public:
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen();
virtual void stopOpen();

View File

@@ -53,7 +53,7 @@ ChestTileEntity::~ChestTileEntity()
delete items;
}
unsigned int ChestTileEntity::getContainerSize()
unsigned int ChestTileEntity::getContainerSize()
{
return 9 * 3;
}
@@ -63,11 +63,11 @@ shared_ptr<ItemInstance> ChestTileEntity::getItem(unsigned int slot)
return items->data[slot];
}
shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int count)
shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int count)
{
if (items->data[slot] != NULL)
{
if (items->data[slot]->count <= count)
if (items->data[slot]->count <= count)
{
shared_ptr<ItemInstance> item = items->data[slot];
items->data[slot] = nullptr;
@@ -75,8 +75,8 @@ shared_ptr<ItemInstance> ChestTileEntity::removeItem(unsigned int slot, int coun
// 4J Stu - Fix for duplication glitch
if(item->count <= 0) return nullptr;
return item;
}
else
}
else
{
shared_ptr<ItemInstance> i = items->data[slot]->remove(count);
if (items->data[slot]->count == 0) items->data[slot] = nullptr;
@@ -154,7 +154,7 @@ void ChestTileEntity::save(CompoundTag *base)
for (unsigned int i = 0; i < items->length; i++)
{
if (items->data[i] != NULL)
if (items->data[i] != NULL)
{
CompoundTag *tag = new CompoundTag();
tag->putByte(L"Slot", (byte) i);
@@ -167,7 +167,7 @@ void ChestTileEntity::save(CompoundTag *base)
base->putBoolean(L"bonus", isBonusChest);
}
int ChestTileEntity::getMaxStackSize()
int ChestTileEntity::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}
@@ -179,7 +179,7 @@ bool ChestTileEntity::stillValid(shared_ptr<Player> player)
return true;
}
void ChestTileEntity::setChanged()
void ChestTileEntity::setChanged()
{
TileEntity::setChanged();
}
@@ -302,7 +302,7 @@ void ChestTileEntity::tick()
if (s.lock() != NULL) zc += 0.5;
if (e.lock() != NULL) xc += 0.5;
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_OPEN, 0.2f, level->random->nextFloat() * 0.1f + 0.9f);
}
}
@@ -327,7 +327,7 @@ void ChestTileEntity::tick()
if (s.lock() != NULL) zc += 0.5;
if (e.lock() != NULL) xc += 0.5;
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
// 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit
level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_CLOSE, 0.2f, level->random->nextFloat() * 0.1f + 0.9f);
}
}

View File

@@ -59,7 +59,7 @@ public:
virtual void setCustomName(const wstring &name);
virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player);
virtual void setChanged();
virtual void clearCache();

View File

@@ -70,7 +70,7 @@ void CompoundContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item
else c1->setItem(slot, item);
}
int CompoundContainer::getMaxStackSize()
int CompoundContainer::getMaxStackSize() const
{
return c1->getMaxStackSize();
}

View File

@@ -24,7 +24,7 @@ public:
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int i);
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void setChanged();
virtual bool stillValid(shared_ptr<Player> player);

View File

@@ -20,7 +20,7 @@ public:
virtual wstring getName() = 0;
virtual wstring getCustomName() = 0; // 4J Stu added for sending over the network
virtual bool hasCustomName() = 0;
virtual int getMaxStackSize() = 0;
virtual int getMaxStackSize() const = 0;
virtual void setChanged() = 0;
virtual bool stillValid(shared_ptr<Player> player) = 0;
virtual void startOpen() = 0;

View File

@@ -95,7 +95,7 @@ void CraftingContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item
if(menu) menu->slotsChanged();
}
int CraftingContainer::getMaxStackSize()
int CraftingContainer::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -24,7 +24,7 @@ public:
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void setChanged();
bool stillValid(shared_ptr<Player> player);

View File

@@ -23,7 +23,7 @@ DispenserTileEntity::~DispenserTileEntity()
delete random;
}
unsigned int DispenserTileEntity::getContainerSize()
unsigned int DispenserTileEntity::getContainerSize()
{
return 9;
}
@@ -33,7 +33,7 @@ shared_ptr<ItemInstance> DispenserTileEntity::getItem(unsigned int slot)
return items[slot];
}
shared_ptr<ItemInstance> DispenserTileEntity::removeItem(unsigned int slot, int count)
shared_ptr<ItemInstance> DispenserTileEntity::removeItem(unsigned int slot, int count)
{
if (items[slot] != NULL)
{
@@ -45,8 +45,8 @@ shared_ptr<ItemInstance> DispenserTileEntity::removeItem(unsigned int slot, int
// 4J Stu - Fix for duplication glitch
if(item->count <= 0) return nullptr;
return item;
}
else
}
else
{
shared_ptr<ItemInstance> i = items[slot]->remove(count);
if (items[slot]->count == 0) items[slot] = nullptr;
@@ -71,7 +71,7 @@ shared_ptr<ItemInstance> DispenserTileEntity::removeItemNoUpdate(int slot)
}
// 4J-PB added for spawn eggs not being useable due to limits, so add them in again
void DispenserTileEntity::AddItemBack(shared_ptr<ItemInstance>item, unsigned int slot)
void DispenserTileEntity::AddItemBack(shared_ptr<ItemInstance>item, unsigned int slot)
{
if (items[slot] != NULL)
{
@@ -80,7 +80,7 @@ void DispenserTileEntity::AddItemBack(shared_ptr<ItemInstance>item, unsigned int
{
items[slot]->count++;
setChanged();
}
}
}
else
{
@@ -91,7 +91,7 @@ void DispenserTileEntity::AddItemBack(shared_ptr<ItemInstance>item, unsigned int
}
/**
* Removes an item with the given id and returns true if one was found.
*
*
* @param itemId
* @return
*/
@@ -114,7 +114,7 @@ int DispenserTileEntity::getRandomSlot()
int replaceOdds = 1;
for (unsigned int i = 0; i < items.length; i++)
{
if (items[i] != NULL && random->nextInt(replaceOdds++) == 0)
if (items[i] != NULL && random->nextInt(replaceOdds++) == 0)
{
replaceSlot = i;
}
@@ -123,7 +123,7 @@ int DispenserTileEntity::getRandomSlot()
return replaceSlot;
}
void DispenserTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
void DispenserTileEntity::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
items[slot] = item;
if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize();
@@ -144,7 +144,7 @@ int DispenserTileEntity::addItem(shared_ptr<ItemInstance> item)
return -1;
}
wstring DispenserTileEntity::getName()
wstring DispenserTileEntity::getName()
{
return hasCustomName() ? name : app.GetString(IDS_TILE_DISPENSER);
}
@@ -184,7 +184,7 @@ void DispenserTileEntity::save(CompoundTag *base)
TileEntity::save(base);
ListTag<CompoundTag> *listTag = new ListTag<CompoundTag>;
for (unsigned int i = 0; i < items.length; i++)
for (unsigned int i = 0; i < items.length; i++)
{
if (items[i] != NULL)
{
@@ -198,7 +198,7 @@ void DispenserTileEntity::save(CompoundTag *base)
if (hasCustomName()) base->putString(L"CustomName", name);
}
int DispenserTileEntity::getMaxStackSize()
int DispenserTileEntity::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -45,7 +45,7 @@ public:
virtual bool hasCustomName();
virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player);
virtual void setChanged();
@@ -55,5 +55,5 @@ public:
// 4J Added
virtual shared_ptr<TileEntity> clone();
void AddItemBack(shared_ptr<ItemInstance>item, unsigned int slot);
void AddItemBack(shared_ptr<ItemInstance>item, unsigned int slot);
};

View File

@@ -6,7 +6,7 @@ EnchantmentContainer::EnchantmentContainer(EnchantmentMenu *menu) : SimpleContai
{
}
int EnchantmentContainer::getMaxStackSize()
int EnchantmentContainer::getMaxStackSize() const
{
return 1;
}

View File

@@ -13,7 +13,7 @@ private:
EnchantmentMenu *m_menu;
public:
EnchantmentContainer(EnchantmentMenu *menu);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void setChanged();
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
};

View File

@@ -420,7 +420,7 @@ void Entity::remove()
void Entity::setSize(float w, float h)
{
if (w != bbWidth || h != bbHeight)
if (w != bbWidth || h != bbHeight)
{
float oldW = bbWidth;
@@ -431,7 +431,7 @@ void Entity::setSize(float w, float h)
bb->z1 = bb->z0 + bbWidth;
bb->y1 = bb->y0 + bbHeight;
if (bbWidth > oldW && !firstTick && !level->isClientSide)
if (bbWidth > oldW && !firstTick && !level->isClientSide)
{
move(oldW - bbWidth, 0, oldW - bbWidth);
}
@@ -449,7 +449,7 @@ void Entity::setPos(EntityPos *pos)
void Entity::setRot(float yRot, float xRot)
{
/* JAVA:
/* JAVA:
this->yRot = yRot % 360.0f;
this->xRot = xRot % 360.0f;
@@ -585,7 +585,7 @@ void Entity::baseTick()
{
onFire = 0;
}
else
else
{
if (onFire > 0)
{
@@ -1031,7 +1031,7 @@ void Entity::checkFallDamage(double ya, bool onGround)
causeFallDamage(fallDistance);
fallDistance = 0;
}
}
}
else
{
if (ya < 0) fallDistance -= (float) ya;
@@ -1100,7 +1100,7 @@ bool Entity::updateInWaterState()
fallDistance = 0;
wasInWater = true;
onFire = 0;
}
}
else
{
wasInWater = false;
@@ -1468,25 +1468,17 @@ void Entity::onLoadedFromSave()
}
ListTag<DoubleTag> *Entity::newDoubleList(unsigned int number, double firstValue, ...)
template<typename ...Args>
ListTag<DoubleTag> *Entity::newDoubleList(unsigned int, double firstValue, Args... args)
{
ListTag<DoubleTag> *res = new ListTag<DoubleTag>();
// Add the first parameter to the ListTag
res->add( new DoubleTag(L"", firstValue ) );
va_list vl;
va_start(vl,firstValue);
double val;
for (unsigned int i=1;i<number;i++)
{
val=va_arg(vl,double);
res->add(new DoubleTag(L"", val));
}
va_end(vl);
// use pre-C++17 fold trick (TODO: once we drop C++14 support, use C++14 fold expression)
using expander = int[];
(void)expander{0, (res->add(new DoubleTag(L"", static_cast<double>(args))), 0)...};
return res;
}
@@ -1573,7 +1565,7 @@ bool Entity::interact(shared_ptr<Player> player)
return false;
}
AABB *Entity::getCollideAgainstBox(shared_ptr<Entity> entity)
AABB *Entity::getCollideAgainstBox(shared_ptr<Entity> entity)
{
return NULL;
}
@@ -1842,7 +1834,7 @@ void Entity::setSharedFlag(int flag, bool value)
if( entityData )
{
byte currentValue = entityData->getByte(DATA_SHARED_FLAGS_ID);
if (value)
if (value)
{
entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue | (1 << flag)));
}
@@ -2121,13 +2113,13 @@ wstring Entity::getNetworkName()
return getDisplayName();
}
void Entity::setAnimOverrideBitmask(unsigned int uiBitmask)
void Entity::setAnimOverrideBitmask(unsigned int uiBitmask)
{
m_uiAnimOverrideBitmask=uiBitmask;
app.DebugPrintf("!!! Setting anim override bitmask to %d\n",uiBitmask);
}
unsigned int Entity::getAnimOverrideBitmask()
{
unsigned int Entity::getAnimOverrideBitmask()
{
if(app.GetGameSettings(eGameSetting_CustomSkinAnim)==0 )
{
// We have a force animation for some skins (claptrap)

View File

@@ -304,7 +304,8 @@ public:
virtual void onLoadedFromSave();
protected:
ListTag<DoubleTag> *newDoubleList(unsigned int number, double firstValue, ...);
template<typename ...Args>
ListTag<DoubleTag> *newDoubleList(unsigned int, double firstValue, Args... args);
ListTag<FloatTag> *newFloatList(unsigned int number, float firstValue, float secondValue);
public:

View File

@@ -160,7 +160,7 @@ void FurnaceTileEntity::save(CompoundTag *base)
}
int FurnaceTileEntity::getMaxStackSize()
int FurnaceTileEntity::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}
@@ -205,7 +205,7 @@ void FurnaceTileEntity::tick()
if (items[SLOT_FUEL] != NULL)
{
// 4J Added: Keep track of whether charcoal was used in production of current stack.
if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id
if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id
&& items[SLOT_FUEL]->getAuxValue() == CoalItem::CHAR_COAL)
{
m_charcoalUsed = true;
@@ -250,7 +250,7 @@ void FurnaceTileEntity::tick()
bool FurnaceTileEntity::canBurn()
{
if (items[SLOT_INPUT] == NULL) return false;
ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
const ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
if (burnResult == NULL) return false;
if (items[SLOT_RESULT] == NULL) return true;
if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false;
@@ -264,7 +264,7 @@ void FurnaceTileEntity::burn()
{
if (!canBurn()) return;
ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
const ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id);
if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy();
else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++;

View File

@@ -57,7 +57,7 @@ public:
virtual void setCustomName(const wstring &name);
virtual void load(CompoundTag *base);
virtual void save(CompoundTag *base);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
int getBurnProgress(int max);
int getLitProgress(int max);
bool isLit();

View File

@@ -131,7 +131,7 @@ void HopperTileEntity::setCustomName(const wstring &name)
this->name = name;
}
int HopperTileEntity::getMaxStackSize()
int HopperTileEntity::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -35,7 +35,7 @@ public:
virtual wstring getCustomName();
virtual bool hasCustomName();
virtual void setCustomName(const wstring &name);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen();
virtual void stopOpen();

View File

@@ -3,20 +3,3 @@
#include "I18n.h"
Language *I18n::lang = Language::getInstance();
wstring I18n::get(const wstring& id, ...)
{
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return id;
#else
va_list va;
va_start(va, id);
return I18n::get(id, va);
#endif
}
wstring I18n::get(const wstring& id, va_list args)
{
return lang->getElement(id, args);
}

View File

@@ -10,6 +10,9 @@ private:
static Language *lang;
public:
static wstring get(const wstring& id, ...);
static wstring get(const wstring& id, va_list args);
template<typename ...Args>
static wstring get(Args... args)
{
return lang->getElement(std::forward<Args>(args)...);
}
};

View File

@@ -87,7 +87,7 @@ int Inventory::getSlotWithRemainingSpace(shared_ptr<ItemInstance> item)
{
for (unsigned int i = 0; i < items.length; i++)
{
if (items[i] != NULL && items[i]->id == item->id && items[i]->isStackable()
if (items[i] != NULL && items[i]->id == item->id && items[i]->isStackable()
&& items[i]->count < items[i]->getMaxStackSize() && items[i]->count < getMaxStackSize()
&& (!items[i]->isStackedByData() || items[i]->getAuxValue() == item->getAuxValue())
&& ItemInstance::tagMatches(items[i], item))
@@ -228,7 +228,7 @@ int Inventory::addResource(shared_ptr<ItemInstance> itemInstance)
if (slot < 0) return count;
if (items[slot] == NULL)
{
items[slot] = ItemInstance::clone(itemInstance);
items[slot] = ItemInstance::clone(itemInstance);
player->handleCollectItem(itemInstance);
}
return 0;
@@ -299,14 +299,14 @@ bool Inventory::removeResource(int type,int iAuxVal)
void Inventory::removeResources(shared_ptr<ItemInstance> item)
{
if(item == NULL) return;
if(item == NULL) return;
int countToRemove = item->count;
for (unsigned int i = 0; i < items.length; i++)
{
if (items[i] != NULL && items[i]->sameItemWithTags(item))
{
int slotCount = items[i]->count;
int slotCount = items[i]->count;
items[i]->count -= countToRemove;
if(slotCount < countToRemove)
{
@@ -387,7 +387,7 @@ bool Inventory::add(shared_ptr<ItemInstance> item)
{
player->handleCollectItem(item);
player->awardStat(
player->awardStat(
GenericStats::itemsCollected(item->id, item->getAuxValue()),
GenericStats::param_itemsCollected(item->id, item->getAuxValue(), item->GetCount()));
@@ -475,7 +475,7 @@ void Inventory::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
else
{
items[slot] = item;
}
}
player->handleCollectItem(item);
/*
ItemInstanceArray& pile = items;
@@ -592,7 +592,7 @@ bool Inventory::hasCustomName()
return false;
}
int Inventory::getMaxStackSize()
int Inventory::getMaxStackSize() const
{
return MAX_INVENTORY_STACK_SIZE;
}

View File

@@ -81,7 +81,7 @@ public:
wstring getName();
wstring getCustomName();
bool hasCustomName();
int getMaxStackSize();
int getMaxStackSize() const;
bool canDestroy(Tile *tile);
shared_ptr<ItemInstance> getArmor(int layer);
int getArmorValue();

View File

@@ -291,12 +291,12 @@ void Item::staticCtor()
Item::helmet_iron = (ArmorItem *) ( ( new ArmorItem(50, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_iron) ->setIconName(L"helmetIron")->setDescriptionId(IDS_ITEM_HELMET_IRON)->setUseDescriptionId(IDS_DESC_HELMET_IRON) );
Item::helmet_diamond = (ArmorItem *) ( ( new ArmorItem(54, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_diamond) ->setIconName(L"helmetDiamond")->setDescriptionId(IDS_ITEM_HELMET_DIAMOND)->setUseDescriptionId(IDS_DESC_HELMET_DIAMOND) );
Item::helmet_gold = (ArmorItem *) ( ( new ArmorItem(58, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_HEAD) ) ->setBaseItemTypeAndMaterial(eBaseItemType_helmet, eMaterial_gold) ->setIconName(L"helmetGold")->setDescriptionId(IDS_ITEM_HELMET_GOLD)->setUseDescriptionId(IDS_DESC_HELMET_GOLD) );
Item::chestplate_leather = (ArmorItem *) ( ( new ArmorItem(43, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_cloth) ->setIconName(L"chestplateCloth")->setDescriptionId(IDS_ITEM_CHESTPLATE_CLOTH)->setUseDescriptionId(IDS_DESC_CHESTPLATE_LEATHER) );
Item::chestplate_iron = (ArmorItem *) ( ( new ArmorItem(51, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_iron) ->setIconName(L"chestplateIron")->setDescriptionId(IDS_ITEM_CHESTPLATE_IRON)->setUseDescriptionId(IDS_DESC_CHESTPLATE_IRON) );
Item::chestplate_diamond = (ArmorItem *) ( ( new ArmorItem(55, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_diamond) ->setIconName(L"chestplateDiamond")->setDescriptionId(IDS_ITEM_CHESTPLATE_DIAMOND)->setUseDescriptionId(IDS_DESC_CHESTPLATE_DIAMOND) );
Item::chestplate_gold = (ArmorItem *) ( ( new ArmorItem(59, ArmorItem::ArmorMaterial::GOLD, 4, ArmorItem::SLOT_TORSO) ) ->setBaseItemTypeAndMaterial(eBaseItemType_chestplate, eMaterial_gold) ->setIconName(L"chestplateGold")->setDescriptionId(IDS_ITEM_CHESTPLATE_GOLD)->setUseDescriptionId(IDS_DESC_CHESTPLATE_GOLD) );
Item::leggings_leather = (ArmorItem *) ( ( new ArmorItem(44, ArmorItem::ArmorMaterial::CLOTH, 0, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_cloth) ->setIconName(L"leggingsCloth")->setDescriptionId(IDS_ITEM_LEGGINGS_CLOTH)->setUseDescriptionId(IDS_DESC_LEGGINGS_LEATHER) );
Item::leggings_iron = (ArmorItem *) ( ( new ArmorItem(52, ArmorItem::ArmorMaterial::IRON, 2, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_iron) ->setIconName(L"leggingsIron")->setDescriptionId(IDS_ITEM_LEGGINGS_IRON)->setUseDescriptionId(IDS_DESC_LEGGINGS_IRON) );
Item::leggings_diamond = (ArmorItem *) ( ( new ArmorItem(56, ArmorItem::ArmorMaterial::DIAMOND, 3, ArmorItem::SLOT_LEGS) ) ->setBaseItemTypeAndMaterial(eBaseItemType_leggings, eMaterial_diamond) ->setIconName(L"leggingsDiamond")->setDescriptionId(IDS_ITEM_LEGGINGS_DIAMOND)->setUseDescriptionId(IDS_DESC_LEGGINGS_DIAMOND) );
@@ -319,14 +319,14 @@ void Item::staticCtor()
// 4J-PB - todo - add materials and base types to the ones below
Item::bucket_empty = ( new BucketItem(69, 0) ) ->setBaseItemTypeAndMaterial(eBaseItemType_utensil, eMaterial_water)->setIconName(L"bucket")->setDescriptionId(IDS_ITEM_BUCKET)->setUseDescriptionId(IDS_DESC_BUCKET)->setMaxStackSize(16);
Item::bowl = ( new Item(25) ) ->setBaseItemTypeAndMaterial(eBaseItemType_utensil, eMaterial_wood)->setIconName(L"bowl")->setDescriptionId(IDS_ITEM_BOWL)->setUseDescriptionId(IDS_DESC_BOWL)->setMaxStackSize(64);
Item::bucket_water = ( new BucketItem(70, Tile::water_Id) ) ->setIconName(L"bucketWater")->setDescriptionId(IDS_ITEM_BUCKET_WATER)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_WATER);
Item::bucket_lava = ( new BucketItem(71, Tile::lava_Id) ) ->setIconName(L"bucketLava")->setDescriptionId(IDS_ITEM_BUCKET_LAVA)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_LAVA);
Item::bucket_milk = ( new MilkBucketItem(79) )->setIconName(L"milk")->setDescriptionId(IDS_ITEM_BUCKET_MILK)->setCraftingRemainingItem(Item::bucket_empty)->setUseDescriptionId(IDS_DESC_BUCKET_MILK);
Item::bow = (BowItem *)( new BowItem(5) ) ->setIconName(L"bow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_bow) ->setDescriptionId(IDS_ITEM_BOW)->setUseDescriptionId(IDS_DESC_BOW);
Item::arrow = ( new Item(6) ) ->setIconName(L"arrow")->setBaseItemTypeAndMaterial(eBaseItemType_bow, eMaterial_arrow) ->setDescriptionId(IDS_ITEM_ARROW)->setUseDescriptionId(IDS_DESC_ARROW);
Item::compass = ( new CompassItem(89) ) ->setIconName(L"compass")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_compass) ->setDescriptionId(IDS_ITEM_COMPASS)->setUseDescriptionId(IDS_DESC_COMPASS);
Item::clock = ( new ClockItem(91) ) ->setIconName(L"clock")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_clock) ->setDescriptionId(IDS_ITEM_CLOCK)->setUseDescriptionId(IDS_DESC_CLOCK);
Item::map = (MapItem *) ( new MapItem(102) ) ->setIconName(L"map")->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_map) ->setDescriptionId(IDS_ITEM_MAP)->setUseDescriptionId(IDS_DESC_MAP);
@@ -357,7 +357,7 @@ void Item::staticCtor()
->setBaseItemTypeAndMaterial(eBaseItemType_giltFruit,eMaterial_apple)->setIconName(L"appleGold")->setDescriptionId(IDS_ITEM_APPLE_GOLD);//->setUseDescriptionId(IDS_DESC_GOLDENAPPLE);
Item::sign = ( new SignItem(67) ) ->setBaseItemTypeAndMaterial(eBaseItemType_HangingItem, eMaterial_wood)->setIconName(L"sign")->setDescriptionId(IDS_ITEM_SIGN)->setUseDescriptionId(IDS_DESC_SIGN);
Item::minecart = ( new MinecartItem(72, Minecart::TYPE_RIDEABLE) ) ->setIconName(L"minecart")->setDescriptionId(IDS_ITEM_MINECART)->setUseDescriptionId(IDS_DESC_MINECART);
@@ -396,7 +396,7 @@ void Item::staticCtor()
Item::cookie = ( new FoodItem(101, 2, FoodConstants::FOOD_SATURATION_POOR, false) ) ->setIconName(L"cookie")->setDescriptionId(IDS_ITEM_COOKIE)->setUseDescriptionId(IDS_DESC_COOKIE);
Item::shears = (ShearsItem *)( new ShearsItem(103) ) ->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS);
Item::shears = (ShearsItem *)( new ShearsItem(103) ) ->setIconName(L"shears")->setBaseItemTypeAndMaterial(eBaseItemType_devicetool, eMaterial_shears)->setDescriptionId(IDS_ITEM_SHEARS)->setUseDescriptionId(IDS_DESC_SHEARS);
Item::melon = (new FoodItem(104, 2, FoodConstants::FOOD_SATURATION_LOW, false)) ->setIconName(L"melon")->setDescriptionId(IDS_ITEM_MELON_SLICE)->setUseDescriptionId(IDS_DESC_MELON_SLICE);
@@ -455,7 +455,7 @@ void Item::staticCtor()
// putting the fire charge in as a torch, so that it stacks without being near the middle of the selection boxes
Item::fireball = (new FireChargeItem(129)) ->setBaseItemTypeAndMaterial(eBaseItemType_torch, eMaterial_setfire)->setIconName(L"fireball")->setDescriptionId(IDS_ITEM_FIREBALL)->setUseDescriptionId(IDS_DESC_FIREBALL);
Item::frame = (new HangingEntityItem(133,eTYPE_ITEM_FRAME)) ->setBaseItemTypeAndMaterial(eBaseItemType_HangingItem, eMaterial_glass)->setIconName(L"frame")->setDescriptionId(IDS_ITEM_ITEMFRAME)->setUseDescriptionId(IDS_DESC_ITEMFRAME);
// TU12
Item::skull = (new SkullItem(141)) ->setIconName(L"skull")->setDescriptionId(IDS_ITEM_SKULL)->setUseDescriptionId(IDS_DESC_SKULL);
@@ -501,7 +501,7 @@ void Item::staticCtor()
void Item::staticInit()
{
Stats::buildItemStats();
}
}
_Tier::Tier(int level, int uses, float speed, float damage, int enchantmentValue) :
@@ -668,7 +668,7 @@ shared_ptr<ItemInstance> Item::useTimeDepleted(shared_ptr<ItemInstance> itemInst
return itemInstance;
}
int Item::getMaxStackSize()
int Item::getMaxStackSize() const
{
return maxStackSize;
}
@@ -711,7 +711,7 @@ bool Item::canBeDepleted()
/**
* Returns true when the item was used to deal more than default damage
*
*
* @param itemInstance
* @param mob
* @param attacker
@@ -724,7 +724,7 @@ bool Item::hurtEnemy(shared_ptr<ItemInstance> itemInstance, shared_ptr<LivingEnt
/**
* Returns true when the item was used to mine more efficiently
*
*
* @param itemInstance
* @param tile
* @param x

View File

@@ -72,8 +72,8 @@ public:
eMaterial_stoneSmooth,
eMaterial_netherbrick,
eMaterial_ender,
eMaterial_glass,
eMaterial_blaze,
eMaterial_glass,
eMaterial_blaze,
eMaterial_magic,
eMaterial_melon,
eMaterial_setfire,
@@ -421,13 +421,13 @@ public:
static const int bow_Id = 261;
static const int arrow_Id = 262;
static const int coal_Id = 263;
static const int diamond_Id = 264;
static const int diamond_Id = 264;
static const int ironIngot_Id = 265;
static const int goldIngot_Id = 266;
static const int sword_iron_Id = 267;
static const int sword_wood_Id = 268;
static const int sword_wood_Id = 268;
static const int shovel_wood_Id = 269;
static const int pickAxe_wood_Id = 270;
static const int pickAxe_wood_Id = 270;
static const int hatchet_wood_Id = 271;
static const int sword_stone_Id = 272;
static const int shovel_stone_Id = 273;
@@ -437,7 +437,7 @@ public:
static const int shovel_diamond_Id = 277;
static const int pickAxe_diamond_Id = 278;
static const int hatchet_diamond_Id = 279;
static const int stick_Id = 280;
static const int stick_Id = 280;
static const int bowl_Id = 281;
static const int mushroomStew_Id = 282;
static const int sword_gold_Id = 283;
@@ -452,7 +452,7 @@ public:
static const int hoe_iron_Id = 292;
static const int hoe_diamond_Id = 293;
static const int hoe_gold_Id = 294;
static const int seeds_wheat_Id = 295;
static const int seeds_wheat_Id = 295;
static const int wheat_Id = 296;
static const int bread_Id = 297;
@@ -485,7 +485,7 @@ public:
static const int porkChop_raw_Id = 319;
static const int porkChop_cooked_Id = 320;
static const int painting_Id = 321;
static const int apple_gold_Id = 322;
static const int apple_gold_Id = 322;
static const int sign_Id = 323;
static const int door_wood_Id = 324;
static const int bucket_empty_Id = 325;
@@ -501,7 +501,7 @@ public:
static const int bucket_milk_Id = 335;
static const int brick_Id = 336;
static const int clay_Id = 337;
static const int reeds_Id = 338;
static const int reeds_Id = 338;
static const int paper_Id = 339;
static const int book_Id = 340;
static const int slimeBall_Id = 341;
@@ -514,7 +514,7 @@ public:
static const int yellowDust_Id = 348;
static const int fish_raw_Id = 349;
static const int fish_cooked_Id = 350;
static const int dye_powder_Id = 351;
static const int dye_powder_Id = 351;
static const int bone_Id = 352;
static const int sugar_Id = 353;
static const int cake_Id = 354;
@@ -574,7 +574,7 @@ public:
static const int record_12_Id = 2266;
// 4J-PB - this one isn't playable in the PC game, but is fine in ours
static const int record_08_Id = 2267;
static const int record_08_Id = 2267;
// TU9
static const int fireball_Id = 385;
@@ -668,7 +668,7 @@ public:
virtual bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
virtual shared_ptr<ItemInstance> useTimeDepleted(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual int getLevelDataForAuxValue(int auxValue);
bool isStackedByData();
@@ -686,7 +686,7 @@ public:
/**
* Returns true when the item was used to deal more than default damage
*
*
* @param itemInstance
* @param mob
* @param attacker
@@ -696,7 +696,7 @@ public:
/**
* Returns true when the item was used to mine more efficiently
*
*
* @param itemInstance
* @param tile
* @param x

View File

@@ -31,17 +31,17 @@ void ItemInstance::_init(int id, int count, int auxValue)
this->m_bForceNumberDisplay=false;
}
ItemInstance::ItemInstance(Tile *tile)
ItemInstance::ItemInstance(Tile *tile)
{
_init(tile->id, 1, 0);
}
ItemInstance::ItemInstance(Tile *tile, int count)
ItemInstance::ItemInstance(Tile *tile, int count)
{
_init(tile->id, count, 0);
}
// 4J-PB - added
ItemInstance::ItemInstance(MapItem *item, int count)
ItemInstance::ItemInstance(MapItem *item, int count)
{
_init(item->id, count, 0);
}
@@ -51,19 +51,19 @@ ItemInstance::ItemInstance(Tile *tile, int count, int auxValue)
_init(tile->id, count, auxValue);
}
ItemInstance::ItemInstance(Item *item)
ItemInstance::ItemInstance(Item *item)
{
_init(item->id, 1, 0);
}
ItemInstance::ItemInstance(Item *item, int count)
ItemInstance::ItemInstance(Item *item, int count)
{
_init(item->id, count, 0);
}
ItemInstance::ItemInstance(Item *item, int count, int auxValue)
ItemInstance::ItemInstance(Item *item, int count, int auxValue)
{
_init(item->id, count, auxValue);
}
@@ -89,7 +89,7 @@ ItemInstance::~ItemInstance()
if(tag != NULL) delete tag;
}
shared_ptr<ItemInstance> ItemInstance::remove(int count)
shared_ptr<ItemInstance> ItemInstance::remove(int count)
{
shared_ptr<ItemInstance> ii = shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
if (tag != NULL) ii->tag = (CompoundTag *) tag->copy();
@@ -123,17 +123,17 @@ bool ItemInstance::useOn(shared_ptr<Player> player, Level *level, int x, int y,
return getItem()->useOn(shared_from_this(), player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly);
}
float ItemInstance::getDestroySpeed(Tile *tile)
float ItemInstance::getDestroySpeed(Tile *tile)
{
return getItem()->getDestroySpeed(shared_from_this(), tile);
}
bool ItemInstance::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
bool ItemInstance::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
return getItem()->TestUse( itemInstance, level, player);
}
shared_ptr<ItemInstance> ItemInstance::use(Level *level, shared_ptr<Player> player)
shared_ptr<ItemInstance> ItemInstance::use(Level *level, shared_ptr<Player> player)
{
return getItem()->use(shared_from_this(), level, player);
}
@@ -143,7 +143,7 @@ shared_ptr<ItemInstance> ItemInstance::useTimeDepleted(Level *level, shared_ptr<
return getItem()->useTimeDepleted(shared_from_this(), level, player);
}
CompoundTag *ItemInstance::save(CompoundTag *compoundTag)
CompoundTag *ItemInstance::save(CompoundTag *compoundTag)
{
compoundTag->putShort(L"id", (short) id);
compoundTag->putByte(L"Count", (byte) count);
@@ -169,7 +169,7 @@ void ItemInstance::load(CompoundTag *compoundTag)
}
}
int ItemInstance::getMaxStackSize()
int ItemInstance::getMaxStackSize() const
{
return getItem()->getMaxStackSize();
}
@@ -179,7 +179,7 @@ bool ItemInstance::isStackable()
return getMaxStackSize() > 1 && (!isDamageableItem() || !isDamaged());
}
bool ItemInstance::isDamageableItem()
bool ItemInstance::isDamageableItem()
{
return Item::items[id]->getMaxDamage() > 0;
}
@@ -187,7 +187,7 @@ bool ItemInstance::isDamageableItem()
/**
* Returns true if this item type only can be stacked with items that have
* the same auxValue data.
*
*
* @return
*/
@@ -196,7 +196,7 @@ bool ItemInstance::isStackedByData()
return Item::items[id]->isStackedByData();
}
bool ItemInstance::isDamaged()
bool ItemInstance::isDamaged()
{
return isDamageableItem() && auxValue > 0;
}
@@ -280,13 +280,13 @@ void ItemInstance::hurtAndBreak(int dmg, shared_ptr<LivingEntity> owner)
void ItemInstance::hurtEnemy(shared_ptr<LivingEntity> mob, shared_ptr<Player> attacker)
{
//bool used =
//bool used =
Item::items[id]->hurtEnemy(shared_from_this(), mob, attacker);
}
void ItemInstance::mineBlock(Level *level, int tile, int x, int y, int z, shared_ptr<Player> owner)
void ItemInstance::mineBlock(Level *level, int tile, int x, int y, int z, shared_ptr<Player> owner)
{
//bool used =
//bool used =
Item::items[id]->mineBlock( shared_from_this(), level, tile, x, y, z, owner);
}
@@ -342,7 +342,7 @@ bool ItemInstance::tagMatches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstanc
return true;
}
bool ItemInstance::matches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
bool ItemInstance::matches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
{
if (a == NULL && b == NULL) return true;
if (a == NULL || b == NULL) return false;
@@ -368,7 +368,7 @@ bool ItemInstance::matches(shared_ptr<ItemInstance> b)
/**
* Checks if this item is the same item as the other one, disregarding the
* 'count' value.
*
*
* @param b
* @return
*/
@@ -393,17 +393,17 @@ bool ItemInstance::sameItemWithTags(shared_ptr<ItemInstance> b)
}
// 4J Stu - Added this for the one time when we compare with a non-shared pointer
bool ItemInstance::sameItem_not_shared(ItemInstance *b)
bool ItemInstance::sameItem_not_shared(const ItemInstance *b)
{
return id == b->id && auxValue == b->auxValue;
}
unsigned int ItemInstance::getUseDescriptionId()
unsigned int ItemInstance::getUseDescriptionId()
{
return Item::items[id]->getUseDescriptionId(shared_from_this());
}
unsigned int ItemInstance::getDescriptionId(int iData /*= -1*/)
unsigned int ItemInstance::getDescriptionId(int iData /*= -1*/)
{
return Item::items[id]->getDescriptionId(shared_from_this());
}
@@ -420,7 +420,7 @@ shared_ptr<ItemInstance> ItemInstance::clone(shared_ptr<ItemInstance> item)
return item == NULL ? nullptr : item->copy();
}
wstring ItemInstance::toString()
wstring ItemInstance::toString()
{
//return count + "x" + Item::items[id]->getDescriptionId() + "@" + auxValue;
@@ -661,7 +661,7 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
lines->push_back(it->second->getHoverText(it->first));
}
}
// Delete modifiers map
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
{
@@ -760,17 +760,17 @@ bool ItemInstance::mayBePlacedInAdventureMode()
return getItem()->mayBePlacedInAdventureMode();
}
bool ItemInstance::isFramed()
bool ItemInstance::isFramed()
{
return frame != NULL;
}
void ItemInstance::setFramed(shared_ptr<ItemFrame> frame)
void ItemInstance::setFramed(shared_ptr<ItemFrame> frame)
{
this->frame = frame;
}
shared_ptr<ItemFrame> ItemInstance::getFrame()
shared_ptr<ItemFrame> ItemInstance::getFrame()
{
return frame;
}
@@ -807,8 +807,8 @@ attrAttrModMap *ItemInstance::getAttributeModifiers()
CompoundTag *entry = entries->get(i);
AttributeModifier *attribute = SharedMonsterAttributes::loadAttributeModifier(entry);
// 4J Not sure why but this is a check that the attribute ID is not empty
/*if (attribute->getId()->getLeastSignificantBits() != 0 && attribute->getId()->getMostSignificantBits() != 0)
// 4J Not sure why but this is a check that the attribute ID is not empty
/*if (attribute->getId()->getLeastSignificantBits() != 0 && attribute->getId()->getMostSignificantBits() != 0)
{*/
result->insert(std::pair<eATTRIBUTE_ID, AttributeModifier *>(static_cast<eATTRIBUTE_ID>(entry->getInt(L"ID")), attribute));
/*}*/
@@ -848,7 +848,7 @@ int ItemInstance::get4JData()
}
}
// 4J Added - to show strength on potions
bool ItemInstance::hasPotionStrengthBar()
bool ItemInstance::hasPotionStrengthBar()
{
// exclude a bottle of water from this
if((id==Item::potion_Id) && (auxValue !=0))// && (!MACRO_POTION_IS_AKWARD(auxValue))) 4J-PB leaving the bar on an awkward potion so we can differentiate it from a water bottle
@@ -859,7 +859,7 @@ bool ItemInstance::hasPotionStrengthBar()
return false;
}
int ItemInstance::GetPotionStrength()
int ItemInstance::GetPotionStrength()
{
if(MACRO_POTION_IS_INSTANTDAMAGE(auxValue) || MACRO_POTION_IS_INSTANTHEALTH(auxValue) )
{

View File

@@ -77,12 +77,12 @@ public:
int getIconType();
bool useOn(shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false);
float getDestroySpeed(Tile *tile);
bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
bool TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
shared_ptr<ItemInstance> use(Level *level, shared_ptr<Player> player);
shared_ptr<ItemInstance> useTimeDepleted(Level *level, shared_ptr<Player> player);
CompoundTag *save(CompoundTag *compoundTag);
void load(CompoundTag *compoundTag);
int getMaxStackSize();
int getMaxStackSize() const;
bool isStackable();
bool isDamageableItem();
bool isStackedByData();
@@ -113,7 +113,7 @@ private:
public:
bool sameItem(shared_ptr<ItemInstance> b);
bool sameItemWithTags(shared_ptr<ItemInstance> b); //4J Added
bool sameItem_not_shared(ItemInstance *b); // 4J Stu - Added this for the one time I need it
bool sameItem_not_shared(const ItemInstance *b); // 4J Stu - Added this for the one time I need it
virtual unsigned int getUseDescriptionId(); // 4J Added
virtual unsigned int getDescriptionId(int iData = -1);
virtual ItemInstance *setDescriptionId(unsigned int id);

View File

@@ -14,37 +14,12 @@ Language *Language::getInstance()
return singleton;
}
/* 4J Jev, creates 2 identical functions.
wstring Language::getElement(const wstring& elementId)
{
return elementId;
} */
wstring Language::getElement(const wstring& elementId, ...)
{
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return elementId;
#else
va_list args;
va_start(args, elementId);
return getElement(elementId, args);
#endif
}
wstring Language::getElement(const wstring& elementId, va_list args)
{
// 4J TODO
return elementId;
}
wstring Language::getElementName(const wstring& elementId)
std::wstring Language::getElementName(const std::wstring& elementId)
{
return elementId;
}
wstring Language::getElementDescription(const wstring& elementId)
std::wstring Language::getElementDescription(const std::wstring& elementId)
{
return elementId;
}

View File

@@ -1,5 +1,7 @@
#pragma once
#include <string>
class Language
{
private:
@@ -7,8 +9,11 @@ private:
public:
Language();
static Language *getInstance();
wstring getElement(const wstring& elementId, ...);
wstring getElement(const wstring& elementId, va_list args);
wstring getElementName(const wstring& elementId);
wstring getElementDescription(const wstring& elementId);
template<typename...Args>
inline std::wstring getElement(const std::wstring& elementId, Args...)
{
return elementId;
}
std::wstring getElementName(const std::wstring& elementId);
std::wstring getElementDescription(const std::wstring& elementId);
};

View File

@@ -105,7 +105,7 @@ bool MerchantContainer::hasCustomName()
return false;
}
int MerchantContainer::getMaxStackSize()
int MerchantContainer::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -33,7 +33,7 @@ public:
wstring getName();
wstring getCustomName();
bool hasCustomName();
int getMaxStackSize();
int getMaxStackSize() const;
bool stillValid(shared_ptr<Player> player);
void startOpen();
void stopOpen();

View File

@@ -127,7 +127,7 @@ wstring MinecartContainer::getName()
return hasCustomName() ? getCustomName() : app.GetString(IDS_CONTAINER_MINECART);
}
int MinecartContainer::getMaxStackSize()
int MinecartContainer::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -26,7 +26,7 @@ public:
virtual void stopOpen();
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
virtual wstring getName();
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void changeDimension(int i);
virtual void remove();
@@ -41,7 +41,7 @@ protected:
virtual void applyNaturalSlowdown();
public:
// 4J Stu - For container
virtual bool hasCustomName() { return Minecart::hasCustomName(); }
virtual wstring getCustomName() { return Minecart::getCustomName(); }

View File

@@ -54,7 +54,7 @@ public:
virtual wstring getName() { return MinecartContainer::getName(); }
virtual wstring getCustomName() { return MinecartContainer::getCustomName(); }
virtual bool hasCustomName() { return MinecartContainer::hasCustomName(); }
virtual int getMaxStackSize() { return MinecartContainer::getMaxStackSize(); }
virtual int getMaxStackSize() const { return MinecartContainer::getMaxStackSize(); }
virtual void setChanged() { MinecartContainer::setChanged(); }
virtual bool stillValid(shared_ptr<Player> player) { return MinecartContainer::stillValid(player); }

View File

@@ -58,7 +58,7 @@ void ResultContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
items[0] = item;
}
int ResultContainer::getMaxStackSize()
int ResultContainer::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -19,7 +19,7 @@ public:
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void setChanged();
virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen() { } // TODO Auto-generated method stub

View File

@@ -106,7 +106,7 @@ void SimpleContainer::setCustomName(const wstring &name)
this->stringName = name;
}
int SimpleContainer::getMaxStackSize()
int SimpleContainer::getMaxStackSize() const
{
return Container::LARGE_MAX_STACK_SIZE;
}

View File

@@ -28,7 +28,7 @@ public:
virtual wstring getCustomName();
virtual bool hasCustomName();
virtual void setCustomName(const wstring &name);
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual void setChanged();
virtual bool stillValid(shared_ptr<Player> player);
virtual void startOpen() { } // TODO Auto-generated method stub

View File

@@ -91,7 +91,7 @@ void Slot::setChanged()
container->setChanged();
}
int Slot::getMaxStackSize()
int Slot::getMaxStackSize() const
{
return container->getMaxStackSize();
}

View File

@@ -31,7 +31,7 @@ public:
virtual bool hasItem();
virtual void set(shared_ptr<ItemInstance> item);
virtual void setChanged();
virtual int getMaxStackSize();
virtual int getMaxStackSize() const;
virtual Icon *getNoItemIcon();
virtual shared_ptr<ItemInstance> remove(int c);
virtual bool isAt(shared_ptr<Container> c, int s);