mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-23 19:54:34 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -5,77 +5,61 @@
|
||||
#include "Slot.h"
|
||||
#include "TrapMenu.h"
|
||||
|
||||
TrapMenu::TrapMenu(std::shared_ptr<Container> inventory, std::shared_ptr<DispenserTileEntity> trap)
|
||||
{
|
||||
this->trap = trap;
|
||||
TrapMenu::TrapMenu(std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) {
|
||||
this->trap = trap;
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
addSlot(new Slot(trap, x + y * 3, 62 + x * 18, 17 + y * 18));
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
addSlot(new Slot(trap, x + y * 3, 62 + x * 18, 17 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
addSlot(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
addSlot(new Slot(inventory, x, 8 + x * 18, 70 + 4 * 18));
|
||||
}
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlot(
|
||||
new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlot(new Slot(inventory, x, 8 + x * 18, 70 + 4 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
bool TrapMenu::stillValid(std::shared_ptr<Player> player)
|
||||
{
|
||||
return trap->stillValid(player);
|
||||
bool TrapMenu::stillValid(std::shared_ptr<Player> player) {
|
||||
return trap->stillValid(player);
|
||||
}
|
||||
|
||||
// 4J Stu - Brought forward from 1.2
|
||||
std::shared_ptr<ItemInstance> TrapMenu::quickMoveStack(std::shared_ptr<Player> player, int slotIndex)
|
||||
{
|
||||
std::shared_ptr<ItemInstance> clicked = nullptr;
|
||||
Slot *slot = slots->at(slotIndex);
|
||||
if (slot != NULL && slot->hasItem())
|
||||
{
|
||||
std::shared_ptr<ItemInstance> stack = slot->getItem();
|
||||
clicked = stack->copy();
|
||||
std::shared_ptr<ItemInstance> TrapMenu::quickMoveStack(
|
||||
std::shared_ptr<Player> player, int slotIndex) {
|
||||
std::shared_ptr<ItemInstance> clicked = nullptr;
|
||||
Slot* slot = slots->at(slotIndex);
|
||||
if (slot != NULL && slot->hasItem()) {
|
||||
std::shared_ptr<ItemInstance> stack = slot->getItem();
|
||||
clicked = stack->copy();
|
||||
|
||||
if (slotIndex < INV_SLOT_START)
|
||||
{
|
||||
if (!moveItemStackTo(stack, INV_SLOT_START, USE_ROW_SLOT_END, true))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!moveItemStackTo(stack, 0, INV_SLOT_START, 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;
|
||||
if (slotIndex < INV_SLOT_START) {
|
||||
if (!moveItemStackTo(stack, INV_SLOT_START, USE_ROW_SLOT_END,
|
||||
true)) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
if (!moveItemStackTo(stack, 0, INV_SLOT_START, 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;
|
||||
}
|
||||
Reference in New Issue
Block a user