mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
Merge branch 'pieeebot:main' into main
This commit is contained in:
commit
1bcc761da8
|
|
@ -4015,6 +4015,12 @@ void ClientConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
|
||||||
else if (a == -2) {
|
else if (a == -2) {
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
else if (a == -4) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
minecraft->localplayers[m_userIndex]->enchantmentEntries[i].id = -3;
|
||||||
|
}
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (firstInGroup) {
|
if (firstInGroup) {
|
||||||
temp.id = a;
|
temp.id = a;
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -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);
|
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
|
if (0 == 0) { //uhh don't worry that is temporary
|
||||||
int lapisCost = slot + 1; // slot 0 = 1 lapis, slot 1 = 2, slot 2 = 3
|
int lapisCost = slot + 1; // slot 0 = 1 lapis, slot 1 = 2, slot 2 = 3
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
auto player = pMinecraft->player;
|
auto player = pMinecraft->player;
|
||||||
|
if (player->enchantmentEntries[slot].id == -3) return;
|
||||||
|
|
||||||
EnchantmentMenu* menu = dynamic_cast<EnchantmentMenu*>(player->containerMenu);
|
EnchantmentMenu* menu = dynamic_cast<EnchantmentMenu*>(player->containerMenu);
|
||||||
|
|
||||||
HtmlString title = HtmlString(
|
HtmlString title = HtmlString(
|
||||||
wstring(app.GetString(Enchantment::enchantments[player->enchantmentEntries[slot].id]->getDescriptionId())) +
|
wstring(app.GetString(Enchantment::enchantments[player->enchantmentEntries[slot].id]->getDescriptionId())) +
|
||||||
L" " +
|
L" " +
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,8 @@ bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
||||||
#endif
|
#endif
|
||||||
// 4J Added - Give every player a map the first time they join a server
|
// 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)));
|
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)
|
if(app.getGameRuleDefinitions() != nullptr)
|
||||||
{
|
{
|
||||||
app.getGameRuleDefinitions()->postProcessPlayer(player);
|
app.getGameRuleDefinitions()->postProcessPlayer(player);
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,16 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
|
||||||
|
|
||||||
if (item == nullptr || !item->isEnchantable())
|
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++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
tempCosts[i] = costs[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);
|
costs[i] = EnchantmentHelper::getEnchantmentCost(&random, i, bookcases, item);
|
||||||
}
|
}
|
||||||
|
std::sort(costs, costs + 3);
|
||||||
if (!alreadyRan) {
|
if (!alreadyRan) {
|
||||||
en = false;
|
en = false;
|
||||||
for (int i = 0; i < 3; i++)
|
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++) {
|
for (int a = 0; a < 3; a++) {
|
||||||
vector<EnchantmentInstance*>* newEnchantment = cachedEnchantments[a];
|
vector<EnchantmentInstance*>* newEnchantment = cachedEnchantments[a];
|
||||||
|
if (newEnchantment != nullptr) {
|
||||||
for (int index = 0; index < newEnchantment->size(); index++)
|
for (int index = 0; index < newEnchantment->size(); index++)
|
||||||
{
|
{
|
||||||
EnchantmentInstance* e = newEnchantment->at(index);
|
EnchantmentInstance* e = newEnchantment->at(index);
|
||||||
dos.writeInt(e->enchantment->id);
|
dos.writeInt(e->enchantment->id);
|
||||||
dos.writeInt(e->level);
|
dos.writeInt(e->level);
|
||||||
//delete e;
|
//delete e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dos.writeInt(-3);
|
||||||
|
dos.writeInt(-3);
|
||||||
}
|
}
|
||||||
dos.writeInt(-1);
|
dos.writeInt(-1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class GameType;
|
||||||
class Scoreboard;
|
class Scoreboard;
|
||||||
struct EnchantmentEntry {
|
struct EnchantmentEntry {
|
||||||
int level;
|
int level;
|
||||||
int id;
|
int id = -3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue