Merge branch 'main' into TU43

This commit is contained in:
Fireblade 2026-05-24 23:47:12 -04:00 committed by GitHub
commit d4b98cf70b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
78 changed files with 1648 additions and 572 deletions

2
BUMP
View file

@ -1 +1 @@
1.0.1b 1.0.4b

View file

@ -268,6 +268,32 @@ if(PLATFORM_NAME STREQUAL "Windows64")
add_dependencies(Minecraft.Server GenerateItemNameMap) add_dependencies(Minecraft.Server GenerateItemNameMap)
endif() endif()
#neo: added - SDK generation
set(SDK_INPUT_DIRS
"${CMAKE_SOURCE_DIR}/Minecraft.World"
"${CMAKE_SOURCE_DIR}/Minecraft.Client"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs"
)
set(SDK_OUTPUT "${CMAKE_BINARY_DIR}/Minecraft.Client/$<CONFIG>/sdk.h")
add_custom_command(
OUTPUT "${SDK_OUTPUT}"
COMMAND ${CMAKE_COMMAND}
"-DINPUT_DIRS=${SDK_INPUT_DIRS}"
"-DOUTPUT_FILE=${SDK_OUTPUT}"
-P "${CMAKE_SOURCE_DIR}/cmake/GenerateSdk.cmake"
DEPENDS
"${CMAKE_SOURCE_DIR}/cmake/GenerateSdk.cmake"
COMMENT "Generating sdk.h..."
VERBATIM
)
add_custom_target(GenerateSdk ALL
DEPENDS "${SDK_OUTPUT}"
)
set_property(TARGET GenerateSdk PROPERTY FOLDER "Build")
target_include_directories(Minecraft.Client PRIVATE target_include_directories(Minecraft.Client PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/generated" "${CMAKE_CURRENT_BINARY_DIR}/generated"
) )

View file

@ -61,6 +61,8 @@
#include "Windows64/Network/WinsockNetLayer.h" #include "Windows64/Network/WinsockNetLayer.h"
#endif #endif
#include "../Minecraft.World/Recipes.h"
#ifdef _DURANGO #ifdef _DURANGO
#include "../Minecraft.World/DurangoStats.h" #include "../Minecraft.World/DurangoStats.h"
@ -137,6 +139,9 @@ ClientConnection::ClientConnection(Minecraft *minecraft, Socket *socket, int iUs
maxPlayers = 20; maxPlayers = 20;
m_isForkServer = false; m_isForkServer = false;
m_recivedRecipeRegistyUpdate = false;
m_recivedCreativeRegistyUpdate = false;
this->minecraft = minecraft; this->minecraft = minecraft;
if( iUserIndex < 0 ) if( iUserIndex < 0 )
@ -246,6 +251,14 @@ void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet)
{ {
if (done) return; if (done) return;
if (!m_recivedRecipeRegistyUpdate) {
Recipes::getInstance()->loadFromLocal();
}
if (!m_recivedCreativeRegistyUpdate) {
IUIScene_CreativeMenu::loadFromLocal();
}
PlayerUID OnlineXuid; PlayerUID OnlineXuid;
ProfileManager.GetXUID(m_userIndex,&OnlineXuid,true); // online xuid ProfileManager.GetXUID(m_userIndex,&OnlineXuid,true); // online xuid
MOJANG_DATA *pMojangData = nullptr; MOJANG_DATA *pMojangData = nullptr;
@ -4043,6 +4056,16 @@ void ClientConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
} }
} }
} }
else if (CustomPayloadPacket::UPDATE_RECIPE_REGISTRY.compare(customPayloadPacket->identifier) == 0) {
this->m_recivedRecipeRegistyUpdate = true;
Recipes::getInstance()->loadFromPacket(customPayloadPacket->data);
}
else if (CustomPayloadPacket::UPDATE_CREATIVE_REGISTRY.compare(customPayloadPacket->identifier) == 0) {
this->m_recivedCreativeRegistyUpdate = true;
IUIScene_CreativeMenu::loadFromPacket(customPayloadPacket->data);
}
} }
Connection *ClientConnection::getConnection() Connection *ClientConnection::getConnection()

View file

@ -49,6 +49,8 @@ private:
std::unordered_set<int> m_trackedEntityIds; std::unordered_set<int> m_trackedEntityIds;
std::unordered_set<int64_t> m_visibleChunks; std::unordered_set<int64_t> m_visibleChunks;
bool m_isForkServer; // true when connected to a fork server (received MC|ForkHello) bool m_isForkServer; // true when connected to a fork server (received MC|ForkHello)
bool m_recivedRecipeRegistyUpdate;
bool m_recivedCreativeRegistyUpdate;
static int64_t chunkKey(int x, int z) { return ((int64_t)x << 32) | ((int64_t)z & 0xFFFFFFFF); } static int64_t chunkKey(int x, int z) { return ((int64_t)x << 32) | ((int64_t)z & 0xFFFFFFFF); }

View file

@ -56,7 +56,8 @@ enum EGameHostOptionWorldSize
e_worldSize_Classic, e_worldSize_Classic,
e_worldSize_Small, e_worldSize_Small,
e_worldSize_Medium, e_worldSize_Medium,
e_worldSize_Large e_worldSize_Large,
e_worldSize_Expanded
}; };

View file

@ -1,4 +1,4 @@
#include "stdafx.h" #include "stdafx.h"
#include "../../Minecraft.World/net.minecraft.world.entity.item.h" #include "../../Minecraft.World/net.minecraft.world.entity.item.h"
#include "../../Minecraft.World/net.minecraft.world.entity.player.h" #include "../../Minecraft.World/net.minecraft.world.entity.player.h"
#include "../../Minecraft.World/net.minecraft.world.level.tile.entity.h" #include "../../Minecraft.World/net.minecraft.world.level.tile.entity.h"
@ -27,6 +27,9 @@
#include "../GameMode.h" #include "../GameMode.h"
#include "../Xbox/Social/SocialManager.h" #include "../Xbox/Social/SocialManager.h"
#include "Tutorial/TutorialMode.h" #include "Tutorial/TutorialMode.h"
#ifdef _WINDOWS64
#include "../Windows64/Network/WinsockNetLayer.h" // HUCKLE - added for quit on disconnect
#endif
#if defined _XBOX || defined _WINDOWS64 #if defined _XBOX || defined _WINDOWS64
#include "../Xbox/XML/ATGXmlParser.h" #include "../Xbox/XML/ATGXmlParser.h"
#include "../Xbox/XML/xmlFilesCallback.h" #include "../Xbox/XML/xmlFilesCallback.h"
@ -450,7 +453,7 @@ void CMinecraftApp::SetAction(int iPad, eXuiAction action, LPVOID param)
bool CMinecraftApp::IsAppPaused() bool CMinecraftApp::IsAppPaused()
{ {
#if defined(_XBOX_ONE) || defined(__ORBIS__) #if defined(_XBOX_ONE) || defined(__ORBIS__) || defined(_WINDOWS64)
bool paused = m_bIsAppPaused; bool paused = m_bIsAppPaused;
EnterCriticalSection(&m_saveNotificationCriticalSection); EnterCriticalSection(&m_saveNotificationCriticalSection);
if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 ) if( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 )
@ -3445,6 +3448,15 @@ void CMinecraftApp::HandleXuiActions(void)
SetAction(i,eAppAction_Idle); SetAction(i,eAppAction_Idle);
// HUCKLE - added for quit game on disconnect
#ifdef _WINDOWS64
if(g_Win64MultiplayerQuitOnDisconnect == true)
{
app.ExitGame();
return;
}
#endif
// If we're already leaving don't exit // If we're already leaving don't exit
if (g_NetworkManager.IsLeavingGame()) if (g_NetworkManager.IsLeavingGame())
{ {
@ -9670,8 +9682,9 @@ bool CMinecraftApp::DLCContentRetrieved(eDLCMarketplaceType eType)
void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, DWORD dwSkinBoxC) void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, DWORD dwSkinBoxC)
{ {
EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); EntityRenderDispatcher *dispatcher = EntityRenderDispatcher::instance;
Model *pModel = renderer->getModel(); EntityRenderer *renderer = dispatcher ? dispatcher->getRenderer(eTYPE_PLAYER) : nullptr;
Model *pModel = renderer ? renderer->getModel() : nullptr;
vector<ModelPart *> *pvModelPart = new vector<ModelPart *>; vector<ModelPart *> *pvModelPart = new vector<ModelPart *>;
vector<SKIN_BOX *> *pvSkinBoxes = new vector<SKIN_BOX *>; vector<SKIN_BOX *> *pvSkinBoxes = new vector<SKIN_BOX *>;
@ -9702,8 +9715,9 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D
vector<ModelPart *> * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vector<SKIN_BOX *> *pvSkinBoxA) vector<ModelPart *> * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vector<SKIN_BOX *> *pvSkinBoxA)
{ {
EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); EntityRenderDispatcher *dispatcher = EntityRenderDispatcher::instance;
Model *pModel = renderer->getModel(); EntityRenderer *renderer = dispatcher ? dispatcher->getRenderer(eTYPE_PLAYER) : nullptr;
Model *pModel = renderer ? renderer->getModel() : nullptr;
vector<ModelPart *> *pvModelPart = new vector<ModelPart *>; vector<ModelPart *> *pvModelPart = new vector<ModelPart *>;
EnterCriticalSection( &csAdditionalModelParts ); EnterCriticalSection( &csAdditionalModelParts );

View file

@ -1,3 +1,4 @@
#include "IUIScene_CreativeMenu.h"
#include "stdafx.h" #include "stdafx.h"
#include "IUIScene_CreativeMenu.h" #include "IUIScene_CreativeMenu.h"
@ -22,6 +23,56 @@ vector< shared_ptr<ItemInstance> > IUIScene_CreativeMenu::categoryGroups[eCreati
#define ITEM_AUX(id, aux) list->push_back( shared_ptr<ItemInstance>(new ItemInstance(id, 1, aux)) ); #define ITEM_AUX(id, aux) list->push_back( shared_ptr<ItemInstance>(new ItemInstance(id, 1, aux)) );
#define DEF(index) list = &categoryGroups[index]; #define DEF(index) list = &categoryGroups[index];
void IUIScene_CreativeMenu::_wipeCreativeItems() {
for (int i = 0; i < eCreativeInventoryGroupsCount; i++) {
IUIScene_CreativeMenu::categoryGroups[i].clear();
}
}
void IUIScene_CreativeMenu::loadFromLocal() {
IUIScene_CreativeMenu::_wipeCreativeItems();
IUIScene_CreativeMenu::staticCtor();
}
void IUIScene_CreativeMenu::loadFromPacket(byteArray packetData) {
ByteArrayInputStream bais(packetData);
DataInputStream input(&bais);
IUIScene_CreativeMenu::_wipeCreativeItems();
for (int i = 0; i < eCreativeInventoryGroupsCount; i++) {
int itemCount = input.readShort();
for (int j = 0; j < itemCount; j++) {
int itemId = input.readShort();
int itemAux = input.readShort();
shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(itemId, 1, 0);
item->setRawAuxValue(itemAux);
item->tag = Packet::readNbt(&input);
IUIScene_CreativeMenu::categoryGroups[i].emplace_back(item);
}
}
}
std::shared_ptr<CustomPayloadPacket> IUIScene_CreativeMenu::createUpdatePacket() {
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
for (int i = 0; i < eCreativeInventoryGroupsCount; i++) {
dos.writeShort(IUIScene_CreativeMenu::categoryGroups[i].size());
for (shared_ptr<ItemInstance>& item : IUIScene_CreativeMenu::categoryGroups[i]) {
dos.writeShort(item->id);
dos.writeShort(item->getAuxValue());
Packet::writeNbt(item->tag, &dos);
}
}
return std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::UPDATE_CREATIVE_REGISTRY, baos.toByteArray());
}
void IUIScene_CreativeMenu::staticCtor() void IUIScene_CreativeMenu::staticCtor()
{ {
vector< shared_ptr<ItemInstance> > *list; vector< shared_ptr<ItemInstance> > *list;
@ -802,55 +853,56 @@ void IUIScene_CreativeMenu::staticCtor()
ITEM_AUX(Item::potion_Id,MACRO_MAKEPOTION_AUXVAL(MASK_SPLASH, MASK_LEVEL2EXTENDED, MASK_JUMPBOOST)) ITEM_AUX(Item::potion_Id,MACRO_MAKEPOTION_AUXVAL(MASK_SPLASH, MASK_LEVEL2EXTENDED, MASK_JUMPBOOST))
// end of tu31 potions // end of tu31 potions
if (specs == nullptr) {
specs = new TabSpec * [eCreativeInventoryTab_COUNT];
specs = new TabSpec*[eCreativeInventoryTab_COUNT]; // Top Row
ECreative_Inventory_Groups blocksGroup[] = { eCreativeInventory_BuildingBlocks };
// Top Row specs[eCreativeInventoryTab_BuildingBlocks] = new TabSpec(L"Structures", IDS_GROUPNAME_BUILDING_BLOCKS, 1, blocksGroup);
ECreative_Inventory_Groups blocksGroup[] = {eCreativeInventory_BuildingBlocks};
specs[eCreativeInventoryTab_BuildingBlocks] = new TabSpec(L"Structures", IDS_GROUPNAME_BUILDING_BLOCKS, 1, blocksGroup);
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration}; ECreative_Inventory_Groups decorationsGroup[] = { eCreativeInventory_Decoration };
ECreative_Inventory_Groups debugDecorationsGroup[] = {eCreativeInventory_ArtToolsDecorations}; ECreative_Inventory_Groups debugDecorationsGroup[] = { eCreativeInventory_ArtToolsDecorations };
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, nullptr, 1, debugDecorationsGroup); specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup, 0, nullptr, 1, debugDecorationsGroup);
#else #else
ECreative_Inventory_Groups decorationsGroup[] = {eCreativeInventory_Decoration}; ECreative_Inventory_Groups decorationsGroup[] = { eCreativeInventory_Decoration };
specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup); specs[eCreativeInventoryTab_Decorations] = new TabSpec(L"Decoration", IDS_GROUPNAME_DECORATIONS, 1, decorationsGroup);
#endif #endif
ECreative_Inventory_Groups redAndTranGroup[] = {eCreativeInventory_Transport, eCreativeInventory_Redstone}; ECreative_Inventory_Groups redAndTranGroup[] = { eCreativeInventory_Transport, eCreativeInventory_Redstone };
specs[eCreativeInventoryTab_RedstoneAndTransport] = new TabSpec(L"RedstoneAndTransport", IDS_GROUPNAME_REDSTONE_AND_TRANSPORT, 2, redAndTranGroup); specs[eCreativeInventoryTab_RedstoneAndTransport] = new TabSpec(L"RedstoneAndTransport", IDS_GROUPNAME_REDSTONE_AND_TRANSPORT, 2, redAndTranGroup);
ECreative_Inventory_Groups materialsGroup[] = {eCreativeInventory_Materials}; ECreative_Inventory_Groups materialsGroup[] = { eCreativeInventory_Materials };
specs[eCreativeInventoryTab_Materials] = new TabSpec(L"Materials", IDS_GROUPNAME_MATERIALS, 1, materialsGroup); specs[eCreativeInventoryTab_Materials] = new TabSpec(L"Materials", IDS_GROUPNAME_MATERIALS, 1, materialsGroup);
ECreative_Inventory_Groups foodGroup[] = {eCreativeInventory_Food}; ECreative_Inventory_Groups foodGroup[] = { eCreativeInventory_Food };
specs[eCreativeInventoryTab_Food] = new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup); specs[eCreativeInventoryTab_Food] = new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup);
ECreative_Inventory_Groups toolsGroup[] = {eCreativeInventory_ToolsArmourWeapons}; ECreative_Inventory_Groups toolsGroup[] = { eCreativeInventory_ToolsArmourWeapons };
specs[eCreativeInventoryTab_ToolsWeaponsArmor] = new TabSpec(L"Tools", IDS_GROUPNAME_TOOLS_WEAPONS_ARMOR, 1, toolsGroup); specs[eCreativeInventoryTab_ToolsWeaponsArmor] = new TabSpec(L"Tools", IDS_GROUPNAME_TOOLS_WEAPONS_ARMOR, 1, toolsGroup);
ECreative_Inventory_Groups brewingGroup[] = {eCreativeInventory_Brewing, eCreativeInventory_Potions_Level2_Extended, eCreativeInventory_Potions_Extended, eCreativeInventory_Potions_Level2, eCreativeInventory_Potions_Basic}; ECreative_Inventory_Groups brewingGroup[] = { eCreativeInventory_Brewing, eCreativeInventory_Potions_Level2_Extended, eCreativeInventory_Potions_Extended, eCreativeInventory_Potions_Level2, eCreativeInventory_Potions_Basic };
// Just use the text LT - the graphic doesn't fit in splitscreen either // Just use the text LT - the graphic doesn't fit in splitscreen either
// In 480p there's not enough room for the LT button, so use text instead // In 480p there's not enough room for the LT button, so use text instead
//if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) //if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())
{ {
specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"Brewing", IDS_GROUPNAME_POTIONS_480, 5, brewingGroup); specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"Brewing", IDS_GROUPNAME_POTIONS_480, 5, brewingGroup);
}
// else
// {
// specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"icon_brewing.png", IDS_GROUPNAME_POTIONS, 1, brewingGroup, 4, potionsGroup);
// }
#ifndef _CONTENT_PACKAGE
ECreative_Inventory_Groups miscGroup[] = { eCreativeInventory_Misc };
ECreative_Inventory_Groups debugMiscGroup[] = { eCreativeInventory_ArtToolsMisc };
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup);
#else
ECreative_Inventory_Groups miscGroup[] = { eCreativeInventory_Misc };
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup);
#endif
} }
// else
// {
// specs[eCreativeInventoryTab_Brewing] = new TabSpec(L"icon_brewing.png", IDS_GROUPNAME_POTIONS, 1, brewingGroup, 4, potionsGroup);
// }
#ifndef _CONTENT_PACKAGE
ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc};
ECreative_Inventory_Groups debugMiscGroup[] = {eCreativeInventory_ArtToolsMisc};
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, 1, debugMiscGroup);
#else
ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc};
specs[eCreativeInventoryTab_Misc] = new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup);
#endif
} }
IUIScene_CreativeMenu::IUIScene_CreativeMenu() IUIScene_CreativeMenu::IUIScene_CreativeMenu()

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "IUIScene_AbstractContainerMenu.h" #include "IUIScene_AbstractContainerMenu.h"
#include "../../../Minecraft.World/AbstractContainerMenu.h" #include "../../../Minecraft.World/AbstractContainerMenu.h"
#include "../../../Minecraft.World/CustomPayloadPacket.h"
// 4J Stu - This class is for code that is common between XUI and Iggy // 4J Stu - This class is for code that is common between XUI and Iggy
class SimpleContainer; class SimpleContainer;
@ -100,10 +101,16 @@ protected:
bool m_bCarryingCreativeItem; bool m_bCarryingCreativeItem;
int m_creativeSlotX, m_creativeSlotY, m_inventorySlotX, m_inventorySlotY; int m_creativeSlotX, m_creativeSlotY, m_inventorySlotX, m_inventorySlotY;
static void _wipeCreativeItems();
public: public:
static void staticCtor(); static void staticCtor();
IUIScene_CreativeMenu(); IUIScene_CreativeMenu();
static void loadFromLocal();
static void loadFromPacket(byteArray packetData);
static std::shared_ptr<CustomPayloadPacket> createUpdatePacket();
protected: protected:
ECreativeInventoryTabs m_curTab; ECreativeInventoryTabs m_curTab;
int m_tabDynamicPos[eCreativeInventoryTab_COUNT]; int m_tabDynamicPos[eCreativeInventoryTab_COUNT];

View file

@ -5,6 +5,7 @@
#include "UIScene.h" #include "UIScene.h"
#include "UIControl_Slider.h" #include "UIControl_Slider.h"
#include "UIControl_TexturePackList.h" #include "UIControl_TexturePackList.h"
#include "UIControl_CheckBox.h"
#include "UIControl_AchievementsList.h" #include "UIControl_AchievementsList.h"
#include "UIScene_AchievementsMenu.h" #include "UIScene_AchievementsMenu.h"
#include "../../../Minecraft.World/StringHelpers.h" #include "../../../Minecraft.World/StringHelpers.h"
@ -976,6 +977,7 @@ void UIController::tickInput()
{ {
#ifdef _WINDOWS64 #ifdef _WINDOWS64
m_mouseClickConsumedByScene = false; m_mouseClickConsumedByScene = false;
UIControl* currHitCtrl = NULL;
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
{ {
UIScene *pScene = nullptr; UIScene *pScene = nullptr;
@ -1150,6 +1152,7 @@ void UIController::tickInput()
hitControlId = -1; hitControlId = -1;
hitArea = INT_MAX; hitArea = INT_MAX;
hitCtrl = NULL; hitCtrl = NULL;
hitCtrl = ctrl;
break; // ButtonList takes priority break; // ButtonList takes priority
} }
if (type == UIControl::eAchievementList) if (type == UIControl::eAchievementList)
@ -1162,6 +1165,7 @@ void UIController::tickInput()
hitControlId = -1; hitControlId = -1;
hitArea = INT_MAX; hitArea = INT_MAX;
hitCtrl = NULL; hitCtrl = NULL;
hitCtrl = ctrl;
break; break;
} }
if (type == UIControl::eTexturePackList) if (type == UIControl::eTexturePackList)
@ -1210,6 +1214,8 @@ void UIController::tickInput()
} }
} }
} }
currHitCtrl = hitCtrl;
UpdateCursorIcon(currHitCtrl);
} }
} }
@ -1336,6 +1342,27 @@ void UIController::tickInput()
} }
} }
void UIController::UpdateCursorIcon(UIControl *hitCtrl)
{
// from WinUser.h
if (hitCtrl && (hitCtrl->getControlType() == UIControl::eButton || hitCtrl->getControlType() == UIControl::eButtonList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
else if (hitCtrl && (hitCtrl->getControlType() == UIControl::eSlider || hitCtrl->getControlType() == UIControl::eTexturePackList))
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_SIZEWE));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput)
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_IBEAM));
else if (hitCtrl && hitCtrl->getControlType() == UIControl::eCheckBox) // Show the cross sign shaped cursor only when the checkbox is disabled/grayed out
{
UIControl_CheckBox *pCheck = static_cast<UIControl_CheckBox *>(hitCtrl);
if (pCheck && !pCheck->IsEnabled())
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_NO));
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND));
}
else
g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_ARROW));
}
void UIController::handleInput() void UIController::handleInput()
{ {
// For each user, loop over each key type and send messages based on the state // For each user, loop over each key type and send messages based on the state
@ -2218,6 +2245,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
SetMenuDisplayed(menuDisplayedPad,true); SetMenuDisplayed(menuDisplayedPad,true);
bool success = m_groups[static_cast<int>(group)]->NavigateToScene(iPad, scene, initData, layer); bool success = m_groups[static_cast<int>(group)]->NavigateToScene(iPad, scene, initData, layer);
if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true); if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true);
UpdateCursorIcon(nullptr);
LeaveCriticalSection(&m_navigationLock); LeaveCriticalSection(&m_navigationLock);
timer.PrintElapsedTime(L"Navigate to scene"); timer.PrintElapsedTime(L"Navigate to scene");
@ -2257,6 +2285,7 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI
navComplete = m_groups[static_cast<int>(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer); navComplete = m_groups[static_cast<int>(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer);
if(!m_groups[static_cast<int>(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false); if(!m_groups[static_cast<int>(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false);
} }
UpdateCursorIcon(nullptr);
return navComplete; return navComplete;
} }

View file

@ -275,6 +275,7 @@ public:
// INPUT // INPUT
private: private:
void tickInput(); void tickInput();
void UpdateCursorIcon(UIControl *hitCtrl);
void handleInput(); void handleInput();
void handleKeyPress(unsigned int iPad, unsigned int key); void handleKeyPress(unsigned int iPad, unsigned int key);

View file

@ -2,6 +2,12 @@
#include "UI.h" #include "UI.h"
#include "UIScene_Intro.h" #include "UIScene_Intro.h"
// HUCKLE - added below for joining game on launch
#ifdef _WINDOWS64
#include "../../Windows64/Network/WinsockNetLayer.h"
#include "../../User.h"
#endif
UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{ {
@ -104,6 +110,82 @@ void UIScene_Intro::handleInput(int iPad, int key, bool repeat, bool pressed, bo
} }
#elif defined _XBOX_ONE #elif defined _XBOX_ONE
ui.NavigateToScene(0,eUIScene_MainMenu); ui.NavigateToScene(0,eUIScene_MainMenu);
#elif defined _WINDOWS64
// HUCKLE - added this for auto joining servers on game launch
// THANKS so much to DrPerky and GeorgeV22 for helping with this bit, honestly got stuck for 4 hours :sob:
if(g_Win64MultiplayerJoin == true)
{
int primaryPad = ProfileManager.GetPrimaryPad();
if (!ProfileManager.IsSignedIn(primaryPad) || ProfileManager.IsGuest(primaryPad))
{
UINT uiIDA[1] = { IDS_OK };
ui.RequestErrorMessage(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, uiIDA, 1);
ui.NavigateToScene(0, eUIScene_MainMenu);
return;
}
app.ClearSignInChangeUsersMask();
app.ReleaseSaveThumbnail();
ProfileManager.SetLockedProfile(primaryPad);
ProfileManager.QuerySigninStatus();
if (!app.DLCInstallProcessCompleted())
app.StartInstallDLCProcess(primaryPad);
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->user->name = convStringToWstring(ProfileManager.GetGamertag(primaryPad));
app.ApplyGameSettingsChanged(primaryPad);
auto sessionInfo = std::make_unique<FriendSessionInfo>();
// label and name
const wchar_t* defaultName = L"";
size_t nameLen = wcslen(defaultName);
// ip and port
strncpy_s(sessionInfo->data.hostIP, g_Win64MultiplayerIP, sizeof(sessionInfo->data.hostIP) - 1);
sessionInfo->data.hostPort = g_Win64MultiplayerPort;
// display label
sessionInfo->displayLabel = new wchar_t[nameLen + 1];
wcscpy_s(sessionInfo->displayLabel, nameLen + 1, defaultName);
sessionInfo->displayLabelLength = static_cast<unsigned char>(nameLen);
sessionInfo->displayLabelViewableStartIndex = 0;
// name
wcsncpy_s(sessionInfo->data.hostName, XUSER_NAME_SIZE, defaultName, _TRUNCATE);
// session ids
sessionInfo->sessionId = static_cast<uint64_t>(inet_addr(g_Win64MultiplayerIP)) |
static_cast<uint64_t>(g_Win64MultiplayerPort) << 32;
// random props
sessionInfo->data.isReadyToJoin = true;
sessionInfo->data.isJoinable = true;
DWORD dwLocalUsersMask = 0;
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( sessionInfo.get(), dwLocalUsersMask );
if (result == CGameNetworkManager::JOINGAME_PENDING)
{
ConnectionProgressParams *param = new ConnectionProgressParams();
param->iPad = ProfileManager.GetPrimaryPad();
param->stringId = IDS_PROGRESS_CONNECTING;
param->showTooltips = true;
param->setFailTimer = false;
param->timerTime = 0;
param->cancelFunc = nullptr;
param->cancelFuncParam = nullptr;
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_ConnectingProgress, param);
}
}
else
{
ui.NavigateToScene(0,eUIScene_SaveMessage);
}
#else #else
ui.NavigateToScene(0,eUIScene_SaveMessage); ui.NavigateToScene(0,eUIScene_SaveMessage);
#endif #endif
@ -169,6 +251,82 @@ void UIScene_Intro::handleAnimationEnd()
{ {
m_bAnimationEnded = true; m_bAnimationEnded = true;
} }
#elif defined _WINDOWS64
// HUCKLE - added this for auto joining servers on game launch
// THANKS so much to DrPerky and GeorgeV22 for helping with this bit, honestly got stuck for 4 hours :sob:
if(g_Win64MultiplayerJoin == true)
{
int primaryPad = ProfileManager.GetPrimaryPad();
if (!ProfileManager.IsSignedIn(primaryPad) || ProfileManager.IsGuest(primaryPad))
{
UINT uiIDA[1] = { IDS_OK };
ui.RequestErrorMessage(IDS_MUST_SIGN_IN_TITLE, IDS_MUST_SIGN_IN_TEXT, uiIDA, 1);
ui.NavigateToScene(0, eUIScene_MainMenu);
return;
}
app.ClearSignInChangeUsersMask();
app.ReleaseSaveThumbnail();
ProfileManager.SetLockedProfile(primaryPad);
ProfileManager.QuerySigninStatus();
if (!app.DLCInstallProcessCompleted())
app.StartInstallDLCProcess(primaryPad);
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->user->name = convStringToWstring(ProfileManager.GetGamertag(primaryPad));
app.ApplyGameSettingsChanged(primaryPad);
auto sessionInfo = std::make_unique<FriendSessionInfo>();
// label and name
const wchar_t* defaultName = L"";
size_t nameLen = wcslen(defaultName);
// ip and port
strncpy_s(sessionInfo->data.hostIP, g_Win64MultiplayerIP, sizeof(sessionInfo->data.hostIP) - 1);
sessionInfo->data.hostPort = g_Win64MultiplayerPort;
// display label
sessionInfo->displayLabel = new wchar_t[nameLen + 1];
wcscpy_s(sessionInfo->displayLabel, nameLen + 1, defaultName);
sessionInfo->displayLabelLength = static_cast<unsigned char>(nameLen);
sessionInfo->displayLabelViewableStartIndex = 0;
// name
wcsncpy_s(sessionInfo->data.hostName, XUSER_NAME_SIZE, defaultName, _TRUNCATE);
// session ids
sessionInfo->sessionId = static_cast<uint64_t>(inet_addr(g_Win64MultiplayerIP)) |
static_cast<uint64_t>(g_Win64MultiplayerPort) << 32;
// random props
sessionInfo->data.isReadyToJoin = true;
sessionInfo->data.isJoinable = true;
DWORD dwLocalUsersMask = 0;
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( sessionInfo.get(), dwLocalUsersMask );
if (result == CGameNetworkManager::JOINGAME_PENDING)
{
ConnectionProgressParams *param = new ConnectionProgressParams();
param->iPad = ProfileManager.GetPrimaryPad();
param->stringId = IDS_PROGRESS_CONNECTING;
param->showTooltips = true;
param->setFailTimer = false;
param->timerTime = 0;
param->cancelFunc = nullptr;
param->cancelFuncParam = nullptr;
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_ConnectingProgress, param);
}
}
else
{
ui.NavigateToScene(0,eUIScene_SaveMessage);
}
#else #else
ui.NavigateToScene(0,eUIScene_SaveMessage); ui.NavigateToScene(0,eUIScene_SaveMessage);
#endif #endif

View file

@ -149,6 +149,7 @@ GameRenderer::GameRenderer(Minecraft *mc)
#ifndef MINECRAFT_SERVER_BUILD #ifndef MINECRAFT_SERVER_BUILD
// 4J-PB - set up the local players iteminhand renderers here - needs to be done with lighting enabled so that the render geometry gets compiled correctly // 4J-PB - set up the local players iteminhand renderers here - needs to be done with lighting enabled so that the render geometry gets compiled correctly
#ifndef MINECRAFT_SERVER_BUILD
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
mc->localitemInHandRenderers[0] = new ItemInHandRenderer(mc);//itemInHandRenderer; mc->localitemInHandRenderers[0] = new ItemInHandRenderer(mc);//itemInHandRenderer;
mc->localitemInHandRenderers[1] = new ItemInHandRenderer(mc); mc->localitemInHandRenderers[1] = new ItemInHandRenderer(mc);

View file

@ -126,81 +126,75 @@ void ItemFrameRenderer::drawFrame(shared_ptr<ItemFrame> itemFrame)
void ItemFrameRenderer::drawItem(shared_ptr<ItemFrame> entity) void ItemFrameRenderer::drawItem(shared_ptr<ItemFrame> entity)
{ {
Minecraft *pMinecraft=Minecraft::GetInstance();
shared_ptr<ItemInstance> instance = entity->getItem(); shared_ptr<ItemInstance> instance = entity->getItem();
if (instance == nullptr) return; if (instance == nullptr) return;
shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(entity->level, 0, 0, 0, instance); shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(entity->level, 0, 0, 0, instance);
itemEntity->getItem()->count = 1; itemEntity->getItem()->count = 1;
itemEntity->bobOffs = 0; itemEntity->bobOffs = 0;
glPushMatrix(); glPushMatrix();
glTranslatef((-7.25f / 16.0f) * Direction::STEP_X[entity->dir], -0.18f, (-7.25f / 16.0f) * Direction::STEP_Z[entity->dir]); glRotatef(180.0f + entity->yRot, 0, 1, 0);
glRotatef(180 + entity->yRot, 0, 1, 0); glTranslatef(0.0f, 0.0f, -0.4375f);
glRotatef(-45.0f * entity->getRotation(), 0, 0, 1);
static const float offsets[8][2] = { int rotation = entity->getRotation();
{ 0.0f, 0.0f }, bool isMap = (itemEntity->getItem()->getItem() == Item::map);
{ -0.08f, -0.08f }, int effectiveRotation = isMap ? 2 * (rotation % 4) : rotation;
{ -0.16f, -0.16f },
{ -0.08f, -0.24f },
{ 0.0f, -0.32f },
{ 0.08f, -0.24f },
{ 0.16f, -0.16f },
{ 0.08f, -0.08f }
};
int rotIndex = entity->getRotation() & 0x7;
glTranslatef(offsets[rotIndex][0], offsets[rotIndex][1], 0.0f);
if (itemEntity->getItem()->getItem() == Item::map) glRotatef(-45.0f * effectiveRotation, 0, 0, 1);
{ glTranslatef(0.0f, -0.41f/2, 0.0f);
entityRenderDispatcher->textures->bindTexture(&MAP_BACKGROUND_LOCATION);
Tesselator *t = Tesselator::getInstance();
glRotatef(180, 0, 1, 0); if (isMap)
glRotatef(180, 0, 0, 1); {
glScalef(1.0f / 128.0f, 1.0f / 128.0f, 1.0f / 128.0f); //entityRenderDispatcher->textures->bindTexture(&MAP_BACKGROUND_LOCATION);
glTranslatef(-64.0f, -87.0f, -3.0f); //Tesselator *t = Tesselator::getInstance();
glNormal3f(0, 0, -1);
t->begin();
int vo = 7;
t->vertexUV(0.0f, 128.0f, 0.0f, 0.0f, 1.0f);
t->vertexUV(128.0f, 128.0f, 0.0f, 1.0f, 1.0f);
t->vertexUV(128.0f, 0.0f, 0.0f, 1.0f, 0.0f);
t->vertexUV(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
t->end();
shared_ptr<MapItemSavedData> data = Item::map->getSavedData(itemEntity->getItem(), entity->level); glRotatef(180, 0, 1, 0);
if (data != nullptr) glRotatef(180, 0, 0, 1);
{ glScalef(1.0f / 128.0f, 1.0f / 128.0f, 1.0f / 128.0f);
entityRenderDispatcher->itemInHandRenderer->minimap->render(nullptr, entityRenderDispatcher->textures, data, entity->entityId); glTranslatef(-64.0f, -87.0f, -3.0f);
}
}
else
{
if (itemEntity->getItem()->getItem() == Item::compass)
{
CompassTexture *ct = CompassTexture::instance;
double compassRot = ct->rot;
double compassRotA = ct->rota;
ct->rot = 0;
ct->rota = 0;
ct->updateFromPosition(entity->level, entity->x, entity->z, Mth::wrapDegrees( static_cast<float>(180 + entity->dir * 90) ), false, true);
ct->rot = compassRot;
ct->rota = compassRotA;
}
EntityRenderDispatcher::instance->render(itemEntity, 0, 0, 0, 0, 0, true); //glNormal3f(0, 0, -1);
//t->begin();
//t->vertexUV(0.0f, 128.0f, 0.0f, 0.0f, 1.0f);
//t->vertexUV(128.0f, 128.0f, 0.0f, 1.0f, 1.0f);
//t->vertexUV(128.0f, 0.0f, 0.0f, 1.0f, 0.0f);
//t->vertexUV(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
//t->end();
if (itemEntity->getItem()->getItem() == Item::compass) shared_ptr<MapItemSavedData> data = Item::map->getSavedData(itemEntity->getItem(), entity->level);
{ if (data != nullptr)
CompassTexture *ct = CompassTexture::instance; {
ct->cycleFrames(); entityRenderDispatcher->itemInHandRenderer->minimap->render(
} nullptr, entityRenderDispatcher->textures, data, entity->entityId);
} }
}
else
{
if (itemEntity->getItem()->getItem() == Item::compass)
{
CompassTexture *ct = CompassTexture::instance;
double compassRot = ct->rot;
double compassRotA = ct->rota;
ct->rot = 0;
ct->rota = 0;
ct->updateFromPosition(entity->level, entity->x, entity->z,
Mth::wrapDegrees(static_cast<float>(180 + entity->dir * 90)), false, true);
ct->rot = compassRot;
ct->rota = compassRotA;
}
glPopMatrix(); EntityRenderDispatcher::instance->render(itemEntity, 0, 0, 0, 0, 0, true);
if (itemEntity->getItem()->getItem() == Item::compass)
{
CompassTexture *ct = CompassTexture::instance;
ct->cycleFrames();
}
}
glPopMatrix();
} }

View file

@ -1268,6 +1268,8 @@ void Minecraft::applyFrameMouseLook()
void Minecraft::run_middle() void Minecraft::run_middle()
{ {
pause = app.IsAppPaused();
static int64_t lastTime = 0; static int64_t lastTime = 0;
static bool bFirstTimeIntoGame = true; static bool bFirstTimeIntoGame = true;
static bool bAutosaveTimerSet=false; static bool bAutosaveTimerSet=false;

View file

@ -1848,7 +1848,7 @@ void MinecraftServer::run(int64_t seed, void *lpParameter)
lastTime = now; lastTime = now;
// 4J Added ability to pause the server // 4J Added ability to pause the server
if( !m_isServerPaused ) if( !m_isServerPaused && !app.IsAppPaused() )
{ {
bool didTick = false; bool didTick = false;
if (levels[0]->allPlayersAreSleeping()) if (levels[0]->allPlayersAreSleeping())

View file

@ -266,7 +266,7 @@ private:
#endif #endif
#endif #endif
bool IsServerPaused() { return m_isServerPaused; }
private: private:
// 4J Added // 4J Added
@ -291,6 +291,7 @@ public:
const wstring& getSaveFolderName() const { return m_saveFolderName; } const wstring& getSaveFolderName() const { return m_saveFolderName; }
void Suspend(); void Suspend();
bool IsSuspending(); bool IsSuspending();
bool IsServerPaused() { return m_isServerPaused; }
// 4J Stu - A load of functions were all added in 1.0.1 in the ServerInterface, but I don't think we need any of them // 4J Stu - A load of functions were all added in 1.0.1 in the ServerInterface, but I don't think we need any of them
}; };

View file

@ -15,8 +15,8 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
XZSIZE = level->dimension->getXZSize(); // 4J Added XZSIZE = level->dimension->getXZSize(); // 4J Added
XZOFFSET = XZSIZE/2; // 4J Added XZOFFSET = XZSIZE/2; // 4J Added
m_XZSize = XZSIZE; m_XZSize = XZSIZE;
hasData = new bool[XZSIZE * XZSIZE]; hasData = new bool[LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH];
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE); memset(hasData, 0, sizeof(bool) * LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH);
emptyChunk = new EmptyLevelChunk(level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0); emptyChunk = new EmptyLevelChunk(level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0);
@ -93,8 +93,8 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
this->level = level; this->level = level;
this->cache = new LevelChunk *[XZSIZE * XZSIZE]; this->cache = new LevelChunk *[LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH];
memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk *)); memset(this->cache, 0, sizeof(LevelChunk*) * LEVEL_MIN_WIDTH * LEVEL_MIN_WIDTH);
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate,4000); InitializeCriticalSectionAndSpinCount(&m_csLoadCreate,4000);
} }
@ -129,10 +129,11 @@ bool MultiPlayerChunkCache::reallyHasChunk(int x, int z)
// Check we're in range of the stored level - if we aren't, then consider that we do have that chunk as we'll be able to use the water chunk there // Check we're in range of the stored level - if we aren't, then consider that we do have that chunk as we'll be able to use the water chunk there
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return true; if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return true;
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true; if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true;
int idx = ix * XZSIZE + iz;
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
LevelChunk *chunk = cache[idx]; LevelChunk *chunk = cache[idx];
if( chunk == nullptr ) if (chunk == nullptr || chunk->x != x || chunk->z != z)
{ {
return false; return false;
} }
@ -145,10 +146,11 @@ void MultiPlayerChunkCache::drop(const int x, const int z)
const int iz = z + XZOFFSET; const int iz = z + XZOFFSET;
if ((ix < 0) || (ix >= XZSIZE)) return; if ((ix < 0) || (ix >= XZSIZE)) return;
if ((iz < 0) || (iz >= XZSIZE)) return; if ((iz < 0) || (iz >= XZSIZE)) return;
const int idx = ix * XZSIZE + iz;
int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
LevelChunk* chunk = cache[idx]; LevelChunk* chunk = cache[idx];
if (chunk != nullptr && !chunk->isEmpty()) if (chunk != nullptr && !chunk->isEmpty() && chunk->x == x && chunk->z == z)
{ {
// Drop entities in the chunks, especially for the case when a player is dead // Drop entities in the chunks, especially for the case when a player is dead
// as they will not get the RemoveEntity packet if an entity is removed. // as they will not get the RemoveEntity packet if an entity is removed.
@ -168,11 +170,12 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z)
// Check we're in range of the stored level // Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk ); if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk ); if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
int idx = ix * XZSIZE + iz; int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
LevelChunk *chunk = cache[idx]; LevelChunk *chunk = cache[idx];
LevelChunk *lastChunk = chunk; LevelChunk *lastChunk = chunk;
if( chunk == nullptr ) if( chunk == nullptr || chunk->x != x || chunk->z != z )
{ {
EnterCriticalSection(&m_csLoadCreate); EnterCriticalSection(&m_csLoadCreate);
@ -251,10 +254,10 @@ LevelChunk *MultiPlayerChunkCache::getChunk(int x, int z)
// Check we're in range of the stored level // Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk ); if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk ); if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
int idx = ix * XZSIZE + iz; int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
LevelChunk *chunk = cache[idx]; LevelChunk *chunk = cache[idx];
if( chunk == nullptr ) if( chunk == nullptr || chunk->x != x || chunk->z != z )
{ {
return emptyChunk; return emptyChunk;
} }
@ -313,6 +316,6 @@ void MultiPlayerChunkCache::dataReceived(int x, int z)
// Check we're in range of the stored level // Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return; if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return;
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return; if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return;
int idx = ix * XZSIZE + iz; int idx = wrapCoord(x, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + wrapCoord(z, LEVEL_MIN_WIDTH);
hasData[idx] = true; hasData[idx] = true;
} }

View file

@ -45,4 +45,9 @@ public:
virtual void dataReceived(int x, int z); // 4J added virtual void dataReceived(int x, int z); // 4J added
virtual LevelChunk **getCache() { return cache; } // 4J added virtual LevelChunk **getCache() { return cache; } // 4J added
static inline int wrapCoord(int v, int size) {
int r = v % size;
return (r < 0) ? r + size : r;
}
}; };

View file

@ -183,7 +183,7 @@ void PlayerConnection::tick()
// Ensure server-side player tick runs even when no move packet was received this tick. // Ensure server-side player tick runs even when no move packet was received this tick.
// Without this, environmental damage (drowning, fire, lava) is never applied to clients // Without this, environmental damage (drowning, fire, lava) is never applied to clients
// that don't send frequent move packets. // that don't send frequent move packets.
if (!didTick && player != nullptr) if (!didTick && player != nullptr && !server->IsServerPaused() && !app.IsAppPaused())
{ {
player->doTick(false); player->doTick(false);
} }
@ -2417,7 +2417,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
player->inventory->setItem(player->inventory->selected, sentItem); player->inventory->setItem(player->inventory->selected, sentItem);
} }
} }
else if (CustomPayloadPacket::QUICK_EQUIP_PACKET.compare(customPayloadPacket->identifier) == 0) { /*else if (CustomPayloadPacket::QUICK_EQUIP_PACKET.compare(customPayloadPacket->identifier) == 0) {
//ByteArrayInputStream bais(customPayloadPacket->data); //ByteArrayInputStream bais(customPayloadPacket->data);
//DataInputStream input(&bais); //DataInputStream input(&bais);
//shared_ptr<ItemInstance> sentItem = Packet::readItem(&input); //shared_ptr<ItemInstance> sentItem = Packet::readItem(&input);
@ -2448,7 +2448,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
//PlayerList* playerList = MinecraftServer::getInstance()->getPlayers(); //PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
//playerList->broadcastAll(std::make_shared<SetEquippedItemPacket>(player->entityId, slot, sentItem)); //playerList->broadcastAll(std::make_shared<SetEquippedItemPacket>(player->entityId, slot, sentItem));
} }*/
else if (CustomPayloadPacket::TRADER_SELECTION_PACKET.compare(customPayloadPacket->identifier) == 0) else if (CustomPayloadPacket::TRADER_SELECTION_PACKET.compare(customPayloadPacket->identifier) == 0)
{ {
ByteArrayInputStream bais(customPayloadPacket->data); ByteArrayInputStream bais(customPayloadPacket->data);

View file

@ -37,6 +37,8 @@
#include "Common/Network/Sony/NetworkPlayerSony.h" #include "Common/Network/Sony/NetworkPlayerSony.h"
#endif #endif
#include "../Minecraft.World/Recipes.h"
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) #if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include "../Minecraft.Server/Access/Access.h" #include "../Minecraft.Server/Access/Access.h"
#include "../Minecraft.Server/Common/StringUtils.h" #include "../Minecraft.Server/Common/StringUtils.h"
@ -51,6 +53,7 @@ extern bool g_Win64DedicatedServer;
static unsigned int s_playerListTickCount = 0; static unsigned int s_playerListTickCount = 0;
static const int kIdentityResponseGraceTicks = 200; // 10 seconds at 20 TPS static const int kIdentityResponseGraceTicks = 200; // 10 seconds at 20 TPS
#endif #endif
#include "../Minecraft.Client/Common/UI/IUIScene_CreativeMenu.h"
// 4J - this class is fairly substantially altered as there didn't seem any point in porting code for banning, whitelisting, ops etc. // 4J - this class is fairly substantially altered as there didn't seem any point in porting code for banning, whitelisting, ops etc.
@ -300,6 +303,9 @@ bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
app.DebugPrintf("RECONNECT: placeNewPlayer smallId=%d entityId=%d dim=%d\n", app.DebugPrintf("RECONNECT: placeNewPlayer smallId=%d entityId=%d dim=%d\n",
newSmallId, player->entityId, level->dimension->id); newSmallId, player->entityId, level->dimension->id);
playerConnection->send(Recipes::getInstance()->createUpdatePacket());
playerConnection->send(IUIScene_CreativeMenu::createUpdatePacket());
playerConnection->send(std::make_shared<LoginPacket>(L"", player->entityId, level->getLevelData()->getGenerator(), playerConnection->send(std::make_shared<LoginPacket>(L"", player->entityId, level->getLevelData()->getGenerator(),
level->getSeed(), level->getSeed(),
player->gameMode->getGameModeForPlayer()->getId(), player->gameMode->getGameModeForPlayer()->getId(),

View file

@ -390,6 +390,20 @@ float KeyboardMouseInput::GetLookY(float sensitivity) const
return static_cast<float>(-m_mouseDeltaY) * sensitivity; return static_cast<float>(-m_mouseDeltaY) * sensitivity;
} }
void KeyboardMouseInput::SetCursorIcon(LPCWSTR cursorName)
{
HCURSOR hCursor = LoadCursorW(nullptr, cursorName);
if (hCursor)
{
SetCursor(hCursor);
if (g_hWnd)
{
SetClassLongPtrW(g_hWnd, GCLP_HCURSOR, (LONG_PTR)hCursor);
}
}
}
void KeyboardMouseInput::OnChar(wchar_t c) void KeyboardMouseInput::OnChar(wchar_t c)
{ {
int next = (m_charBufferHead + 1) % CHAR_BUFFER_SIZE; int next = (m_charBufferHead + 1) % CHAR_BUFFER_SIZE;

View file

@ -104,6 +104,8 @@ public:
float GetLookX(float sensitivity) const; float GetLookX(float sensitivity) const;
float GetLookY(float sensitivity) const; float GetLookY(float sensitivity) const;
void SetCursorIcon(LPCWSTR cursorName);
private: private:
bool m_keyDown[MAX_KEYS]; bool m_keyDown[MAX_KEYS];
bool m_keyDownPrev[MAX_KEYS]; bool m_keyDownPrev[MAX_KEYS];

View file

@ -115,6 +115,7 @@ bool WinsockNetLayer::s_clientKeyStored = false;
bool g_Win64MultiplayerHost = false; bool g_Win64MultiplayerHost = false;
bool g_Win64MultiplayerJoin = false; bool g_Win64MultiplayerJoin = false;
bool g_Win64MultiplayerQuitOnDisconnect = false;
int g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT; int g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT;
char g_Win64MultiplayerIP[256] = "127.0.0.1"; char g_Win64MultiplayerIP[256] = "127.0.0.1";
bool g_Win64DedicatedServer = false; bool g_Win64DedicatedServer = false;

View file

@ -227,6 +227,7 @@ public:
extern bool g_Win64MultiplayerHost; extern bool g_Win64MultiplayerHost;
extern bool g_Win64MultiplayerJoin; extern bool g_Win64MultiplayerJoin;
extern bool g_Win64MultiplayerQuitOnDisconnect;
extern int g_Win64MultiplayerPort; extern int g_Win64MultiplayerPort;
extern char g_Win64MultiplayerIP[256]; extern char g_Win64MultiplayerIP[256];
extern bool g_Win64DedicatedServer; extern bool g_Win64DedicatedServer;

View file

@ -219,6 +219,7 @@ static Win64LaunchOptions ParseLaunchOptions()
Win64LaunchOptions options = {}; Win64LaunchOptions options = {};
options.screenMode = 0; options.screenMode = 0;
g_Win64MultiplayerQuitOnDisconnect = false;
g_Win64MultiplayerJoin = false; g_Win64MultiplayerJoin = false;
g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT; g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT;
@ -239,6 +240,10 @@ static Win64LaunchOptions ParseLaunchOptions()
{ {
CopyWideArgToAnsi(argv[++i], g_Win64Username, sizeof(g_Win64Username)); CopyWideArgToAnsi(argv[++i], g_Win64Username, sizeof(g_Win64Username));
} }
else if (_wcsicmp(argv[i], L"-quitondisconnect") == 0)
{
g_Win64MultiplayerQuitOnDisconnect = true;
}
else if (_wcsicmp(argv[i], L"-ip") == 0 && (i + 1) < argc) else if (_wcsicmp(argv[i], L"-ip") == 0 && (i + 1) < argc)
{ {
char ipBuf[256]; char ipBuf[256];
@ -1760,8 +1765,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
} }
g_bResizeReady = true; g_bResizeReady = true;
ui.ReloadSkin();
//app.TemporaryCreateGameStart(); //app.TemporaryCreateGameStart();
//Sleep(10000); //Sleep(10000);

View file

@ -9152,7 +9152,7 @@ All Ender Chests in a world are linked. Items placed into an Ender Chest are acc
</data> </data>
<data name="IDS_ITEM_RABBIT_STEW"> <data name="IDS_ITEM_RABBIT_STEW">
<value>{*ICON_SHANK_01*}</value> <value>Rabbit Stew</value>
</data> </data>
<data name="IDS_TILE_DOUBLE_TALL_GRASS"> <data name="IDS_TILE_DOUBLE_TALL_GRASS">
@ -9622,4 +9622,8 @@ All Ender Chests in a world are linked. Items placed into an Ender Chest are acc
<data name="IDS_ACHIEVEMENT_VIEW"><value>Hold {*CONTROLLER_VK_Y*} to view</value></data> <data name="IDS_ACHIEVEMENT_VIEW"><value>Hold {*CONTROLLER_VK_Y*} to view</value></data>
<data name="IDS_CHECKBOX_CLASSICCRAFTING"><value>Classic Crafting</value></data> <data name="IDS_CHECKBOX_CLASSICCRAFTING"><value>Classic Crafting</value></data>
<data name="IDS_DESC_RABBIT_STEW">
<value>Restores 5{*ICON_SHANK_01*}.</value>
</data>
</root> </root>

View file

@ -628,6 +628,8 @@ static std::string WorldSizeToPropertyValue(int worldSize)
return "medium"; return "medium";
case e_worldSize_Large: case e_worldSize_Large:
return "large"; return "large";
case e_worldSize_Expanded:
return "expanded";
case e_worldSize_Classic: case e_worldSize_Classic:
default: default:
return "classic"; return "classic";
@ -644,6 +646,8 @@ static int WorldSizeToXzChunks(int worldSize)
return LEVEL_WIDTH_MEDIUM; return LEVEL_WIDTH_MEDIUM;
case e_worldSize_Large: case e_worldSize_Large:
return LEVEL_WIDTH_LARGE; return LEVEL_WIDTH_LARGE;
case e_worldSize_Expanded:
return LEVEL_WIDTH_EXPANDED;
case e_worldSize_Classic: case e_worldSize_Classic:
default: default:
return LEVEL_WIDTH_CLASSIC; return LEVEL_WIDTH_CLASSIC;
@ -659,6 +663,7 @@ static int WorldSizeToHellScale(int worldSize)
case e_worldSize_Medium: case e_worldSize_Medium:
return HELL_LEVEL_SCALE_MEDIUM; return HELL_LEVEL_SCALE_MEDIUM;
case e_worldSize_Large: case e_worldSize_Large:
case e_worldSize_Expanded:
return HELL_LEVEL_SCALE_LARGE; return HELL_LEVEL_SCALE_LARGE;
case e_worldSize_Classic: case e_worldSize_Classic:
default: default:
@ -694,6 +699,12 @@ static bool TryParseWorldSize(const std::string &lowered, int *outWorldSize)
return true; return true;
} }
if (lowered == "expanded" || lowered == "344" || lowered == "8")
{
*outWorldSize = e_worldSize_Expanded;
return true;
}
return false; return false;
} }

View file

@ -54,7 +54,7 @@ AddEntityPacket::AddEntityPacket(shared_ptr<Entity> e, int type, int data, int y
void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J JEV add throws statement void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J JEV add throws statement
{ {
id = dis->readShort(); id = dis->readInt();
type = dis->readByte(); type = dis->readByte();
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
x = dis->readInt(); x = dis->readInt();
@ -78,7 +78,7 @@ void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J
void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J JEV add throws statement void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J JEV add throws statement
{ {
dos->writeShort(id); dos->writeInt(id);
dos->writeByte(type); dos->writeByte(type);
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
dos->writeInt(x); dos->writeInt(x);
@ -107,5 +107,5 @@ void AddEntityPacket::handle(PacketListener *listener)
int AddEntityPacket::getEstimatedSize() int AddEntityPacket::getEstimatedSize()
{ {
return 11 + data > -1 ? 6 : 0; return (11 + data > -1 ? 6 : 0) + 2;
} }

View file

@ -66,7 +66,7 @@ AddMobPacket::AddMobPacket(shared_ptr<LivingEntity> mob, int yRotp, int xRotp, i
void AddMobPacket::read(DataInputStream *dis) //throws IOException void AddMobPacket::read(DataInputStream *dis) //throws IOException
{ {
id = dis->readShort(); id = dis->readInt();
type = dis->readByte() & 0xff; type = dis->readByte() & 0xff;
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
x = dis->readInt(); x = dis->readInt();
@ -90,7 +90,7 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException
void AddMobPacket::write(DataOutputStream *dos) //throws IOException void AddMobPacket::write(DataOutputStream *dos) //throws IOException
{ {
dos->writeShort(id); dos->writeInt(id);
dos->writeByte(type & 0xff); dos->writeByte(type & 0xff);
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
dos->writeInt(x); dos->writeInt(x);
@ -127,7 +127,7 @@ int AddMobPacket::getEstimatedSize()
// 4J Stu - This is an incoming value which we aren't currently analysing // 4J Stu - This is an incoming value which we aren't currently analysing
//size += unpack->get //size += unpack->get
} }
return size; return size + 2;
} }
vector<shared_ptr<SynchedEntityData::DataItem> > *AddMobPacket::getUnpackedData() vector<shared_ptr<SynchedEntityData::DataItem> > *AddMobPacket::getUnpackedData()

View file

@ -7,12 +7,14 @@ class TilePos;
// The maximum number of chunks that we can store // The maximum number of chunks that we can store
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
// 4J Stu - Our default map (at zoom level 3) is 1024x1024 blocks (or 64 chunks) // 4J Stu - Our default map (at zoom level 3) is 1024x1024 blocks (or 64 chunks)
#define LEVEL_MAX_WIDTH (5*64) //(6*54)
#define LEVEL_WIDTH_CLASSIC 54 #define LEVEL_WIDTH_CLASSIC 54
#define LEVEL_WIDTH_SMALL 64 #define LEVEL_WIDTH_SMALL 64
#define LEVEL_WIDTH_MEDIUM (3*64) #define LEVEL_WIDTH_MEDIUM (3*64)
#define LEVEL_WIDTH_LARGE (5*64) #define LEVEL_WIDTH_LARGE (5*64)
#define LEVEL_WIDTH_EXPANDED (5*64) + 24
#define LEVEL_MAX_WIDTH LEVEL_WIDTH_EXPANDED
#else #else
#define LEVEL_MAX_WIDTH 54 #define LEVEL_MAX_WIDTH 54

View file

@ -1,4 +1,4 @@
#include "stdafx.h" #include "stdafx.h"
#include "net.minecraft.world.item.h" #include "net.minecraft.world.item.h"
#include "net.minecraft.world.level.h" #include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.redstone.h" #include "net.minecraft.world.level.redstone.h"
@ -134,33 +134,42 @@ bool ComparatorTile::shouldTurnOn(Level *level, int x, int y, int z, int data)
int ComparatorTile::getInputSignal(Level *level, int x, int y, int z, int data) int ComparatorTile::getInputSignal(Level *level, int x, int y, int z, int data)
{ {
int result = DiodeTile::getInputSignal(level, x, y, z, data); int result = DiodeTile::getInputSignal(level, x, y, z, data);
int dir = getDirection(data); int dir = getDirection(data);
int xx = x + Direction::STEP_X[dir]; int xx = x + Direction::STEP_X[dir];
int zz = z + Direction::STEP_Z[dir]; int zz = z + Direction::STEP_Z[dir];
int tile = level->getTile(xx, y, zz); int tile = level->getTile(xx, y, zz);
if (tile > 0) if (tile > 0)
{ {
if (Tile::tiles[tile]->hasAnalogOutputSignal()) if (Tile::tiles[tile]->hasAnalogOutputSignal())
{ {
result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]); result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]);
} }
else if (result < Redstone::SIGNAL_MAX && Tile::isSolidBlockingTile(tile)) else if (result < Redstone::SIGNAL_MAX && Tile::isSolidBlockingTile(tile))
{ {
xx += Direction::STEP_X[dir]; xx += Direction::STEP_X[dir];
zz += Direction::STEP_Z[dir]; zz += Direction::STEP_Z[dir];
tile = level->getTile(xx, y, zz); tile = level->getTile(xx, y, zz);
if (tile > 0 && Tile::tiles[tile]->hasAnalogOutputSignal()) if (tile > 0 && Tile::tiles[tile]->hasAnalogOutputSignal())
{ {
result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]); result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]);
} }
}
}
return result; else if (tile == 0)
{
shared_ptr<ItemFrame> frame = getItemFrame(level, xx, y, zz);
if (frame != nullptr)
{
result = frame->getAnalogOutput();
}
}
}
}
return result;
} }
shared_ptr<ComparatorTileEntity> ComparatorTile::getComparator(LevelSource *level, int x, int y, int z) shared_ptr<ComparatorTileEntity> ComparatorTile::getComparator(LevelSource *level, int x, int y, int z)
@ -278,3 +287,27 @@ bool ComparatorTile::TestUse()
{ {
return true; return true;
} }
shared_ptr<ItemFrame> ComparatorTile::getItemFrame(
Level* level,
int x,
int y,
int z)
{
AABB* box = AABB::newTemp(
x,
y,
z,
x + 1,
y + 1,
z + 1
);
vector<shared_ptr<Entity>>* entities =
level->getEntitiesOfClass(typeid(ItemFrame), box);
if (entities == nullptr || entities->size() != 1)
return nullptr;
return dynamic_pointer_cast<ItemFrame>((*entities)[0]);
}

View file

@ -2,6 +2,7 @@
#include "DiodeTile.h" #include "DiodeTile.h"
#include "EntityTile.h" #include "EntityTile.h"
#include "AABB.h"
class ComparatorTileEntity; class ComparatorTileEntity;
@ -62,4 +63,5 @@ public:
virtual bool triggerEvent(Level *level, int x, int y, int z, int b0, int b1); virtual bool triggerEvent(Level *level, int x, int y, int z, int b0, int b1);
virtual shared_ptr<TileEntity> newTileEntity(Level *level); virtual shared_ptr<TileEntity> newTileEntity(Level *level);
virtual bool TestUse(); virtual bool TestUse();
shared_ptr<ItemFrame> ComparatorTile::getItemFrame(Level* level,int x,int y,int z);
}; };

View file

@ -26,6 +26,7 @@ void Creeper::_init()
oldSwell = 0; oldSwell = 0;
maxSwell = 30; maxSwell = 30;
explosionRadius = 3; explosionRadius = 3;
ignited = false;
} }
Creeper::Creeper(Level *level) : Monster( level ) Creeper::Creeper(Level *level) : Monster( level )
@ -190,3 +191,38 @@ void Creeper::thunderHit(const LightningBolt *lightningBolt)
Monster::thunderHit(lightningBolt); Monster::thunderHit(lightningBolt);
entityData->set(DATA_IS_POWERED, static_cast<byte>(1)); entityData->set(DATA_IS_POWERED, static_cast<byte>(1));
} }
void Creeper::Ignite()
{
setSwellDir(1);
ignited = true;
}
bool Creeper::isIgnited()
{
return ignited;
}
bool Creeper::mobInteract(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
if (item == nullptr || item->id != Item::flintAndSteel_Id)
return Mob::mobInteract(player);
playSound(eSoundType_FIRE_NEWIGNITE, 1, random->nextFloat() * 0.4f + 0.8f);
player->swing();
if (!level->isClientSide)
{
if (!isIgnited())
{
Ignite();
item->hurtAndBreak(1, player);
return true;
}
return Mob::mobInteract(player);
}
return true;
}

View file

@ -21,6 +21,8 @@ private:
int maxSwell; int maxSwell;
int explosionRadius; int explosionRadius;
bool ignited;
void _init(); void _init();
public: public:
@ -34,6 +36,8 @@ public:
virtual int getMaxFallDistance(); virtual int getMaxFallDistance();
virtual bool mobInteract(shared_ptr<Player> player);
protected: protected:
virtual void causeFallDamage(float distance); virtual void causeFallDamage(float distance);
virtual void defineSynchedData(); virtual void defineSynchedData();
@ -61,5 +65,9 @@ protected:
public: public:
int getSwellDir(); int getSwellDir();
void setSwellDir(int dir); void setSwellDir(int dir);
void thunderHit(const LightningBolt *lightningBolt) ; void thunderHit(const LightningBolt *lightningBolt);
public:
void Ignite();
bool isIgnited();
}; };

View file

@ -5,30 +5,39 @@
#include "CustomPayloadPacket.h" #include "CustomPayloadPacket.h"
// Mojang-defined custom packets // Mojang-defined custom packets
const wstring CustomPayloadPacket::CUSTOM_BOOK_PACKET = L"MC|BEdit"; const wstring CustomPayloadPacket::CUSTOM_BOOK_PACKET = CreateVanillaPayloadKey(L"BEdit");
const wstring CustomPayloadPacket::CUSTOM_BOOK_SIGN_PACKET = L"MC|BSign"; const wstring CustomPayloadPacket::CUSTOM_BOOK_SIGN_PACKET = CreateVanillaPayloadKey(L"BSign");
const wstring CustomPayloadPacket::TEXTURE_PACK_PACKET = L"MC|TPack"; const wstring CustomPayloadPacket::TEXTURE_PACK_PACKET = CreateVanillaPayloadKey(L"TPack");
const wstring CustomPayloadPacket::TRADER_LIST_PACKET = L"MC|TrList"; const wstring CustomPayloadPacket::TRADER_LIST_PACKET = CreateVanillaPayloadKey(L"TrList");
const wstring CustomPayloadPacket::TRADER_SELECTION_PACKET = L"MC|TrSel"; const wstring CustomPayloadPacket::TRADER_SELECTION_PACKET = CreateVanillaPayloadKey(L"TrSel");
const wstring CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET = L"MC|AdvCdm";
const wstring CustomPayloadPacket::SET_BEACON_PACKET = L"MC|Beacon";
const wstring CustomPayloadPacket::SET_ITEM_NAME_PACKET = L"MC|ItemName";
const wstring CustomPayloadPacket::CIPHER_KEY_CHANNEL = L"MC|CKey"; // neoLegacy-defined custom packets
const wstring CustomPayloadPacket::CIPHER_ACK_CHANNEL = L"MC|CAck"; const wstring CustomPayloadPacket::UPDATE_RECIPE_REGISTRY = CreatePayloadKey(L"neo", L"UpdRReg");
const wstring CustomPayloadPacket::CIPHER_ON_CHANNEL = L"MC|COn"; const wstring CustomPayloadPacket::UPDATE_CREATIVE_REGISTRY = CreatePayloadKey(L"neo", L"UpdCReg");
const wstring CustomPayloadPacket::IDENTITY_TOKEN_ISSUE = L"MC|CTIssue"; //todo: figure out if we should replace the packets in the comment section with a custom payload identifier
const wstring CustomPayloadPacket::IDENTITY_TOKEN_CHALLENGE = L"MC|CTChallenge"; //comment section start
const wstring CustomPayloadPacket::IDENTITY_TOKEN_RESPONSE = L"MC|CTResponse"; const wstring CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET = CreateVanillaPayloadKey(L"AdvCdm");
const wstring CustomPayloadPacket::SET_BEACON_PACKET = CreateVanillaPayloadKey(L"Beacon");
const wstring CustomPayloadPacket::SET_ITEM_NAME_PACKET = CreateVanillaPayloadKey(L"ItemName");
const wstring CustomPayloadPacket::FORK_HELLO_CHANNEL = L"MC|ForkHello"; const wstring CustomPayloadPacket::CIPHER_KEY_CHANNEL = CreateVanillaPayloadKey(L"CKey");
const wstring CustomPayloadPacket::FORK_PLAYER_LEAVE_CHANNEL = L"MC|ForkPLeave"; const wstring CustomPayloadPacket::CIPHER_ACK_CHANNEL = CreateVanillaPayloadKey(L"CAck");
const wstring CustomPayloadPacket::CIPHER_ON_CHANNEL = CreateVanillaPayloadKey(L"COn");
const wstring CustomPayloadPacket::QUICK_EQUIP_PACKET = L"MC|QEquip"; const wstring CustomPayloadPacket::IDENTITY_TOKEN_ISSUE = CreateVanillaPayloadKey(L"CTIssue");
const wstring CustomPayloadPacket::QUICK_EQUIP_SERVER_PACKET = L"MC|QEquipServer"; const wstring CustomPayloadPacket::IDENTITY_TOKEN_CHALLENGE = CreateVanillaPayloadKey(L"CTChallenge");
const wstring CustomPayloadPacket::IDENTITY_TOKEN_RESPONSE = CreateVanillaPayloadKey(L"CTResponse");
const wstring CustomPayloadPacket::ENCHANTMENT_LIST_PACKET = L"MC|EnchList"; const wstring CustomPayloadPacket::FORK_HELLO_CHANNEL = CreateVanillaPayloadKey(L"ForkHello");
const wstring CustomPayloadPacket::FORK_PLAYER_LEAVE_CHANNEL = CreateVanillaPayloadKey(L"ForkPLeave");
const wstring CustomPayloadPacket::ENCHANTMENT_LIST_PACKET = CreateVanillaPayloadKey(L"EnchList");
//comment section end
//removed cause its now handled on the server side
// const wstring CustomPayloadPacket::QUICK_EQUIP_PACKET = CreateVanillaPayloadKey(L"QEquip");
// const wstring CustomPayloadPacket::QUICK_EQUIP_SERVER_PACKET = CreateVanillaPayloadKey(L"QEquipServer");
CustomPayloadPacket::CustomPayloadPacket() CustomPayloadPacket::CustomPayloadPacket()
: length(0) : length(0)

View file

@ -3,6 +3,9 @@ using namespace std;
#include "Packet.h" #include "Packet.h"
#define CreatePayloadKey(identifier, action) identifier L"|" action
#define CreateVanillaPayloadKey(action) CreatePayloadKey(L"MC", action)
class CustomPayloadPacket : public Packet, public enable_shared_from_this<CustomPayloadPacket> class CustomPayloadPacket : public Packet, public enable_shared_from_this<CustomPayloadPacket>
{ {
public: public:
@ -17,6 +20,10 @@ public:
static const wstring SET_BEACON_PACKET; static const wstring SET_BEACON_PACKET;
static const wstring SET_ITEM_NAME_PACKET; static const wstring SET_ITEM_NAME_PACKET;
// neoLegacy-defined custom packets
static const wstring UPDATE_RECIPE_REGISTRY;
static const wstring UPDATE_CREATIVE_REGISTRY;
// Security: stream cipher handshake channels // Security: stream cipher handshake channels
static const wstring CIPHER_KEY_CHANNEL; // server->client: carries 32-byte key (16 AES key + 16 IV) static const wstring CIPHER_KEY_CHANNEL; // server->client: carries 32-byte key (16 AES key + 16 IV)
static const wstring CIPHER_ACK_CHANNEL; // client->server: ack (empty payload) static const wstring CIPHER_ACK_CHANNEL; // client->server: ack (empty payload)
@ -32,8 +39,8 @@ public:
static const wstring FORK_PLAYER_LEAVE_CHANNEL; // server->client: player disconnected (payload: UTF gamertag) static const wstring FORK_PLAYER_LEAVE_CHANNEL; // server->client: player disconnected (payload: UTF gamertag)
// Fixes for MP related crashes // Fixes for MP related crashes
static const wstring QUICK_EQUIP_PACKET; //static const wstring QUICK_EQUIP_PACKET;
static const wstring QUICK_EQUIP_SERVER_PACKET; //static const wstring QUICK_EQUIP_SERVER_PACKET;
static const wstring ENCHANTMENT_LIST_PACKET; static const wstring ENCHANTMENT_LIST_PACKET;

View file

@ -42,8 +42,20 @@ Icon* DirtTile::getTexture(int face, int data)
if (data < 0 || data >= DIRT_NAMES_LENGTH) if (data < 0 || data >= DIRT_NAMES_LENGTH)
data = 0; data = 0;
if (TEXTURE_NAMES[data] == L"dirt_podzol") { if (TEXTURE_NAMES[data] == L"dirt_podzol")
return (face == Facing::UP) ? podzolTop : podzolSide; {
switch(face)
{
case Facing::UP:
return podzolTop;
break;
case Facing::DOWN:
return Tile::dirt->getTexture(face);
break;
default:
return podzolSide;
break;
}
} }
return icons[data]; return icons[data];

View file

@ -6,13 +6,13 @@
#include "net.minecraft.world.item.h" #include "net.minecraft.world.item.h"
#include "net.minecraft.world.item.enchantment.h" #include "net.minecraft.world.item.enchantment.h"
#include "EnchantmentMenu.h" #include "EnchantmentMenu.h"
#include "../../../Minecraft.Client/ServerPlayer.h" #include "../Minecraft.Client/ServerPlayer.h"
#include "../../../Minecraft.Client/MinecraftServer.h" #include "../Minecraft.Client/MinecraftServer.h"
#include "../../../Minecraft.Client/PlayerList.h" #include "../Minecraft.Client/PlayerList.h"
#include "../../../Minecraft.Client/MultiPlayerLocalPlayer.h" #include "../Minecraft.Client/MultiPlayerLocalPlayer.h"
#include "../../../Minecraft.Client/PlayerConnection.h" #include "../Minecraft.Client/PlayerConnection.h"
#include "../../../Minecraft.World/CustomPayloadPacket.h" #include "../Minecraft.World/CustomPayloadPacket.h"
#include "../../../Minecraft.Client/Minecraft.h" #include "../Minecraft.Client/Minecraft.h"
EnchantmentMenu::EnchantmentMenu(shared_ptr<Inventory> inventory, Level *level, int xt, int yt, int zt) EnchantmentMenu::EnchantmentMenu(shared_ptr<Inventory> inventory, Level *level, int xt, int yt, int zt)
{ {

View file

@ -43,4 +43,8 @@ public:
// 4J Added // 4J Added
static void updatePossibleRecipes(shared_ptr<CraftingContainer> craftSlots, bool *firework, bool *charge, bool *fade); static void updatePossibleRecipes(shared_ptr<CraftingContainer> craftSlots, bool *firework, bool *charge, bool *fade);
static bool isValidIngredient(shared_ptr<ItemInstance> item, bool firework, bool charge, bool fade); static bool isValidIngredient(shared_ptr<ItemInstance> item, bool firework, bool charge, bool fade);
virtual void writeToStream(DataOutputStream* dos) {
dos->writeByte(99);
}
}; };

View file

@ -10,7 +10,8 @@
#include "net.minecraft.world.level.saveddata.h" #include "net.minecraft.world.level.saveddata.h"
#include "com.mojang.nbt.h" #include "com.mojang.nbt.h"
#include "ItemFrame.h" #include "ItemFrame.h"
#include "DamageSource.h"
#include "Level.h"
@ -87,29 +88,52 @@ shared_ptr<ItemInstance> ItemFrame::getItem()
return getEntityData()->getItemInstance(DATA_ITEM); return getEntityData()->getItemInstance(DATA_ITEM);
} }
void ItemFrame::setItem(shared_ptr<ItemInstance> item, bool notifyNeighbors)
{
if (item != nullptr)
{
item = item->copy();
item->count = 1;
item->setFramed(dynamic_pointer_cast<ItemFrame>(shared_from_this()));
}
getEntityData()->set(DATA_ITEM, item);
getEntityData()->markDirty(DATA_ITEM);
if (notifyNeighbors)
{
level->updateNeighbourForOutputSignal(xTile, yTile, zTile, Tile::comparator_off->id);
}
}
void ItemFrame::setItem(shared_ptr<ItemInstance> item) void ItemFrame::setItem(shared_ptr<ItemInstance> item)
{ {
if(item != nullptr) setItem(item, true);
{
item = item->copy();
item->count = 1;
item->setFramed(dynamic_pointer_cast<ItemFrame>( shared_from_this() ));
}
getEntityData()->set(DATA_ITEM, item);
getEntityData()->markDirty(DATA_ITEM);
} }
int ItemFrame::getRotation() int ItemFrame::getRotation()
{ {
return getEntityData()->getByte(DATA_ROTATION); return getEntityData()->getByte(DATA_ROTATION);
}
void ItemFrame::setRotation(int rotation, bool notifyNeighbors)
{
getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 8));
if (notifyNeighbors)
{
level->updateNeighbourForOutputSignal(xTile, yTile, zTile, Tile::comparator_off->id);
}
} }
void ItemFrame::setRotation(int rotation) void ItemFrame::setRotation(int rotation)
{ {
getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 8));
getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 8));
level->updateNeighbourForOutputSignal(xTile, yTile, zTile, Tile::comparator_off->id);
} }
void ItemFrame::addAdditonalSaveData(CompoundTag *tag) void ItemFrame::addAdditonalSaveData(CompoundTag *tag)
{ {
if (getItem() != nullptr) if (getItem() != nullptr)
@ -171,3 +195,54 @@ bool ItemFrame::interact(shared_ptr<Player> player)
return true; return true;
} }
bool ItemFrame::hurt(DamageSource *source, float damage)
{
if (level->isClientSide) return false;
shared_ptr<ItemInstance> item = getItem();
if (!source->isExplosion() && item != nullptr)
{
shared_ptr<Entity> sourceEntity = source->getEntity();
if (sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER))
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(sourceEntity);
if (!player->abilities.instabuild)
{
shared_ptr<ItemInstance> copy = item->copy();
removeFramedMap(copy);
spawnAtLocation(copy, 0);
}
else
{
removeFramedMap(item);
}
}
else
{
shared_ptr<ItemInstance> copy = item->copy();
removeFramedMap(copy);
spawnAtLocation(copy, 0);
}
setItem(nullptr);
return true;
}
return HangingEntity::hurt(source, damage);
}
int ItemFrame::getAnalogOutput()
{
shared_ptr<ItemInstance> item = getItem();
if (item == nullptr) return 0;
return getRotation() % 8 + 1;
}
float ItemFrame::getPickRadius()
{
return 0.0f;
}

View file

@ -38,9 +38,14 @@ private:
public: public:
shared_ptr<ItemInstance> getItem(); shared_ptr<ItemInstance> getItem();
void setItem(shared_ptr<ItemInstance> item, bool notifyNeighbors);
void setItem(shared_ptr<ItemInstance> item); void setItem(shared_ptr<ItemInstance> item);
int getRotation(); int getRotation();
void setRotation(int rotation, bool notifyNeighbors);
void setRotation(int rotation); void setRotation(int rotation);
virtual bool hurt(DamageSource *source, float damage) override;
virtual int getAnalogOutput();
virtual float getPickRadius()override;
virtual void addAdditonalSaveData(CompoundTag *tag); virtual void addAdditonalSaveData(CompoundTag *tag);
virtual void readAdditionalSaveData(CompoundTag *tag); virtual void readAdditionalSaveData(CompoundTag *tag);

View file

@ -396,6 +396,11 @@ void ItemInstance::setAuxValue(int value)
} }
} }
void ItemInstance::setRawAuxValue(int value)
{
auxValue = value;
}
int ItemInstance::getMaxDamage() int ItemInstance::getMaxDamage()
{ {
return Item::items[id]->getMaxDamage(); return Item::items[id]->getMaxDamage();

View file

@ -90,6 +90,7 @@ public:
int getDamageValue(); int getDamageValue();
int getAuxValue() const; int getAuxValue() const;
void setAuxValue(int value); void setAuxValue(int value);
void setRawAuxValue(int value);
int getMaxDamage(); int getMaxDamage();
bool hurt(int dmg, Random *random); bool hurt(int dmg, Random *random);
void hurtAndBreak(int dmg, shared_ptr<LivingEntity> owner); void hurtAndBreak(int dmg, shared_ptr<LivingEntity> owner);

View file

@ -15,13 +15,13 @@ const unsigned int LeafTile2::LEAF2_NAMES[LEAF2_NAMES_SIZE] = {
}; };
const wstring LeafTile2::TEXTURES[2][2] = { const wstring LeafTile2::TEXTURES[2][2] = {
{ L"leaves_acacia", L"leaves_dark_oak" }, // Indice 0: Fancy { L"leaves_acacia", L"leaves_dark_oak" }, // index 0: Fancy
{ L"leaves_acacia_opaque", L"leaves_dark_oak_opaque" } // Indice 1: Veloce/Opaca { L"leaves_acacia_opaque", L"leaves_dark_oak_opaque" } // index 1: Fast
}; };
LeafTile2::LeafTile2(int id) : LeafTile(id) LeafTile2::LeafTile2(int id) : LeafTile(id)
{ {
// Non serve fare checkBuffer qui, ci pensa già la classe padre LeafTile! // do nothing here
} }
Icon *LeafTile2::getTexture(int face, int data) Icon *LeafTile2::getTexture(int face, int data)
@ -29,8 +29,8 @@ Icon *LeafTile2::getTexture(int face, int data)
int type = data & 3; int type = data & 3;
if (type >= LEAF2_NAMES_SIZE) type = 0; if (type >= LEAF2_NAMES_SIZE) type = 0;
// isSolidRender() in LeafTile restituisce 'true' se la grafica è su Veloce/Opaca. // isSolidRender() in LeafTile returns 'true' if graphics is Fast
// Quindi se è true usiamo l'indice 1, se è false (Trasparente) usiamo l'indice 0. // if true -> index is 1, else 0.
int textureSet = isSolidRender(false) ? 1 : 0; int textureSet = isSolidRender(false) ? 1 : 0;
return icons[textureSet][type]; return icons[textureSet][type];
@ -56,13 +56,14 @@ void LeafTile2::registerIcons(IconRegister *iconRegister)
int LeafTile2::getColor(int data) int LeafTile2::getColor(int data)
{ {
// In inventario o in mano, l'Acacia e la Dark Oak usano il verde base // in the inventory use the default colour for leaves
return FoliageColor::getDefaultColor(); return FoliageColor::getDefaultColor();
} }
int LeafTile2::getColor(LevelSource *level, int x, int y, int z, int data) int LeafTile2::getColor(LevelSource *level, int x, int y, int z, int data)
{ {
// Codice di blending per il colore del bioma (copiato dal tuo LeafTile.cpp) // Codice di blending per il colore del bioma (copiato dal tuo LeafTile.cpp))
// blending biome colors copied from LeafTile.cpp
int totalRed = 0; int totalRed = 0;
int totalGreen = 0; int totalGreen = 0;
int totalBlue = 0; int totalBlue = 0;
@ -71,7 +72,7 @@ int LeafTile2::getColor(LevelSource *level, int x, int y, int z, int data)
{ {
for (int ox = -1; ox <= 1; ox++) for (int ox = -1; ox <= 1; ox++)
{ {
int foliageColor = level->getBiome(x + ox, z + oz)->getFolageColor(); // Attento, nel tuo engine si chiama getFolageColor() senza la 'i' int foliageColor = level->getBiome(x + ox, z + oz)->getFolageColor(); // they mispelled the word. getFolageColor without "i"
totalRed += (foliageColor & 0xff0000) >> 16; totalRed += (foliageColor & 0xff0000) >> 16;
totalGreen += (foliageColor & 0xff00) >> 8; totalGreen += (foliageColor & 0xff00) >> 8;
totalBlue += (foliageColor & 0xff); totalBlue += (foliageColor & 0xff);
@ -83,7 +84,7 @@ int LeafTile2::getColor(LevelSource *level, int x, int y, int z, int data)
void LeafTile2::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data) void LeafTile2::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data)
{ {
// Se il giocatore usa le cesoie, vogliamo droppare "leaves2" (ID 161) e non "leaves" (ID 18) // if player is using shears, drop "leaves2" (ID 161) , instead of "leaves" (ID 18)
if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id) if (!level->isClientSide && player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears->id)
{ {
player->awardStat( player->awardStat(
@ -95,7 +96,7 @@ void LeafTile2::playerDestroy(Level *level, shared_ptr<Player> player, int x, in
} }
else else
{ {
// Altrimenti usa la distruzione standard di TransparentTile // or default destroy
TransparentTile::playerDestroy(level, player, x, y, z, data); TransparentTile::playerDestroy(level, player, x, y, z, data);
} }
} }

View file

@ -13,7 +13,7 @@ public:
static const unsigned int LEAF2_NAMES[LEAF2_NAMES_SIZE]; static const unsigned int LEAF2_NAMES[LEAF2_NAMES_SIZE];
private: private:
//[0] = Fancy (Trasparenti), [1] = Fast (Opache) //index 0, fancy; index 1, fast
static const wstring TEXTURES[2][2]; static const wstring TEXTURES[2][2];
Icon *icons[2][2]; Icon *icons[2][2];

View file

@ -46,6 +46,7 @@ DWORD Level::tlsIdxLightCache = TlsAlloc();
// 4J : WESTY : Added for time played stats. // 4J : WESTY : Added for time played stats.
#include "net.minecraft.stats.h" #include "net.minecraft.stats.h"
#include "../Minecraft.Client/MultiPlayerChunkCache.h"
// 4J - Caching of lighting data added. This is implemented as a 16x16x16 cache of ints (ie 16K storage in total). The index of the element to be used in the array is determined by the lower // 4J - Caching of lighting data added. This is implemented as a 16x16x16 cache of ints (ie 16K storage in total). The index of the element to be used in the array is determined by the lower
// four bits of each x/y/z position, and the upper 7/4/7 bits of the x/y/z positions are stored within the element itself along with the cached values etc. The cache can be enabled per thread by // four bits of each x/y/z position, and the upper 7/4/7 bits of the x/y/z positions are stored within the element itself along with the cached values etc. The cache can be enabled per thread by
@ -1334,10 +1335,10 @@ int Level::getBrightness(LightLayer::variety layer, int x, int y, int z)
if( ( ix < 0 ) || ( ix >= chunkSourceXZSize ) ) return 0; if( ( ix < 0 ) || ( ix >= chunkSourceXZSize ) ) return 0;
if( ( iz < 0 ) || ( iz >= chunkSourceXZSize ) ) return 0; if( ( iz < 0 ) || ( iz >= chunkSourceXZSize ) ) return 0;
int idx = ix * chunkSourceXZSize + iz; int idx = MultiPlayerChunkCache::wrapCoord(ix, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + MultiPlayerChunkCache::wrapCoord(iz, LEVEL_MIN_WIDTH);
LevelChunk *c = chunkSourceCache[idx]; LevelChunk *c = chunkSourceCache[idx];
if( c == nullptr ) return (int)layer; if( c == nullptr) return (int)layer;
if (y < 0) y = 0; if (y < 0) y = 0;
if (y >= maxBuildHeight) y = maxBuildHeight - 1; if (y >= maxBuildHeight) y = maxBuildHeight - 1;
@ -1383,7 +1384,7 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye
return; return;
} }
int idx = ix * chunkSourceXZSize + iz; int idx = MultiPlayerChunkCache::wrapCoord(ix, LEVEL_MIN_WIDTH) * LEVEL_MIN_WIDTH + MultiPlayerChunkCache::wrapCoord(iz, LEVEL_MIN_WIDTH);
LevelChunk *c = chunkSourceCache[idx]; LevelChunk *c = chunkSourceCache[idx];
// 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we // 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we

View file

@ -185,6 +185,7 @@ LevelData::LevelData(CompoundTag *tag)
case LEVEL_WIDTH_SMALL: hostOptionworldSize = e_worldSize_Small; break; case LEVEL_WIDTH_SMALL: hostOptionworldSize = e_worldSize_Small; break;
case LEVEL_WIDTH_MEDIUM: hostOptionworldSize = e_worldSize_Medium; break; case LEVEL_WIDTH_MEDIUM: hostOptionworldSize = e_worldSize_Medium; break;
case LEVEL_WIDTH_LARGE: hostOptionworldSize = e_worldSize_Large; break; case LEVEL_WIDTH_LARGE: hostOptionworldSize = e_worldSize_Large; break;
case LEVEL_WIDTH_EXPANDED: hostOptionworldSize = e_worldSize_Expanded; break;
default: assert(0); break; default: assert(0); break;
} }
app.SetGameHostOption(eGameHostOption_WorldSize, hostOptionworldSize ); app.SetGameHostOption(eGameHostOption_WorldSize, hostOptionworldSize );

View file

@ -137,9 +137,13 @@ void MobEffect::applyEffectTick(shared_ptr<LivingEntity> mob, int amplification)
} }
else if (id == poison->id) else if (id == poison->id)
{ {
if (mob->getHealth() > 1.0f) // poison must never reduce health below 1 hp
// if the current health is between 1 and 2 hp the player is left at exactly 1 HP rather than dying.
float currentHealth = mob->getHealth();
if (currentHealth > 1.0f)
{ {
mob->hurt(DamageSource::magic, 1.0f); float poisonDmg = min(1.0f, currentHealth - 1.0f);
mob->hurt(DamageSource::magic, poisonDmg);
} }
} }
else if (id == wither->id) else if (id == wither->id)

View file

@ -30,7 +30,7 @@ MoveEntityPacket::MoveEntityPacket(int id)
void MoveEntityPacket::read(DataInputStream *dis) //throws IOException void MoveEntityPacket::read(DataInputStream *dis) //throws IOException
{ {
id = dis->readShort(); id = dis->readInt();
} }
void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
@ -40,7 +40,7 @@ void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
// We shouln't be tracking an entity that doesn't have a short type of id // We shouln't be tracking an entity that doesn't have a short type of id
DEBUG_BREAK(); DEBUG_BREAK();
} }
dos->writeShort(static_cast<short>(id)); dos->writeInt(static_cast<short>(id));
} }
void MoveEntityPacket::handle(PacketListener *listener) void MoveEntityPacket::handle(PacketListener *listener)
@ -50,7 +50,7 @@ void MoveEntityPacket::handle(PacketListener *listener)
int MoveEntityPacket::getEstimatedSize() int MoveEntityPacket::getEstimatedSize()
{ {
return 2; return 4;
} }
bool MoveEntityPacket::canBeInvalidated() bool MoveEntityPacket::canBeInvalidated()
@ -101,7 +101,7 @@ void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException
int MoveEntityPacket::PosRot::getEstimatedSize() int MoveEntityPacket::PosRot::getEstimatedSize()
{ {
return 2+5; return 4+5;
} }
MoveEntityPacket::Pos::Pos() MoveEntityPacket::Pos::Pos()
@ -133,7 +133,7 @@ void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException
int MoveEntityPacket::Pos::getEstimatedSize() int MoveEntityPacket::Pos::getEstimatedSize()
{ {
return 2+3; return 4+3;
} }
MoveEntityPacket::Rot::Rot() MoveEntityPacket::Rot::Rot()
@ -164,5 +164,5 @@ void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException
int MoveEntityPacket::Rot::getEstimatedSize() int MoveEntityPacket::Rot::getEstimatedSize()
{ {
return 2+2; return 4+2;
} }

View file

@ -37,7 +37,7 @@ MoveEntityPacketSmall::MoveEntityPacketSmall(int id)
void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException
{ {
id = dis->readShort(); id = dis->readInt();
} }
void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
@ -47,7 +47,7 @@ void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
// We shouln't be tracking an entity that doesn't have a short type of id // We shouln't be tracking an entity that doesn't have a short type of id
DEBUG_BREAK(); DEBUG_BREAK();
} }
dos->writeShort(static_cast<short>(id)); dos->writeInt(id);
} }
void MoveEntityPacketSmall::handle(PacketListener *listener) void MoveEntityPacketSmall::handle(PacketListener *listener)
@ -57,7 +57,7 @@ void MoveEntityPacketSmall::handle(PacketListener *listener)
int MoveEntityPacketSmall::getEstimatedSize() int MoveEntityPacketSmall::getEstimatedSize()
{ {
return 2; return 4;
} }
bool MoveEntityPacketSmall::canBeInvalidated() bool MoveEntityPacketSmall::canBeInvalidated()
@ -88,13 +88,12 @@ MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yR
void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException
{ {
int idAndRot = dis->readShort(); this->id = dis->readInt();
this->id = idAndRot & 0x07ff; this->yRot = dis->readChar();
this->yRot = idAndRot >> 11; int XandYandZ = (int)dis->readShort();
int xAndYAndZ = (int)dis->readShort(); this->xa = XandYandZ >> 11;
this->xa = xAndYAndZ >> 11; this->ya = (XandYandZ << 21 ) >> 26;
this->ya = (xAndYAndZ << 21 ) >> 26; this->za = (XandYandZ << 27 ) >> 27;
this->za = (xAndYAndZ << 27 ) >> 27;
} }
void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException
@ -104,15 +103,15 @@ void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOExce
// We shouln't be tracking an entity that doesn't have a short type of id // We shouln't be tracking an entity that doesn't have a short type of id
DEBUG_BREAK(); DEBUG_BREAK();
} }
short idAndRot = id | yRot << 11; dos->writeInt(id);
dos->writeShort(idAndRot); dos->writeChar(yRot);
short xAndYAndZ = ( xa << 11 ) | ( ( ya & 0x3f ) << 5 ) | ( za & 0x1f ); short XandYandZ = ( xa << 11 ) | ( ( ya & 0x3f ) << 5 ) | ( za & 0x1f );
dos->writeShort(xAndYAndZ); dos->writeShort(XandYandZ);
} }
int MoveEntityPacketSmall::PosRot::getEstimatedSize() int MoveEntityPacketSmall::PosRot::getEstimatedSize()
{ {
return 4; return 7;
} }
MoveEntityPacketSmall::Pos::Pos() MoveEntityPacketSmall::Pos::Pos()
@ -128,9 +127,8 @@ MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityP
void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException
{ {
int idAndY = dis->readShort(); this->id = dis->readInt();
this->id = idAndY & 0x07ff; this->ya = dis->readChar();
this->ya = idAndY >> 11;
int XandZ = (int)static_cast<signed char>(dis->readByte()); int XandZ = (int)static_cast<signed char>(dis->readByte());
xa = XandZ >> 4; xa = XandZ >> 4;
za = ( XandZ << 28 ) >> 28; za = ( XandZ << 28 ) >> 28;
@ -143,15 +141,15 @@ void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOExcepti
// We shouln't be tracking an entity that doesn't have a short type of id // We shouln't be tracking an entity that doesn't have a short type of id
DEBUG_BREAK(); DEBUG_BREAK();
} }
short idAndY = id | ya << 11; dos->writeInt(id);
dos->writeShort(idAndY); dos->writeChar(ya);
char XandZ = ( xa << 4 ) | ( za & 0x0f ); char XandZ = ( xa << 4 ) | ( za & 0x0f );
dos->writeByte(XandZ); dos->writeByte(XandZ);
} }
int MoveEntityPacketSmall::Pos::getEstimatedSize() int MoveEntityPacketSmall::Pos::getEstimatedSize()
{ {
return 3; return 7;
} }
MoveEntityPacketSmall::Rot::Rot() MoveEntityPacketSmall::Rot::Rot()
@ -169,9 +167,8 @@ MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket
void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException
{ {
int idAndRot = (int)dis->readShort(); this->id = dis->readInt();
this->id = idAndRot & 0x07ff; this->yRot = dis->readChar();
this->yRot = idAndRot >> 11;
} }
void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException
@ -181,11 +178,11 @@ void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOExcepti
// We shouln't be tracking an entity that doesn't have a short type of id // We shouln't be tracking an entity that doesn't have a short type of id
DEBUG_BREAK(); DEBUG_BREAK();
} }
short idAndRot = id | yRot << 11; dos->writeInt(id);
dos->writeShort(idAndRot); dos->writeChar(yRot);
} }
int MoveEntityPacketSmall::Rot::getEstimatedSize() int MoveEntityPacketSmall::Rot::getEstimatedSize()
{ {
return 2; return 5;
} }

View file

@ -103,7 +103,5 @@ public:
static shared_ptr<ItemInstance> readItem(DataInputStream *dis); static shared_ptr<ItemInstance> readItem(DataInputStream *dis);
static void writeItem(shared_ptr<ItemInstance> item, DataOutputStream *dos); static void writeItem(shared_ptr<ItemInstance> item, DataOutputStream *dos);
static CompoundTag *readNbt(DataInputStream *dis); static CompoundTag *readNbt(DataInputStream *dis);
protected:
static void writeNbt(CompoundTag *tag, DataOutputStream *dos); static void writeNbt(CompoundTag *tag, DataOutputStream *dos);
}; };

View file

@ -29,20 +29,14 @@ void Recipes::_init()
{ {
// 4J Jev: instance = new Recipes(); // 4J Jev: instance = new Recipes();
recipies = new RecipyList(); recipies = new RecipyList();
}
Recipes::Recipes() pArmorRecipes = new ArmorRecipes;
{ pClothDyeRecipes = new ClothDyeRecipes;
int iCount=0; pFoodRecipies = new FoodRecipies;
_init(); pOreRecipies = new OreRecipies;
pStructureRecipies = new StructureRecipies;
pArmorRecipes = new ArmorRecipes; pToolRecipies = new ToolRecipies;
pClothDyeRecipes = new ClothDyeRecipes; pWeaponRecipies = new WeaponRecipies;
pFoodRecipies = new FoodRecipies;
pOreRecipies = new OreRecipies;
pStructureRecipies = new StructureRecipies;
pToolRecipies = new ToolRecipies;
pWeaponRecipies = new WeaponRecipies;
// 4J Stu - These just don't work with our crafting menu // 4J Stu - These just don't work with our crafting menu
//recipies->push_back(new ArmorDyeRecipe()); //recipies->push_back(new ArmorDyeRecipe());
@ -50,8 +44,10 @@ Recipes::Recipes()
//recipies->add(new MapExtendingRecipe()); //recipies->add(new MapExtendingRecipe());
//recipies->add(new FireworksRecipe()); //recipies->add(new FireworksRecipe());
pFireworksRecipes = new FireworksRecipe(); pFireworksRecipes = new FireworksRecipe();
}
void Recipes::_compileRecipes()
{
addShapedRecipy(new ItemInstance(Tile::wood, 4, 0), // addShapedRecipy(new ItemInstance(Tile::wood, 4, 0), //
L"sczg", L"sczg",
L"#", // L"#", //
@ -475,12 +471,10 @@ Recipes::Recipes()
L'S'); L'S');
pArmorRecipes->addRecipes(this); pArmorRecipes->addRecipes(this);
//iCount=getRecipies()->size();
pClothDyeRecipes->addRecipes(this); pClothDyeRecipes->addRecipes(this);
addShapedRecipy(new ItemInstance(Tile::snow, 1), // addShapedRecipy(new ItemInstance(Tile::snow, 1), //
L"sscig", L"sscig",
L"##", // L"##", //
@ -497,7 +491,7 @@ Recipes::Recipes()
L'#', Item::prismarine_shard, L'#', Item::prismarine_shard,
L'S'); L'S');
addShapedRecipy(new ItemInstance(Tile::prismarine, 1,PrismarineTile::TYPE_BRICKS), // addShapedRecipy(new ItemInstance(Tile::prismarine, 1, PrismarineTile::TYPE_BRICKS), //
L"ssscig", L"ssscig",
L"###", // L"###", //
L"###", // L"###", //
@ -507,7 +501,7 @@ Recipes::Recipes()
L'S'); L'S');
addShapedRecipy(new ItemInstance(Tile::prismarine, 1,PrismarineTile::TYPE_DARK), // addShapedRecipy(new ItemInstance(Tile::prismarine, 1, PrismarineTile::TYPE_DARK), //
L"ssscicig", L"ssscicig",
L"###", // L"###", //
L"#X#", // L"#X#", //
@ -657,10 +651,6 @@ Recipes::Recipes()
//iCount=getRecipies()->size();
addShapedRecipy(new ItemInstance(Item::cake, 1), // addShapedRecipy(new ItemInstance(Item::cake, 1), //
L"ssscicicicig", L"ssscicicicig",
L"AAA", // L"AAA", //
@ -803,7 +793,7 @@ Recipes::Recipes()
L'F'); L'F');
// Moved bow and arrow in from weapons to avoid stacking on the group name display // Moved bow and arrow in from weapons to avoid stacking on the group name display
addShapedRecipy(new ItemInstance((Item *)Item::bow, 1), // addShapedRecipy(new ItemInstance((Item*)Item::bow, 1), //
L"ssscicig", L"ssscicig",
L" #X", // L" #X", //
L"# X", // L"# X", //
@ -1206,19 +1196,19 @@ Recipes::Recipes()
L'D'); L'D');
// 4J - TODO - put these new 1.7.3 items in required place within recipes // 4J - TODO - put these new 1.7.3 items in required place within recipes
addShapedRecipy(new ItemInstance(static_cast<Tile *>(Tile::pistonBase), 1), // addShapedRecipy(new ItemInstance(static_cast<Tile*>(Tile::pistonBase), 1), //
L"sssctcicictg", L"sssctcicictg",
L"TTT", // L"TTT", //
L"#X#", // L"#X#", //
L"#R#", // L"#R#", //
L'#', Tile::cobblestone, L'X', Item::iron_ingot, L'R', Item::redstone, L'T', Tile::wood, L'#', Tile::cobblestone, L'X', Item::iron_ingot, L'R', Item::redstone, L'T', Tile::wood,
L'M'); L'M');
addShapedRecipy(new ItemInstance(static_cast<Tile *>(Tile::sticky_piston), 1), // addShapedRecipy(new ItemInstance(static_cast<Tile *>(Tile::sticky_piston), 1), //
L"sscictg", L"sscictg",
L"S", // L"S", //
L"P", // L"P", //
L'S', Item::slime_ball, L'P', Tile::pistonBase, L'S', Item::slime_ball, L'P', Tile::pistonBase,
L'M'); L'M');
@ -1249,37 +1239,38 @@ Recipes::Recipes()
L'D', Item::dye, L'C', Item::firework_charge, L'D', Item::dye, L'C', Item::firework_charge,
L'D'); L'D');
// Sort so the largest recipes get checked first!
/* 4J-PB - TODO
Collections.sort(recipies, new Comparator<Recipy>()
{
public: int compare(Recipy r0, Recipy r1)
{
// shapeless recipes are put in the back of the list
if (r0 instanceof ShapelessRecipy && r1 instanceof ShapedRecipy)
{
return 1;
}
if (r1 instanceof ShapelessRecipy && r0 instanceof ShapedRecipy)
{
return -1;
}
if (r1.size() < r0.size()) return -1;
if (r1.size() > r0.size()) return 1;
return 0;
}
});
*/
// 4J-PB removed System.out.println(recipies->size() + L" recipes");
// 4J-PB - build the array of ingredients required per recipe
buildRecipeIngredientsArray(); buildRecipeIngredientsArray();
} }
void Recipes::_wipeRecipes()
{
int iCount = recipies->size();
for (int i = 0; i < iCount; i++) {
Recipy::INGREDIENTS_REQUIRED& req = m_pRecipeIngredientsRequired[i];
delete[] req.iIngIDA;
delete[] req.iIngValA;
delete[] req.iIngAuxValA;
delete[] req.uiGridA;
}
for (int i = 0; i < iCount; i++) {
delete (*recipies)[i];
}
recipies->clear();
delete[] m_pRecipeIngredientsRequired;
m_pRecipeIngredientsRequired = nullptr;
}
Recipes::Recipes()
{
_init();
_compileRecipes();
}
// 4J-PB - this function has been substantially changed due to the differences with a va_list of classes in C++ and Java // 4J-PB - this function has been substantially changed due to the differences with a va_list of classes in C++ and Java
ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
{ {
@ -1563,7 +1554,7 @@ void Recipes::buildRecipeIngredientsArray(void)
int iRecipeC=static_cast<int>(recipies->size()); int iRecipeC=static_cast<int>(recipies->size());
m_pRecipeIngredientsRequired= new Recipy::INGREDIENTS_REQUIRED [iRecipeC]; m_pRecipeIngredientsRequired = new Recipy::INGREDIENTS_REQUIRED [iRecipeC];
int iCount=0; int iCount=0;
for (auto& recipe : *recipies) for (auto& recipe : *recipies)
@ -1578,3 +1569,45 @@ Recipy::INGREDIENTS_REQUIRED *Recipes::getRecipeIngredientsArray(void)
{ {
return m_pRecipeIngredientsRequired; return m_pRecipeIngredientsRequired;
} }
void Recipes::loadFromLocal()
{
this->_wipeRecipes();
this->_compileRecipes();
}
void Recipes::loadFromPacket(byteArray packetData)
{
ByteArrayInputStream bais(packetData);
DataInputStream input(&bais);
this->_wipeRecipes();
{
int iCount = input.readInt();
for (int i = 0; i < iCount; i++) {
int recipeType = input.readByte();
if (recipeType == 1) {
recipies->push_back(ShapelessRecipy::readFromStream(&input));
} else if (recipeType == 2) {
recipies->push_back(ShapedRecipy::readFromStream(&input));
}
}
}
this->buildRecipeIngredientsArray();
}
std::shared_ptr<CustomPayloadPacket> Recipes::createUpdatePacket()
{
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
int iCount = recipies->size();
dos.writeInt(iCount);
for (int i = 0; i < iCount; i++) {
(*recipies)[i]->writeToStream(&dos);
}
return std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::UPDATE_RECIPE_REGISTRY, baos.toByteArray());
}

View file

@ -16,6 +16,7 @@ import net.minecraft.world.level.tile.Tile;
*/ */
#include "Recipy.h" #include "Recipy.h"
#include "../Minecraft.World/CustomPayloadPacket.h"
#pragma once #pragma once
using namespace std; using namespace std;
@ -84,6 +85,8 @@ public:
private: private:
void _init(); // 4J add void _init(); // 4J add
void _compileRecipes();
void _wipeRecipes();
Recipes(); Recipes();
public: public:
@ -97,6 +100,11 @@ public:
shared_ptr<ItemInstance> getItemForRecipe(Recipy *r); shared_ptr<ItemInstance> getItemForRecipe(Recipy *r);
Recipy::INGREDIENTS_REQUIRED *getRecipeIngredientsArray(); Recipy::INGREDIENTS_REQUIRED *getRecipeIngredientsArray();
void loadFromLocal();
void loadFromPacket(byteArray packetData);
std::shared_ptr<CustomPayloadPacket> createUpdatePacket();
private: private:
void buildRecipeIngredientsArray(); void buildRecipeIngredientsArray();
Recipy::INGREDIENTS_REQUIRED *m_pRecipeIngredientsRequired; Recipy::INGREDIENTS_REQUIRED *m_pRecipeIngredientsRequired;

View file

@ -15,8 +15,8 @@ class Recipy
public: public:
enum _eGroupType enum _eGroupType
{ {
eGroupType_First=0, eGroupType_First = 0,
eGroupType_Structure=0, eGroupType_Structure = 0,
eGroupType_Tool, eGroupType_Tool,
eGroupType_Food, eGroupType_Food,
eGroupType_Armour, eGroupType_Armour,
@ -32,24 +32,26 @@ public:
{ {
int iIngC; int iIngC;
int iType; // Can be a 2x2 or a 3x3. Inventory crafting can only make a 2x2. int iType; // Can be a 2x2 or a 3x3. Inventory crafting can only make a 2x2.
int *iIngIDA; int* iIngIDA;
int *iIngValA; int* iIngValA;
int *iIngAuxValA; int* iIngAuxValA;
Recipy *pRecipy; Recipy* pRecipy;
bool bCanMake[XUSER_MAX_COUNT]; bool bCanMake[XUSER_MAX_COUNT];
unsigned int *uiGridA; // hold the layout of the recipe (id | auxval<<24) unsigned int* uiGridA; // hold the layout of the recipe (id | auxval<<24)
unsigned short usBitmaskMissingGridIngredients[XUSER_MAX_COUNT]; // each bit set means we don't have that grid ingredient unsigned short usBitmaskMissingGridIngredients[XUSER_MAX_COUNT]; // each bit set means we don't have that grid ingredient
} }
INGREDIENTS_REQUIRED; INGREDIENTS_REQUIRED;
~Recipy() {} virtual ~Recipy() = default;
virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level *level) = 0; virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level* level) = 0;
virtual shared_ptr<ItemInstance> assemble(shared_ptr<CraftingContainer> craftSlots) = 0; virtual shared_ptr<ItemInstance> assemble(shared_ptr<CraftingContainer> craftSlots) = 0;
virtual int size() = 0; virtual int size() = 0;
virtual const ItemInstance *getResultItem() = 0; virtual const ItemInstance* getResultItem() = 0;
virtual const int getGroup() = 0; virtual const int getGroup() = 0;
// 4J-PB // 4J-PB
virtual bool reqs(int iRecipe) = 0; virtual bool reqs(int iRecipe) = 0;
virtual void reqs(INGREDIENTS_REQUIRED *pIngReq) = 0; virtual void reqs(INGREDIENTS_REQUIRED* pIngReq) = 0;
virtual void writeToStream(DataOutputStream* dos) = 0;
}; };

View file

@ -58,7 +58,7 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException
mapSeed = dis->readLong(); mapSeed = dis->readLong();
difficulty = dis->readByte(); difficulty = dis->readByte();
m_newSeaLevel = dis->readBoolean(); m_newSeaLevel = dis->readBoolean();
m_newEntityId = dis->readShort(); m_newEntityId = dis->readInt();
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
m_xzSize = dis->readShort(); m_xzSize = dis->readShort();
m_hellScale = dis->read(); m_hellScale = dis->read();
@ -83,7 +83,7 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException
dos->writeLong(mapSeed); dos->writeLong(mapSeed);
dos->writeByte(difficulty); dos->writeByte(difficulty);
dos->writeBoolean(m_newSeaLevel); dos->writeBoolean(m_newSeaLevel);
dos->writeShort(m_newEntityId); dos->writeInt(m_newEntityId);
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
dos->writeShort(m_xzSize); dos->writeShort(m_xzSize);
dos->write(m_hellScale); dos->write(m_hellScale);
@ -97,5 +97,5 @@ int RespawnPacket::getEstimatedSize()
{ {
length = static_cast<int>(m_pLevelType->getGeneratorName().length()); length = static_cast<int>(m_pLevelType->getGeneratorName().length());
} }
return 13+length; return 13+length+2;
} }

View file

@ -49,9 +49,9 @@ SetEntityMotionPacket::SetEntityMotionPacket(int id, double xd, double yd, doubl
void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
{ {
short idAndFlag = dis->readShort(); useBytes = dis->readBoolean();
id = idAndFlag & 0x07ff; id = dis->readInt();
if( idAndFlag & 0x0800 ) if(useBytes)
{ {
xa = static_cast<int>(dis->readByte()); xa = static_cast<int>(dis->readByte());
ya = static_cast<int>(dis->readByte()); ya = static_cast<int>(dis->readByte());
@ -62,29 +62,28 @@ void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
xa *= 16; xa *= 16;
ya *= 16; ya *= 16;
za *= 16; za *= 16;
useBytes = true;
} }
else else
{ {
xa = dis->readShort(); xa = dis->readShort();
ya = dis->readShort(); ya = dis->readShort();
za = dis->readShort(); za = dis->readShort();
useBytes = false;
} }
} }
void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException
{ {
dos->writeBoolean(useBytes);
if( useBytes ) if( useBytes )
{ {
dos->writeShort(id | 0x800); dos->writeInt(id);
dos->writeByte(xa/16); dos->writeByte(xa/16);
dos->writeByte(ya/16); dos->writeByte(ya/16);
dos->writeByte(za/16); dos->writeByte(za/16);
} }
else else
{ {
dos->writeShort(id); dos->writeInt(id);
dos->writeShort(xa); dos->writeShort(xa);
dos->writeShort(ya); dos->writeShort(ya);
dos->writeShort(za); dos->writeShort(za);
@ -98,7 +97,7 @@ void SetEntityMotionPacket::handle(PacketListener *listener)
int SetEntityMotionPacket::getEstimatedSize() int SetEntityMotionPacket::getEstimatedSize()
{ {
return useBytes ? 5 : 8; return useBytes ? 8 : 11;
} }
bool SetEntityMotionPacket::canBeInvalidated() bool SetEntityMotionPacket::canBeInvalidated()

View file

@ -23,6 +23,24 @@ ShapedRecipy::ShapedRecipy(int width, int height, ItemInstance **recipeItems, It
_keepTag = false; _keepTag = false;
} }
ShapedRecipy::~ShapedRecipy() {
// todo: why does this cause a error when clearing out these specifically?
// might be leaking memory here but im not sure cause it crashes when you clear them, so we dont clear them
/*for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
if (x < width && y < height) {
delete recipeItems[x + y * width];
}
}
}*/
delete[] recipeItems;
delete result;
recipeItems = nullptr;
result = nullptr;
}
const int ShapedRecipy::getGroup() const int ShapedRecipy::getGroup()
{ {
return group; return group;
@ -228,3 +246,64 @@ ShapedRecipy *ShapedRecipy::keepTag()
_keepTag = true; _keepTag = true;
return this; return this;
} }
void ShapedRecipy::writeToStream(DataOutputStream* dos) {
dos->writeByte(2);
dos->writeByte(this->group);
//write result item, it should always be valid
{
dos->writeShort(this->result->id);
dos->writeByte(this->result->count);
dos->writeShort(this->result->getAuxValue());
Packet::writeNbt(this->result->tag, dos);
}
dos->writeByte((this->width << 2) | this->height);
for (int i = 0; i < (this->width * this->height); i++) {
ItemInstance* ingredients_item = this->recipeItems[i];
dos->writeBoolean(ingredients_item == nullptr);
if (ingredients_item == nullptr) continue;
dos->writeShort(ingredients_item->id);
dos->writeShort(ingredients_item->getAuxValue());
Packet::writeNbt(ingredients_item->tag, dos);
}
}
ShapedRecipy* ShapedRecipy::readFromStream(DataInputStream* dis) {
int groupType = dis->readByte();
int resultItemID = dis->readShort();
int resultItemCount = dis->readByte();
int resultItemAux = dis->readShort();
ItemInstance* resultItem = new ItemInstance(resultItemID, resultItemCount, 0);
resultItem->setRawAuxValue(resultItemAux);
resultItem->tag = Packet::readNbt(dis);
unsigned char packedSize = dis->readByte();
int width = (packedSize >> 2) & 0x3;
int height = packedSize & 0x3;
ItemInstance** ids = new ItemInstance*[width * height];
for (int i = 0; i < width * height; i++) {
ItemInstance* ingredients_item = nullptr;
bool isNull = dis->readBoolean();
if (!isNull) {
int itemId = dis->readShort();
int itemAux = dis->readShort();
ingredients_item = new ItemInstance(itemId, 1, 0);
ingredients_item->setRawAuxValue(itemAux);
ingredients_item->tag = Packet::readNbt(dis);
}
ids[i] = ingredients_item;
}
return new ShapedRecipy(width, height, ids, resultItem, groupType);
}

View file

@ -4,18 +4,19 @@ class ShapedRecipy : public Recipy
{ {
private: private:
int width, height, group; int width, height, group;
ItemInstance **recipeItems; ItemInstance** recipeItems;
ItemInstance *result; ItemInstance* result;
bool _keepTag; bool _keepTag;
public: public:
const int resultId; const int resultId;
public: public:
ShapedRecipy(int width, int height, ItemInstance **recipeItems, ItemInstance *result, int iGroup=Recipy::eGroupType_Decoration); ShapedRecipy(int width, int height, ItemInstance** recipeItems, ItemInstance* result, int iGroup = Recipy::eGroupType_Decoration);
virtual ~ShapedRecipy() override;
virtual const ItemInstance *getResultItem(); virtual const ItemInstance* getResultItem();
virtual const int getGroup(); virtual const int getGroup();
virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level *level); virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level* level);
private: private:
bool matches(shared_ptr<CraftingContainer> craftSlots, int xOffs, int yOffs, bool xFlip); bool matches(shared_ptr<CraftingContainer> craftSlots, int xOffs, int yOffs, bool xFlip);
@ -23,10 +24,14 @@ private:
public: public:
virtual shared_ptr<ItemInstance> assemble(shared_ptr<CraftingContainer> craftSlots); virtual shared_ptr<ItemInstance> assemble(shared_ptr<CraftingContainer> craftSlots);
virtual int size(); virtual int size();
ShapedRecipy *keepTag(); ShapedRecipy* keepTag();
// 4J-PB - to return the items required to make a recipe // 4J-PB - to return the items required to make a recipe
virtual bool reqs(int iRecipe); virtual bool reqs(int iRecipe);
virtual void reqs(INGREDIENTS_REQUIRED *pIngReq); virtual void reqs(INGREDIENTS_REQUIRED* pIngReq);
virtual void writeToStream(DataOutputStream* dos);
static ShapedRecipy* readFromStream(DataInputStream* dis);
}; };

View file

@ -19,6 +19,19 @@ ShapelessRecipy::ShapelessRecipy(ItemInstance *result, vector<ItemInstance *> *i
{ {
} }
ShapelessRecipy::~ShapelessRecipy() {
for (int i = 0; i < ingredients->size(); i++) {
delete (*ingredients)[i];
}
delete ingredients;
delete result;
ingredients = nullptr;
result = nullptr;
}
const int ShapelessRecipy::getGroup() const int ShapelessRecipy::getGroup()
{ {
return group; return group;
@ -174,3 +187,60 @@ void ShapelessRecipy::reqs(INGREDIENTS_REQUIRED *pIngReq)
delete [] TempIngReq.iIngAuxValA; delete [] TempIngReq.iIngAuxValA;
delete [] TempIngReq.uiGridA; delete [] TempIngReq.uiGridA;
} }
void ShapelessRecipy::writeToStream(DataOutputStream* dos) {
dos->writeByte(1);
dos->writeByte(this->group);
//write result item, it should always be valid
{
dos->writeShort(this->result->id);
dos->writeByte(this->result->count);
dos->writeShort(this->result->getAuxValue());
Packet::writeNbt(this->result->tag, dos);
}
byte iCount = ingredients->size();
dos->writeByte(iCount);
for (int i = 0; i < iCount; i++) {
ItemInstance* item = (*ingredients)[i];
dos->writeBoolean(item == nullptr);
if (item == nullptr) continue;
dos->writeShort(item->id);
dos->writeShort(item->getAuxValue());
Packet::writeNbt(item->tag, dos);
}
}
ShapelessRecipy* ShapelessRecipy::readFromStream(DataInputStream* dis) {
unsigned char groupType = dis->readByte();
int resultItemID = dis->readShort();
int resultItemCount = dis->readByte();
int resultItemAux = dis->readShort();
ItemInstance* resultItem = new ItemInstance(resultItemID, resultItemCount, 0);
resultItem->setRawAuxValue(resultItemAux);
resultItem->tag = Packet::readNbt(dis);
vector<ItemInstance*>* ingredients = new vector<ItemInstance*>();
int iCount = dis->readByte();
for (int i = 0; i < iCount; i++) {
if (dis->readBoolean() == true) continue; //item is null or something weird
int itemID = dis->readShort();
int itemAux = dis->readShort();
ItemInstance* ingredients_item = new ItemInstance(itemID, 1, 0);
ingredients_item->setRawAuxValue(itemAux);
ingredients_item->tag = Packet::readNbt(dis);
ingredients->push_back(ingredients_item);
}
return new ShapelessRecipy(resultItem, ingredients, (Recipy::_eGroupType)groupType);
}

View file

@ -9,6 +9,7 @@ private:
public: public:
ShapelessRecipy(ItemInstance *result, vector<ItemInstance *> *ingredients, _eGroupType egroup=Recipy::eGroupType_Decoration); ShapelessRecipy(ItemInstance *result, vector<ItemInstance *> *ingredients, _eGroupType egroup=Recipy::eGroupType_Decoration);
virtual ~ShapelessRecipy() override;
virtual const ItemInstance *getResultItem(); virtual const ItemInstance *getResultItem();
virtual const int getGroup(); virtual const int getGroup();
@ -20,4 +21,6 @@ public:
virtual bool reqs(int iRecipe); virtual bool reqs(int iRecipe);
virtual void reqs(INGREDIENTS_REQUIRED *pIngReq); virtual void reqs(INGREDIENTS_REQUIRED *pIngReq);
virtual void writeToStream(DataOutputStream* dos);
static ShapelessRecipy* readFromStream(DataInputStream* dos);
}; };

View file

@ -7,7 +7,7 @@ class SharedConstants
public: public:
static void staticCtor(); static void staticCtor();
static const wstring VERSION_STRING; static const wstring VERSION_STRING;
static const int NETWORK_PROTOCOL_VERSION = 78; static const int NETWORK_PROTOCOL_VERSION = 79;
static const bool INGAME_DEBUG_OUTPUT = false; static const bool INGAME_DEBUG_OUTPUT = false;
// NOT texture resolution. How many sub-blocks each block face is made up of. // NOT texture resolution. How many sub-blocks each block face is made up of.

View file

@ -77,7 +77,51 @@ void StructureRecipies::addRecipes(Recipes *r)
L'#', new ItemInstance(Tile::quartzBlock, 1, QuartzBlockTile::TYPE_DEFAULT), L'#', new ItemInstance(Tile::quartzBlock, 1, QuartzBlockTile::TYPE_DEFAULT),
L'S'); L'S');
r->addShapedRecipy(new ItemInstance(Tile::stone_Id, 2, StoneTile::DIORITE), //
L"ssctcig",
L"#Q", //
L"Q#", //
L'#', Tile::cobblestone, L'Q', Item::netherQuartz,
L'S');
r->addShapedRecipy(new ItemInstance(Tile::stone_Id, 1, StoneTile::GRANITE), //
L"sczcig",
L"#Q", //
L'#', new ItemInstance(Tile::stone_Id, 1, StoneTile::DIORITE), L'Q', Item::netherQuartz,
L'S');
r->addShapedRecipy(new ItemInstance(Tile::stone_Id, 2, StoneTile::ANDESITE), //
L"sczctg",
L"#-", //
L'#', new ItemInstance(Tile::stone_Id, 1, StoneTile::DIORITE), L'-', Tile::cobblestone,
L'S');
r->addShapedRecipy(new ItemInstance(Tile::stone_Id, 4, StoneTile::POLISHED_DIORITE), //
L"ssczg",
L"##", //
L"##", //
L'#', new ItemInstance(Tile::stone_Id, 1, StoneTile::DIORITE),
L'S');
r->addShapedRecipy(new ItemInstance(Tile::stone_Id, 4, StoneTile::POLISHED_GRANITE), //
L"ssczg",
L"##", //
L"##", //
L'#', new ItemInstance(Tile::stone_Id, 1, StoneTile::GRANITE),
L'S');
r->addShapedRecipy(new ItemInstance(Tile::stone_Id, 4, StoneTile::POLISHED_ANDESITE), //
L"ssczg",
L"##", //
L"##", //
L'#', new ItemInstance(Tile::stone_Id, 1, StoneTile::ANDESITE),
L'S');
// 4J Stu - Changed the order, as the blocks that go with sandstone cause a 3-icon scroll // 4J Stu - Changed the order, as the blocks that go with sandstone cause a 3-icon scroll
// that touches the text "Structures" in the title in 720 fullscreen. // that touches the text "Structures" in the title in 720 fullscreen.

View file

@ -32,6 +32,12 @@ void SwellGoal::stop()
void SwellGoal::tick() void SwellGoal::tick()
{ {
if(creeper->isIgnited())
{
creeper->setSwellDir(1);
return;
}
if (target.lock() == nullptr) if (target.lock() == nullptr)
{ {
creeper->setSwellDir(-1); creeper->setSwellDir(-1);

View file

@ -236,11 +236,12 @@ void TallGrass2::neighborChanged(Level* level, int x, int y, int z, int type)
if (!isUpper) if (!isUpper)
{ {
if (!canSurvive(level, x, y, z)) int upperTileId = level->getTile(x, y + 1, z);
if (!canSurvive(level, x, y, z) || (upperTileId != id))
{ {
spawnResources(level, x, y, z, data, 0); spawnResources(level, x, y, z, data, 0);
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS);
if (level->getTile(x, y + 1, z) == id) if (upperTileId == id)
level->removeTile(x, y + 1, z); level->removeTile(x, y + 1, z);
} }
} }
@ -258,11 +259,12 @@ void TallGrass2::tick(Level* level, int x, int y, int z, Random* random)
if (!isUpper) if (!isUpper)
{ {
if (!canSurvive(level, x, y, z)) int upperTileId = level->getTile(x, y + 1, z);
if (!canSurvive(level, x, y, z) || (upperTileId != id))
{ {
spawnResources(level, x, y, z, data, 0); spawnResources(level, x, y, z, data, 0);
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_CLIENTS);
if (level->getTile(x, y + 1, z) == id) if (upperTileId == id)
level->removeTile(x, y + 1, z); level->removeTile(x, y + 1, z);
} }
} }
@ -271,7 +273,6 @@ void TallGrass2::tick(Level* level, int x, int y, int z, Random* random)
int TallGrass2::getResource(int data, Random* random, int playerBonusLevel) int TallGrass2::getResource(int data, Random* random, int playerBonusLevel)
{ {
return -1; return -1;
} }
@ -287,7 +288,6 @@ bool TallGrass2::isSilkTouchable()
shared_ptr<ItemInstance> TallGrass2::getSilkTouchItemInstance(int data) shared_ptr<ItemInstance> TallGrass2::getSilkTouchItemInstance(int data)
{ {
if ((data & UPPER_BIT) != 0) return nullptr; if ((data & UPPER_BIT) != 0) return nullptr;
int variant = data & ~UPPER_BIT; int variant = data & ~UPPER_BIT;
return std::make_shared<ItemInstance>(this, 1, variant); return std::make_shared<ItemInstance>(this, 1, variant);

View file

@ -39,7 +39,7 @@ TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRo
void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
{ {
id = dis->readShort(); id = dis->readInt();
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
x = dis->readInt(); x = dis->readInt();
y = dis->readInt(); y = dis->readInt();
@ -55,7 +55,7 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException
void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException
{ {
dos->writeShort(id); dos->writeInt(id);
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
dos->writeInt(x); dos->writeInt(x);
dos->writeInt(y); dos->writeInt(y);
@ -76,7 +76,7 @@ void TeleportEntityPacket::handle(PacketListener *listener)
int TeleportEntityPacket::getEstimatedSize() int TeleportEntityPacket::getEstimatedSize()
{ {
return 2 + 2 + 2 + 2 + 1 + 1; return 4 + 2 + 2 + 2 + 1 + 1;
} }
bool TeleportEntityPacket::canBeInvalidated() bool TeleportEntityPacket::canBeInvalidated()

View file

@ -372,7 +372,7 @@ void Tile::staticCtor()
Tile::tiles = new Tile *[TILE_NUM_COUNT]; Tile::tiles = new Tile *[TILE_NUM_COUNT];
memset( tiles, 0, sizeof( Tile *)*TILE_NUM_COUNT ); memset( tiles, 0, sizeof( Tile *)*TILE_NUM_COUNT );
Tile::stone = (new StoneTile(1)) ->setDestroyTime(1.5f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stone")->setDescriptionId(IDS_TILE_STONE)->setUseDescriptionId(IDS_DESC_STONE); Tile::stone = (new StoneTile(1))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(1.5f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stone")->setDescriptionId(IDS_TILE_STONE)->setUseDescriptionId(IDS_DESC_STONE);
Tile::grass = static_cast<GrassTile *>((new GrassTile(2))->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"grass")->setDescriptionId(IDS_TILE_GRASS)->setUseDescriptionId(IDS_DESC_GRASS)); Tile::grass = static_cast<GrassTile *>((new GrassTile(2))->setDestroyTime(0.6f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"grass")->setDescriptionId(IDS_TILE_GRASS)->setUseDescriptionId(IDS_DESC_GRASS));
Tile::dirt = (new DirtTile(3)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_GRAVEL)->setIconName(L"dirt")->setDescriptionId(IDS_TILE_DIRT)->setUseDescriptionId(IDS_DESC_DIRT); Tile::dirt = (new DirtTile(3)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_GRAVEL)->setIconName(L"dirt")->setDescriptionId(IDS_TILE_DIRT)->setUseDescriptionId(IDS_DESC_DIRT);
Tile::cobblestone = (new Tile(4, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"cobblestone")->setDescriptionId(IDS_TILE_STONE_BRICK)->setUseDescriptionId(IDS_DESC_STONE_BRICK); Tile::cobblestone = (new Tile(4, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"cobblestone")->setDescriptionId(IDS_TILE_STONE_BRICK)->setUseDescriptionId(IDS_DESC_STONE_BRICK);

View file

@ -709,7 +709,8 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l
bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, BoundingBox *chunkBB) bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, BoundingBox *chunkBB)
{ {
int tile = biomeBlock(Tile::gravel_Id, 0); int roadTile = biomeBlock(Tile::gravel_Id, 0);
int baseTile = biomeBlock(Tile::cobblestone_Id, 0);
for (int x = boundingBox->x0; x <= boundingBox->x1; x++) for (int x = boundingBox->x0; x <= boundingBox->x1; x++)
{ {
for (int z = boundingBox->z0; z <= boundingBox->z1; z++) for (int z = boundingBox->z0; z <= boundingBox->z1; z++)
@ -717,7 +718,8 @@ bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, Boun
if (chunkBB->isInside(x, 64, z)) if (chunkBB->isInside(x, 64, z))
{ {
int y = level->getTopSolidBlock(x, z) - 1; int y = level->getTopSolidBlock(x, z) - 1;
level->setTileAndData(x, y, z,tile, 0, Tile::UPDATE_CLIENTS); level->setTileAndData(x, y, z, roadTile, 0, Tile::UPDATE_CLIENTS);
level->setTileAndData(x, y - 1, z, baseTile, 0, Tile::UPDATE_CLIENTS);
} }
} }
} }

View file

@ -156,7 +156,7 @@ bool Villager::mobInteract(shared_ptr<Player> player)
shared_ptr<ItemInstance> item = player->inventory->getSelected(); shared_ptr<ItemInstance> item = player->inventory->getSelected();
bool holdingSpawnEgg = item != nullptr && item->id == Item::spawn_egg_Id; bool holdingSpawnEgg = item != nullptr && item->id == Item::spawn_egg_Id;
if (!holdingSpawnEgg && isAlive() && !isTrading() && !isBaby()) if (!player->isSneaking() && !holdingSpawnEgg && isAlive() && !isTrading() && !isBaby())
{ {
if (!level->isClientSide) if (!level->isClientSide)
{ {
@ -776,3 +776,19 @@ wstring Villager::getDisplayName()
}; };
return app.GetString(name); return app.GetString(name);
} }
void Villager::thunderHit(const LightningBolt *lightningBolt)
{
if (level->isClientSide) return;
shared_ptr<Witch> witch = std::make_shared<Witch>(level);
witch->moveTo(x, y, z, yRot, xRot);
if (this->hasCustomName())
witch->setCustomName(this->getCustomName());
if (this->isPersistenceRequired())
witch->setPersistenceRequired();
level->addEntity(witch);
remove();
}

View file

@ -147,4 +147,5 @@ public:
virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target); virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target);
virtual bool canBeLeashed(); virtual bool canBeLeashed();
virtual wstring getDisplayName(); virtual wstring getDisplayName();
virtual void thunderHit(const LightningBolt *lightningBolt);
}; };

View file

@ -20,3 +20,4 @@
#include "TheEndPortalTileEntity.h" #include "TheEndPortalTileEntity.h"
#include "SkullTileEntity.h" #include "SkullTileEntity.h"
#include "EnderChestTileEntity.h" #include "EnderChestTileEntity.h"
#include "ItemFrame.h"

View file

@ -1,15 +1,16 @@
![Banner](https://github.com/pieeebot/neoLegacy/raw/main/.github/banner.png) # neoLegacy v1.0.4b
# neoLegacy v1.0.1b ### Bug Fixes
- Fixed Podzol bottom face displaying incorrect texture (was using side texture instead of dirt)
- Classic Crafting ### Changes
- Commands support! - Cursor icon now changes when hovering over different UI elements
- /give - Added TU31 parity changes which include:
- /tp - /teleport - Creepers can now be ignited with Flint and Steel
- /gamemode - Village gravel roads now have Cobblestone underneath
- .... - Villagers now transform into Witches when struck by lightning
<img width="784" height="410" alt="image" src="https://github.com/user-attachments/assets/3731d5b4-b2d6-4c62-ab52-2e241fb7dcb4" /> <img width="784" height="410" alt="roadmap" src="https://github.com/user-attachments/assets/134856ae-b151-4003-aa97-7ecf19ccd278" />
# Download # Download
Get the latest build from [LCE Emerald Launcher](https://github.com/LCE-Hub/LCE-Emerald-Launcher/releases) or the upcoming LC Launcher. Get the latest build from [LCE Emerald Launcher](https://github.com/LCE-Hub/LCE-Emerald-Launcher/releases) or the upcoming LC Launcher.

View file

@ -21,8 +21,8 @@ Users can download our [Nightly Build](https://github.com/pieeebot/neoLegacy/rel
Huge thanks to the following projects: Huge thanks to the following projects:
- [Patoke/LCERenewed](https://github.com/Patoke/LCERenewed) - for some of the patches that required deep decompilation - [Patoke/LCERenewed](https://github.com/Patoke/LCERenewed) - for some of the patches that required deep decompilation
- [itsRevela/LCE-Revelations](https://github.com/itsRevela/LCE-Revelations) - for providing a stable project for neoLegacy to continue with - [itsRevela/LCE-Revelations](https://git.revela.dev/itsRevela/LCE-Revelations) - for providing a stable project for neoLegacy to continue with
- [GabsPuNs/MinecraftConsoles](https://github.com/GabsPuNs/MinecraftConsoles) - for providing us with their implemention of the Classic Crafting Feature. - [GabsPuNs/Project-Zenith](https://github.com/GabsPuNs/Project-Zenith-Main) - for providing us with their implemention of the Classic Crafting Feature.
# Build & Run # Build & Run

View file

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
VERSION="0.0.0" # man we're using nightly :sob: VERSION="0.0.0" # man we're using nightly :sob:
SOURCE_DIR="${1:-.}" SOURCE_DIR="${SOURCE_DIR:-${1:-.}}"
BUILD_CI="${BUILD_CI:-0}" BUILD_CI="${BUILD_CI:-0}"
BUILD_TYPE="${2:-Release}" BUILD_TYPE="${BUILD_TYPE:-${2:-Release}}"
XWIN_CACHE="${XWIN_CACHE:-$PWD/.xwin}" XWIN_CACHE="${XWIN_CACHE:-$PWD/.xwin}"
INSTALL_DIR="${INSTALL_PREFIX:-$HOME/.local/share/neoLegacy}" INSTALL_DIR="${INSTALL_PREFIX:-$HOME/.local/share/neoLegacy}"
RED='\033[0;31m' RED='\033[0;31m'
@ -84,6 +84,10 @@ do_cmake_configure() {
-imsvc $winsdk/sdk/include/um \ -imsvc $winsdk/sdk/include/um \
-imsvc $winsdk/sdk/include/shared" -imsvc $winsdk/sdk/include/shared"
if [[ "$BUILD_TYPE" == "Debug" ]]; then
c_flags="$c_flags -w"
fi
local linker_flags="\ local linker_flags="\
-libpath:$winsdk/crt/lib/x86_64 \ -libpath:$winsdk/crt/lib/x86_64 \
-libpath:$winsdk/sdk/lib/um/x86_64 \ -libpath:$winsdk/sdk/lib/um/x86_64 \
@ -259,15 +263,22 @@ LAUNCHER
chmod +x "$INSTALL_DIR/minecraft-lce-fourkit" chmod +x "$INSTALL_DIR/minecraft-lce-fourkit"
} }
BUILD_DIR="$SOURCE_DIR/build/windows64-clang" main() {
mkdir -p "$BUILD_DIR" BUILD_DIR="$SOURCE_DIR/build/windows64-clang"
info "neoLegacy v$VERSION build script" mkdir -p "$BUILD_DIR"
info "Source: $SOURCE_DIR | Type: $BUILD_TYPE" info "LegacyEvolved LCE v$VERSION build script"
echo "" info "Source: $SOURCE_DIR | Type: $BUILD_TYPE"
check_deps echo ""
fetch_winsdk check_deps
patch_winsdk_symlinks fetch_winsdk
do_cmake_configure patch_winsdk_symlinks
do_build do_cmake_configure
do_install do_build
do_install
}
# Do not run main when sourced (required for flake.nix)
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi

View file

@ -7,7 +7,7 @@ if(NOT OUTPUT_FILE)
message(FATAL_ERROR "OUTPUT_FILE must be set.") message(FATAL_ERROR "OUTPUT_FILE must be set.")
endif() endif()
set(BUILD_NUMBER 560) # Note: Build/network has to stay static for now, as without it builds wont be able to play together. We can change it later when we have a better versioning scheme in place. set(BUILD_NUMBER 570) # Note: Build/network has to stay static for now, as without it builds wont be able to play together. We can change it later when we have a better versioning scheme in place.
set(SUFFIX "") set(SUFFIX "")
# Get short SHA # Get short SHA

228
cmake/GenerateSdk.cmake Normal file
View file

@ -0,0 +1,228 @@
if(NOT INPUT_DIRS)
message(FATAL_ERROR "INPUT_DIRS must be set to a list of directories.")
endif()
if(NOT OUTPUT_FILE)
message(FATAL_ERROR "OUTPUT_FILE must be set.")
endif()
set(_all_headers "")
foreach(_dir IN LISTS INPUT_DIRS)
if(EXISTS "${_dir}")
file(GLOB_RECURSE _hfiles "${_dir}/*.h")
list(APPEND _all_headers ${_hfiles})
endif()
endforeach()
if(NOT _all_headers)
message(FATAL_ERROR "No .h files found in INPUT_DIRS.")
endif()
list(REMOVE_DUPLICATES _all_headers)
list(SORT _all_headers)
foreach(_h IN LISTS _all_headers)
get_filename_component(_bn "${_h}" NAME)
string(TOLOWER "${_bn}" _k)
set(_idx_${_k} "${_h}")
endforeach()
foreach(_h IN LISTS _all_headers)
file(STRINGS "${_h}" _ll REGEX "^[ \t]*#[ \t]*include[ \t]+\"")
get_filename_component(_hd "${_h}" DIRECTORY)
set(_dd "")
foreach(_l IN LISTS _ll)
if(_l MATCHES "^[ \t]*#[ \t]*include[ \t]+\"([^\"]+)\"")
set(_in "${CMAKE_MATCH_1}")
set(_rv "")
set(_try "${_hd}/${_in}")
get_filename_component(_try "${_try}" ABSOLUTE)
if(EXISTS "${_try}")
set(_rv "${_try}")
else()
string(TOLOWER "${_in}" _k2)
if(DEFINED _idx_${_k2})
set(_rv "${_idx_${_k2}}")
endif()
endif()
if(_rv AND _rv IN_LIST _all_headers)
list(APPEND _dd "${_rv}")
endif()
endif()
endforeach()
if(_dd)
list(REMOVE_DUPLICATES _dd)
endif()
set(_de_${_h} "${_dd}")
endforeach()
set(_sorted "")
set(_left ${_all_headers})
while(_left)
set(_prog 0)
set(_next "")
foreach(_h IN LISTS _left)
set(_rdy 1)
foreach(_d IN LISTS _de_${_h})
if(_d IN_LIST _left)
set(_rdy 0)
break()
endif()
endforeach()
if(_rdy)
list(APPEND _sorted "${_h}")
set(_prog 1)
else()
list(APPEND _next "${_h}")
endif()
endforeach()
if(NOT _prog)
foreach(_h IN LISTS _next)
list(APPEND _sorted "${_h}")
endforeach()
break()
endif()
set(_left ${_next})
endwhile()
set(_body "")
foreach(_h IN LISTS _sorted)
file(STRINGS "${_h}" _ll)
set(_inbc 0)
set(_out "")
foreach(_l IN LISTS _ll)
if(_l STREQUAL "")
continue()
endif()
if(_inbc)
string(FIND "${_l}" "*/" _ce)
if(_ce GREATER -1)
math(EXPR _ca "${_ce} + 2")
string(SUBSTRING "${_l}" ${_ca} -1 _l)
set(_inbc 0)
else()
continue()
endif()
endif()
string(FIND "${_l}" "//" _sl)
if(_sl GREATER -1)
string(SUBSTRING "${_l}" 0 ${_sl} _l)
endif()
while(TRUE)
string(FIND "${_l}" "/*" _so)
if(_so EQUAL -1)
break()
endif()
string(SUBSTRING "${_l}" 0 ${_so} _bf)
string(SUBSTRING "${_l}" ${_so} -1 _ar)
string(FIND "${_ar}" "*/" _ce)
if(_ce EQUAL -1)
set(_l "${_bf}")
set(_inbc 1)
break()
else()
math(EXPR _ca "${_ce} + 2")
string(SUBSTRING "${_ar}" ${_ca} -1 _af)
set(_l "${_bf}${_af}")
endif()
endwhile()
string(STRIP "${_l}" _ls)
if(_ls MATCHES "^#[ \t]*pragma[ \t]+once")
continue()
endif()
if(_ls MATCHES "^#[ \t]*include[ \t]+\"([^\"]+)\"")
continue()
endif()
if(_ls MATCHES "^#[ \t]*include[ \t]+<")
continue()
endif()
if(_ls STREQUAL "")
continue()
endif()
string(APPEND _out "${_l}\n")
endforeach()
if(_out)
if(_body)
string(APPEND _body "\n")
endif()
string(APPEND _body "${_out}")
endif()
endforeach()
set(_guard "MINECRAFT_LCE_SDK_H")
set(_tmp "${OUTPUT_FILE}.tmp")
file(WRITE "${_tmp}"
"#ifndef ${_guard}\n"
"#define ${_guard}\n"
"\n"
"// Auto-generated. Do not edit.\n"
"// Minecraft Console Edition SDK Header\n"
"\n"
"#include <cstddef>\n"
"#include <cstdint>\n"
"#include <string>\n"
"#include <memory>\n"
"#include <vector>\n"
"#include <map>\n"
"#include <unordered_map>\n"
"#include <functional>\n"
"#include <algorithm>\n"
"#include <atomic>\n"
"#include <mutex>\n"
"#include <thread>\n"
"#include <fstream>\n"
"#include <sstream>\n"
"#include <iostream>\n"
"#include <array>\n"
"#include <set>\n"
"#include <queue>\n"
"#include <list>\n"
"#include <cmath>\n"
"#include <cassert>\n"
"#include <cstdio>\n"
"#include <cstdlib>\n"
"#include <cstring>\n"
"#include <cwchar>\n"
"#include <climits>\n"
"#include <cfloat>\n"
"#include <type_traits>\n"
"#include <initializer_list>\n"
"#include <exception>\n"
"#include <tuple>\n"
"#include <chrono>\n"
"#include <system_error>\n"
"#if defined(_WIN32) || defined(_WIN64)\n"
"#include <Windows.h>\n"
"#endif\n"
"\n"
)
file(APPEND "${_tmp}" "${_body}")
file(APPEND "${_tmp}" "\n#endif // ${_guard}\n")
if(EXISTS "${OUTPUT_FILE}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E compare_files "${OUTPUT_FILE}" "${_tmp}"
RESULT_VARIABLE _ch
)
else()
set(_ch 1)
endif()
if(_ch)
file(RENAME "${_tmp}" "${OUTPUT_FILE}")
message(STATUS "GenerateSdk: wrote ${OUTPUT_FILE}")
else()
file(REMOVE "${_tmp}")
message(STATUS "GenerateSdk: ${OUTPUT_FILE} is up-to-date")
endif()

View file

@ -18,6 +18,22 @@
"type": "github" "type": "github"
} }
}, },
"fourjlibs": {
"flake": false,
"locked": {
"lastModified": 1777358628,
"narHash": "sha256-yV/ugauN5L4FFC88N4CJI01iTOKYBeim8UQ3Usy2vI0=",
"owner": "Patoke",
"repo": "4JLibs",
"rev": "8fb036f6d6ca5aa5aa2e20633638d6232a58d508",
"type": "github"
},
"original": {
"owner": "Patoke",
"repo": "4JLibs",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1774106199, "lastModified": 1774106199,
@ -37,6 +53,7 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"fourjlibs": "fourjlibs",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
}, },

254
flake.nix
View file

@ -4,18 +4,34 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
fourjlibs = {
url = "github:Patoke/4JLibs";
flake = false;
};
}; };
outputs = { self, nixpkgs, flake-utils }: outputs =
flake-utils.lib.eachDefaultSystem (system: {
self,
nixpkgs,
flake-utils,
fourjlibs,
}:
flake-utils.lib.eachDefaultSystem (
system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
# Version info # Version derived from network protocol version in cmake/GenerateBuildVer.cmake
version = "1.6.0560.0"; buildNumber = builtins.head (
builtins.match ".*set\\(BUILD_NUMBER ([0-9]+)\\).*" (
builtins.readFile ./cmake/GenerateBuildVer.cmake
)
);
version = "0.${buildNumber}.0";
# Windows SDK downloaded via xwin (fixed-output derivation) # Windows SDK downloaded via xwin (fixed-output derivation)
windowsSdk = pkgs.stdenvNoCC.mkDerivation { windowsSdk = pkgs.stdenvNoCC.mkDerivation {
@ -24,9 +40,13 @@
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash = "sha256-ksSytBUjv/tD3IJzHM9BkAzFjJ+JAGD353Pur0G4rQE="; outputHash = "sha256-UFQjsFVBwcF/9e9tVFoG0Z1JySxyTnFqoaRwr/tUWzA=";
nativeBuildInputs = [ pkgs.xwin pkgs.cacert pkgs.rsync ]; nativeBuildInputs = [
pkgs.xwin
pkgs.cacert
pkgs.rsync
];
dontUnpack = true; dontUnpack = true;
@ -50,8 +70,45 @@
dontFixup = true; dontFixup = true;
}; };
# Helper to create case-insensitive symlinks for SDK headers/libs # Pre fetch NuGet packages for FourKit (dotnet publish --self-contained needs win-x64 runtime)
sdkWithSymlinks = pkgs.runCommand "windows-sdk-symlinked" {} '' fourkitNugetDeps = pkgs.stdenvNoCC.mkDerivation {
pname = "fourkit-nuget-deps";
version = "10.0";
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-eEkU0MugnFSNvVYvd5V5xLK4oNcLgZcXxMYSuiYMPbA=";
nativeBuildInputs = [ pkgs.cacert ];
dontUnpack = true;
buildPhase = ''
export HOME=$(mktemp -d)
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1
export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
# Use the unwrapped SDK to allow NuGet network access
DOTNET="${pkgs.dotnetCorePackages.sdk_10_0.passthru.unwrapped}/share/dotnet/dotnet"
# Copy csproj to writable location (dotnet needs to write obj/)
WORK=$(mktemp -d)
cp ${./.}/Minecraft.Server.FourKit/Minecraft.Server.FourKit.csproj "$WORK/"
cp ${./.}/global.json "$WORK/"
$DOTNET restore "$WORK/Minecraft.Server.FourKit.csproj" \
--runtime win-x64 \
--packages "$out" \
--source https://api.nuget.org/v3/index.json
'';
dontInstall = true;
dontFixup = true;
};
# Helper to make case insensitive symlinks for SDK headers/libs
sdkWithSymlinks = pkgs.runCommand "windows-sdk-symlinked" { } ''
cp -r ${windowsSdk} $out cp -r ${windowsSdk} $out
chmod -R u+w $out chmod -R u+w $out
@ -63,27 +120,6 @@
ln -sf $out/sdk/lib/um/x86_64/ws2_32.lib $out/sdk/lib/um/x86_64/Ws2_32.lib 2>/dev/null || true ln -sf $out/sdk/lib/um/x86_64/ws2_32.lib $out/sdk/lib/um/x86_64/Ws2_32.lib 2>/dev/null || true
''; '';
# CMake toolchain file for clang-cl cross-compilation
clangClToolchain = pkgs.writeText "clang-cl-toolchain.cmake" ''
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR AMD64)
set(CMAKE_C_COMPILER clang-cl)
set(CMAKE_CXX_COMPILER clang-cl)
set(CMAKE_RC_COMPILER llvm-rc)
set(CMAKE_ASM_MASM_COMPILER llvm-ml)
set(CMAKE_AR llvm-lib)
set(CMAKE_LINKER lld-link)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> -out:<TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> -out:<TARGET> <LINK_LIBRARIES>")
add_compile_options(-fms-compatibility -fms-extensions)
add_compile_definitions(_WIN64 _AMD64_ WIN32_LEAN_AND_MEAN)
'';
# The main build derivation # The main build derivation
minecraft-lce-unwrapped = pkgs.stdenv.mkDerivation { minecraft-lce-unwrapped = pkgs.stdenv.mkDerivation {
pname = "minecraft-lce-unwrapped"; pname = "minecraft-lce-unwrapped";
@ -91,84 +127,79 @@
src = pkgs.lib.cleanSourceWith { src = pkgs.lib.cleanSourceWith {
src = ./.; src = ./.;
filter = path: type: filter =
path: type:
let let
baseName = baseNameOf path; baseName = baseNameOf path;
in in
# Exclude build directories and other non-source files # Exclude build directories and other non-source files
!(baseName == "build" || !(
baseName == "result" || baseName == "build"
baseName == ".git" || || baseName == "result"
baseName == ".direnv" || || baseName == ".git"
pkgs.lib.hasPrefix "result-" baseName); || baseName == ".direnv"
|| pkgs.lib.hasPrefix "result-" baseName
);
}; };
# Patch in the 4JLibs submodule (flakes don't fetch submodules)
postUnpack = ''
rm -rf source/Minecraft.Client/Windows64/4JLibs
cp -r ${fourjlibs} source/Minecraft.Client/Windows64/4JLibs
chmod -R u+w source/Minecraft.Client/Windows64/4JLibs
'';
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
llvmPackages.clang-unwrapped # provides clang-cl llvmPackages.clang-unwrapped # provides clang-cl
llvmPackages.lld # provides lld-link llvmPackages.lld # provides lld-link
llvmPackages.llvm # provides llvm-rc, llvm-ml, llvm-lib, llvm-mt llvmPackages.llvm # provides llvm-rc, llvm-ml, llvm-lib, llvm-mt
cmake cmake
ninja ninja
rsync rsync
winePackage # needed to run fxc.exe during build
dotnetCorePackages.sdk_10_0 # needed for FourKit server
]; ];
# Set up environment for clang-cl
WINSDK = sdkWithSymlinks;
configurePhase = '' configurePhase = ''
runHook preConfigure runHook preConfigure
export INCLUDE="$WINSDK/crt/include;$WINSDK/sdk/include/um;$WINSDK/sdk/include/ucrt;$WINSDK/sdk/include/shared" # Point build-linux.sh at the pre-downloaded Windows SDK
export LIB="$WINSDK/crt/lib/x86_64;$WINSDK/sdk/lib/um/x86_64;$WINSDK/sdk/lib/ucrt/x86_64" export XWIN_CACHE=$(mktemp -d)
ln -s ${sdkWithSymlinks} "$XWIN_CACHE/splat"
cmake -S . -B build \ # NuGet packages for FourKit dotnet publish
-G Ninja \ export NUGET_PACKAGES="${fourkitNugetDeps}"
-DCMAKE_BUILD_TYPE=Release \ export DOTNET_CLI_TELEMETRY_OPTOUT=1
-DCMAKE_TOOLCHAIN_FILE=${clangClToolchain} \ export DOTNET_NOLOGO=1
-DCMAKE_C_COMPILER=clang-cl \
-DCMAKE_CXX_COMPILER=clang-cl \ # Configure build-linux.sh variables
-DCMAKE_LINKER=lld-link \ export SOURCE_DIR=.
-DCMAKE_RC_COMPILER=llvm-rc \ export BUILD_TYPE=Release
-DCMAKE_MT=llvm-mt \ export INSTALL_PREFIX=$out
-DPLATFORM_DEFINES="_WINDOWS64" \
-DPLATFORM_NAME="Windows64" \ # Source the build script for its functions
-DIGGY_LIBS="iggy_w64.lib;iggyperfmon_w64.lib;iggyexpruntime_w64.lib" \ source ./build-linux.sh
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded \ BUILD_DIR="$SOURCE_DIR/build/windows64-clang"
-DCMAKE_C_FLAGS="/MT -fms-compatibility -fms-extensions --target=x86_64-pc-windows-msvc -imsvc $WINSDK/crt/include -imsvc $WINSDK/sdk/include/ucrt -imsvc $WINSDK/sdk/include/um -imsvc $WINSDK/sdk/include/shared" \ mkdir -p "$BUILD_DIR"
-DCMAKE_CXX_FLAGS="/MT -fms-compatibility -fms-extensions --target=x86_64-pc-windows-msvc -imsvc $WINSDK/crt/include -imsvc $WINSDK/sdk/include/ucrt -imsvc $WINSDK/sdk/include/um -imsvc $WINSDK/sdk/include/shared" \
-DCMAKE_ASM_MASM_FLAGS="-m64" \ do_cmake_configure
-DCMAKE_EXE_LINKER_FLAGS="-libpath:$WINSDK/crt/lib/x86_64 -libpath:$WINSDK/sdk/lib/um/x86_64 -libpath:$WINSDK/sdk/lib/ucrt/x86_64"
# Patch shebangs in generated scripts (fxc wine wrapper)
patchShebangs "$BUILD_DIR/tools" 2>/dev/null || true
runHook postConfigure runHook postConfigure
''; '';
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
cmake --build build --config Release -j $NIX_BUILD_CORES do_build
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
do_install
mkdir -p $out/{client,server}
# Install client
cp build/Minecraft.Client/Minecraft.Client.exe $out/client/
cp build/Minecraft.Client/iggy_w64.dll $out/client/ 2>/dev/null || true
cp -r build/Minecraft.Client/Common $out/client/ 2>/dev/null || true
cp -r build/Minecraft.Client/music $out/client/ 2>/dev/null || true
cp -r build/Minecraft.Client/Windows64 $out/client/ 2>/dev/null || true
cp -r build/Minecraft.Client/Windows64Media $out/client/ 2>/dev/null || true
cp -r build/Minecraft.Client/iggy* $out/client/ 2>/dev/null || true
# Install server
cp build/Minecraft.Server/Minecraft.Server.exe $out/server/
cp build/Minecraft.Server/iggy_w64.dll $out/server/ 2>/dev/null || true
cp -r build/Minecraft.Server/Common $out/server/ 2>/dev/null || true
cp -r build/Minecraft.Server/Windows64 $out/server/ 2>/dev/null || true
runHook postInstall runHook postInstall
''; '';
@ -386,58 +417,10 @@
rsync rsync
coreutils coreutils
cacert cacert
winePackage
]; ];
text = '' text = ''
set -euo pipefail exec bash "${./build-linux.sh}" "$@"
SOURCE_DIR="''${1:-.}"
BUILD_TYPE="''${2:-Release}"
XWIN_CACHE="''${XWIN_CACHE:-$HOME/.cache/xwin}"
export XWIN_CACHE
echo "[info] Checking Windows SDK cache at $XWIN_CACHE"
if [[ ! -d "$XWIN_CACHE/splat" ]]; then
echo "[info] Downloading Windows SDK and CRT via xwin..."
mkdir -p "$XWIN_CACHE"
xwin --accept-license splat --output "$XWIN_CACHE/splat"
else
echo "[info] Using cached Windows SDK"
fi
WINSDK="$XWIN_CACHE/splat"
export INCLUDE="$WINSDK/crt/include;$WINSDK/sdk/include/um;$WINSDK/sdk/include/ucrt;$WINSDK/sdk/include/shared"
export LIB="$WINSDK/crt/lib/x86_64;$WINSDK/sdk/lib/um/x86_64;$WINSDK/sdk/lib/ucrt/x86_64"
BUILD_DIR="$SOURCE_DIR/build/windows64-clang"
mkdir -p "$BUILD_DIR"
echo "[info] Configuring with CMake..."
cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" \
-G Ninja \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_TOOLCHAIN_FILE="${clangClToolchain}" \
-DCMAKE_C_COMPILER=clang-cl \
-DCMAKE_CXX_COMPILER=clang-cl \
-DCMAKE_LINKER=lld-link \
-DCMAKE_RC_COMPILER=llvm-rc \
-DCMAKE_MT=llvm-mt \
-DPLATFORM_DEFINES="_WINDOWS64" \
-DPLATFORM_NAME="Windows64" \
-DIGGY_LIBS="iggy_w64.lib;iggyperfmon_w64.lib;iggyexpruntime_w64.lib" \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded \
-DCMAKE_C_FLAGS="/MT -fms-compatibility -fms-extensions --target=x86_64-pc-windows-msvc -imsvc $WINSDK/crt/include -imsvc $WINSDK/sdk/include/ucrt -imsvc $WINSDK/sdk/include/um -imsvc $WINSDK/sdk/include/shared" \
-DCMAKE_CXX_FLAGS="/MT -fms-compatibility -fms-extensions --target=x86_64-pc-windows-msvc -imsvc $WINSDK/crt/include -imsvc $WINSDK/sdk/include/ucrt -imsvc $WINSDK/sdk/include/um -imsvc $WINSDK/sdk/include/shared" \
-DCMAKE_ASM_MASM_FLAGS="-m64" \
-DCMAKE_EXE_LINKER_FLAGS="-libpath:$WINSDK/crt/lib/x86_64 -libpath:$WINSDK/sdk/lib/um/x86_64 -libpath:$WINSDK/sdk/lib/ucrt/x86_64"
echo "[info] Building..."
cmake --build "$BUILD_DIR" --config "$BUILD_TYPE" -j "$(nproc)"
echo "[info] Build complete! Output in $BUILD_DIR"
''; '';
}; };
@ -451,6 +434,9 @@
# Unwrapped (just the Windows executables) # Unwrapped (just the Windows executables)
unwrapped = minecraft-lce-unwrapped; unwrapped = minecraft-lce-unwrapped;
# NuGet deps for FourKit (for debugging)
fourkit-nuget-deps = fourkitNugetDeps;
# Windows SDK (for debugging) # Windows SDK (for debugging)
windows-sdk = sdkWithSymlinks; windows-sdk = sdkWithSymlinks;
@ -488,6 +474,9 @@
xwin xwin
rsync rsync
# .NET SDK for FourKit server
dotnetCorePackages.sdk_10_0
# Wine for testing # Wine for testing
winePackage winePackage
winetricks winetricks
@ -500,8 +489,6 @@
cacert cacert
]; ];
XWIN_CACHE = "$HOME/.cache/xwin";
shellHook = '' shellHook = ''
echo "LCE-Revelations development shell" echo "LCE-Revelations development shell"
echo "" echo ""
@ -510,13 +497,14 @@
echo " nix build .#server # Build server package" echo " nix build .#server # Build server package"
echo "" echo ""
echo "Development build (in-tree):" echo "Development build (in-tree):"
echo " minecraft-lce-build [source_dir] [Release|Debug]" echo " ./build-linux.sh [source_dir] [Release|Debug]"
echo "" echo ""
echo "Run:" echo "Run:"
echo " nix run .#client" echo " nix run .#client"
echo " nix run .#server" echo " nix run .#server"
echo "" echo ""
echo "Environment variables:" echo "Environment variables:"
echo " XWIN_CACHE - Windows SDK cache (default: \$PWD/.xwin)"
echo " MC_PORT - Server port (default: 25565)" echo " MC_PORT - Server port (default: 25565)"
echo " MC_BIND - Server bind address (default: 0.0.0.0)" echo " MC_BIND - Server bind address (default: 0.0.0.0)"
echo " MC_DATA_DIR - Persistent data directory" echo " MC_DATA_DIR - Persistent data directory"