mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-26 21:26:38 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
260 lines
7.7 KiB
C++
260 lines
7.7 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.item.h"
|
|
#include "net.minecraft.world.item.crafting.h"
|
|
#include "net.minecraft.world.entity.player.h"
|
|
#include "ResultSlot.h"
|
|
#include "ArmorSlot.h"
|
|
#include "CraftingContainer.h"
|
|
#include "ResultContainer.h"
|
|
#include "InventoryMenu.h"
|
|
#include "Tile.h"
|
|
#include "GenericStats.h"
|
|
|
|
const int InventoryMenu::RESULT_SLOT = 0;
|
|
const int InventoryMenu::CRAFT_SLOT_START = 1;
|
|
const int InventoryMenu::CRAFT_SLOT_END = InventoryMenu::CRAFT_SLOT_START + 4;
|
|
const int InventoryMenu::ARMOR_SLOT_START = InventoryMenu::CRAFT_SLOT_END;
|
|
const int InventoryMenu::ARMOR_SLOT_END = InventoryMenu::ARMOR_SLOT_START + 4;
|
|
const int InventoryMenu::INV_SLOT_START = InventoryMenu::ARMOR_SLOT_END;
|
|
const int InventoryMenu::INV_SLOT_END = InventoryMenu::INV_SLOT_START + 9 * 3;
|
|
const int InventoryMenu::USE_ROW_SLOT_START = InventoryMenu::INV_SLOT_END;
|
|
const int InventoryMenu::USE_ROW_SLOT_END = InventoryMenu::USE_ROW_SLOT_START + 9;
|
|
const int InventoryMenu::OFFHAND_SLOT = InventoryMenu::USE_ROW_SLOT_END;
|
|
|
|
InventoryMenu::InventoryMenu(shared_ptr<Inventory> inventory, bool active, Player *player) : AbstractContainerMenu()
|
|
{
|
|
owner = player;
|
|
_init( inventory, active );
|
|
}
|
|
|
|
void InventoryMenu::_init(shared_ptr<Inventory> inventory, bool active)
|
|
{
|
|
craftSlots = std::make_shared<CraftingContainer>(this, 2, 2);
|
|
resultSlots = std::make_shared<ResultContainer>();
|
|
|
|
this->active = active;
|
|
addSlot(new ResultSlot( inventory->player, craftSlots, resultSlots, 0, 144, 36));
|
|
|
|
for (int y = 0; y < 2; y++)
|
|
{
|
|
for (int x = 0; x < 2; x++)
|
|
{
|
|
addSlot(new Slot(craftSlots, x + y * 2, 88 + x * 18, 26 + y * 18));
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
// 4J Stu I removed an anonymous class that was here whose only purpose seemed to be a way of using the
|
|
// loop counter i within the functions, rather than making it a member of the object. I have moved all that
|
|
// out to the ArmorSlot class
|
|
addSlot(new ArmorSlot(i, inventory, Inventory::OFFHAND_SLOT - 1 - i, 8, 8 + i * 18) );
|
|
}
|
|
for (int y = 0; y < 3; y++)
|
|
{
|
|
for (int x = 0; x < 9; x++)
|
|
{
|
|
addSlot(new Slot(inventory, x + (y + 1) * 9, 8 + x * 18, 84 + y * 18));
|
|
}
|
|
}
|
|
for (int x = 0; x < 9; x++)
|
|
{
|
|
addSlot(new Slot(inventory, x, 8 + x * 18, 142));
|
|
}
|
|
|
|
addSlot(new OffhandSlot(inventory, Inventory::OFFHAND_SLOT, 77, 62));
|
|
|
|
slotsChanged(); // 4J removed craftSlots parameter, see comment below
|
|
}
|
|
|
|
void InventoryMenu::slotsChanged() // 4J used to take a shared_ptr<Container> but wasn't using it, so removed to simplify things
|
|
{
|
|
MemSect(23);
|
|
resultSlots->setItem(0, Recipes::getInstance()->getItemFor(craftSlots, owner->level) );
|
|
MemSect(0);
|
|
}
|
|
|
|
void InventoryMenu::removed(shared_ptr<Player> player)
|
|
{
|
|
AbstractContainerMenu::removed(player);
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
shared_ptr<ItemInstance> item = craftSlots->removeItemNoUpdate(i);
|
|
if (item != nullptr)
|
|
{
|
|
player->drop(item);
|
|
craftSlots->setItem(i, nullptr);
|
|
}
|
|
}
|
|
resultSlots->setItem(0, nullptr);
|
|
}
|
|
|
|
bool InventoryMenu::stillValid(shared_ptr<Player> player)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
shared_ptr<ItemInstance> InventoryMenu::quickMoveStack(shared_ptr<Player> player, int slotIndex)
|
|
{
|
|
shared_ptr<ItemInstance> clicked = nullptr;
|
|
Slot *slot = slots.at(slotIndex);
|
|
|
|
Slot *HelmetSlot = slots.at(ARMOR_SLOT_START);
|
|
Slot *ChestplateSlot = slots.at(ARMOR_SLOT_START+1);
|
|
Slot *LeggingsSlot = slots.at(ARMOR_SLOT_START+2);
|
|
Slot *BootsSlot = slots.at(ARMOR_SLOT_START+3);
|
|
|
|
|
|
if (slot != nullptr && slot->hasItem())
|
|
{
|
|
shared_ptr<ItemInstance> stack = slot->getItem();
|
|
clicked = stack->copy();
|
|
|
|
if (slotIndex == RESULT_SLOT)
|
|
{
|
|
// 4J Stu - Brought forward change from 1.2
|
|
if(!moveItemStackTo(stack, INV_SLOT_START, USE_ROW_SLOT_END, true))
|
|
{
|
|
return nullptr;
|
|
}
|
|
slot->onQuickCraft(stack, clicked);
|
|
}
|
|
else if (slotIndex >= INV_SLOT_START && slotIndex < INV_SLOT_END)
|
|
{
|
|
// 4J-PB - added for quick equip
|
|
if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Helmet && (!HelmetSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START, ARMOR_SLOT_START+1, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Chestplate && (!ChestplateSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START+1, ARMOR_SLOT_START+2, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Leggings && (!LeggingsSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START+2, ARMOR_SLOT_START+3, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Boots && (!BootsSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START+3, ARMOR_SLOT_START+4, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
// 4J Stu - Brought forward change from 1.2
|
|
else if(!moveItemStackTo(stack, USE_ROW_SLOT_START, USE_ROW_SLOT_END, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if (slotIndex >= USE_ROW_SLOT_START && slotIndex < USE_ROW_SLOT_END)
|
|
{
|
|
//ArmorRecipes::_eArmorType eArmourType=ArmorRecipes::GetArmorType(stack->id);
|
|
|
|
if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Helmet && (!HelmetSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START, ARMOR_SLOT_START+1, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Chestplate && (!ChestplateSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START+1, ARMOR_SLOT_START+2, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Leggings && (!LeggingsSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START+2, ARMOR_SLOT_START+3, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else if(ArmorRecipes::GetArmorType(stack->id)==ArmorRecipes::eArmorType_Boots && (!BootsSlot->hasItem() ) )
|
|
{
|
|
if(!moveItemStackTo(stack, ARMOR_SLOT_START+3, ARMOR_SLOT_START+4, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
// 4J Stu - Brought forward change from 1.2
|
|
else if(!moveItemStackTo(stack, INV_SLOT_START, INV_SLOT_END, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 4J Stu - Brought forward change from 1.2
|
|
if(!moveItemStackTo(stack, INV_SLOT_START, USE_ROW_SLOT_END, false))
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
if (stack->count == 0)
|
|
{
|
|
slot->set(nullptr);
|
|
}
|
|
else
|
|
{
|
|
slot->setChanged();
|
|
}
|
|
if (stack->count == clicked->count)
|
|
{
|
|
// nothing moved
|
|
return nullptr;
|
|
}
|
|
else
|
|
{
|
|
slot->onTake(player, stack);
|
|
}
|
|
}
|
|
return clicked;
|
|
}
|
|
|
|
bool InventoryMenu::mayCombine(Slot *slot, shared_ptr<ItemInstance> item)
|
|
{
|
|
return slot->mayCombine(item);
|
|
}
|
|
|
|
bool InventoryMenu::canTakeItemForPickAll(shared_ptr<ItemInstance> carried, Slot *target)
|
|
{
|
|
return target->container != resultSlots && AbstractContainerMenu::canTakeItemForPickAll(carried, target);
|
|
}
|
|
|
|
// 4J-JEV: Added for achievement 'Iron Man'.
|
|
shared_ptr<ItemInstance> InventoryMenu::clicked(int slotIndex, int buttonNum, int clickType, shared_ptr<Player> player, bool looped) // 4J Added looped param
|
|
{
|
|
shared_ptr<ItemInstance> out = AbstractContainerMenu::clicked(slotIndex, buttonNum, clickType, player, looped);
|
|
|
|
|
|
static int ironItems[4] = {Item::iron_helmet_Id,Item::iron_chestplate_Id,Item::iron_leggings_Id,Item::iron_boots_Id};
|
|
for (int i = ARMOR_SLOT_START; i < ARMOR_SLOT_END; i++)
|
|
{
|
|
Slot *slot = slots.at(i);
|
|
if ( (slot==nullptr) || (!slot->hasItem()) || (slot->getItem()->getItem()->id != ironItems[i-ARMOR_SLOT_START]) )
|
|
{
|
|
return out;
|
|
}
|
|
}
|
|
player->awardStat(GenericStats::ironMan(),GenericStats::param_ironMan());
|
|
|
|
return out;
|
|
}
|
|
|
|
bool InventoryMenu::OffhandSlot::mayPlace(shared_ptr<ItemInstance> item)
|
|
{
|
|
return Inventory::mayPlaceInOffhand(item);
|
|
}
|