Merge branch 'pieeebot:main' into main

This commit is contained in:
Marvelco 2026-04-17 11:46:51 +03:00 committed by GitHub
commit 1bcc761da8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 36 additions and 9 deletions

View file

@ -4015,6 +4015,12 @@ void ClientConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
else if (a == -2) {
done = true;
}
else if (a == -4) {
for (int i = 0; i < 3; i++) {
minecraft->localplayers[m_userIndex]->enchantmentEntries[i].id = -3;
}
done = true;
}
else {
if (firstInGroup) {
temp.id = a;

View file

@ -275,10 +275,13 @@ void IUIScene_AbstractContainerMenu::handleEnchantButton(int slot, int iPad) {
EnchantmentMenu* menu = new EnchantmentMenu(Minecraft::GetInstance()->player->inventory, dynamic_cast<Level*>(Minecraft::GetInstance()->level), 0, 0, 0);
if (0 == 0) { //uhh don't worry that is temporary
int lapisCost = slot + 1; // slot 0 = 1 lapis, slot 1 = 2, slot 2 = 3
Minecraft* pMinecraft = Minecraft::GetInstance();
auto player = pMinecraft->player;
if (player->enchantmentEntries[slot].id == -3) return;
EnchantmentMenu* menu = dynamic_cast<EnchantmentMenu*>(player->containerMenu);
HtmlString title = HtmlString(
wstring(app.GetString(Enchantment::enchantments[player->enchantmentEntries[slot].id]->getDescriptionId())) +
L" " +

View file

@ -216,6 +216,8 @@ bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
#endif
// 4J Added - Give every player a map the first time they join a server
player->inventory->setItem( 9, std::make_shared<ItemInstance>(Item::emptyMap_Id, 1, level->getAuxValueForMap(player->getXuid(), 0, centreXC, centreZC, mapScale)));
Random* r = new Random();
player->enchantmentSeed = r->nextInt(1000000); //Randomise enchantment seed upon joining server
if(app.getGameRuleDefinitions() != nullptr)
{
app.getGameRuleDefinitions()->postProcessPlayer(player);

View file

@ -103,6 +103,16 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
if (item == nullptr || !item->isEnchantable())
{
if (!level->isClientSide)
{
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
//send reset signal
dos.writeInt(-4);
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
playerList->broadcastAll(std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::ENCHANTMENT_LIST_PACKET, baos.toByteArray()));
}
for (int i = 0; i < 3; i++)
{
tempCosts[i] = costs[i];
@ -166,6 +176,7 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
{
costs[i] = EnchantmentHelper::getEnchantmentCost(&random, i, bookcases, item);
}
std::sort(costs, costs + 3);
if (!alreadyRan) {
en = false;
for (int i = 0; i < 3; i++)
@ -180,13 +191,18 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
for (int a = 0; a < 3; a++) {
vector<EnchantmentInstance*>* newEnchantment = cachedEnchantments[a];
for (int index = 0; index < newEnchantment->size(); index++)
{
EnchantmentInstance* e = newEnchantment->at(index);
dos.writeInt(e->enchantment->id);
dos.writeInt(e->level);
//delete e;
if (newEnchantment != nullptr) {
for (int index = 0; index < newEnchantment->size(); index++)
{
EnchantmentInstance* e = newEnchantment->at(index);
dos.writeInt(e->enchantment->id);
dos.writeInt(e->level);
//delete e;
}
}
else {
dos.writeInt(-3);
dos.writeInt(-3);
}
dos.writeInt(-1);
}

View file

@ -34,7 +34,7 @@ class GameType;
class Scoreboard;
struct EnchantmentEntry {
int level;
int id;
int id = -3;
};