From 0c2b307eab67b7f37d82a7862a6acbcd96b45adb Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 20 Jan 2014 18:22:08 +0100 Subject: first changes for enchanting (not finished) - added enchanting table block handler and added it to the blockhandler - added enchanting window - drop item in the slot 0 when the player close the window - added enchanting packet (1.7 only) - some more... --- src/Blocks/BlockEnchantmentTable.h | 37 +++++++++++++++++++++++++++++++++++++ src/Blocks/BlockHandler.cpp | 2 ++ 2 files changed, 39 insertions(+) create mode 100644 src/Blocks/BlockEnchantmentTable.h (limited to 'src/Blocks') diff --git a/src/Blocks/BlockEnchantmentTable.h b/src/Blocks/BlockEnchantmentTable.h new file mode 100644 index 000000000..e8a87179b --- /dev/null +++ b/src/Blocks/BlockEnchantmentTable.h @@ -0,0 +1,37 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../UI/Window.h" +#include "../Entities/Player.h" + + + + + +class cBlockEnchantmentTableHandler : + public cBlockHandler +{ +public: + cBlockEnchantmentTableHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + { + cWindow * Window = new cEnchantingWindow(a_BlockX, a_BlockY, a_BlockZ); + a_Player->OpenWindow(Window); + } + + + virtual bool IsUseable(void) override + { + return true; + } +}; + + + + diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index b9c0887ce..8d09b5559 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -21,6 +21,7 @@ #include "BlockDirt.h" #include "BlockDoor.h" #include "BlockDropSpenser.h" +#include "BlockEnchantmentTable.h" #include "BlockEnderchest.h" #include "BlockEntity.h" #include "BlockFarmland.h" @@ -132,6 +133,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType); case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType); + case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType); case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType); case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( ); case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); -- cgit v1.2.3 From 1dfd2b1c5fe125757aeb084c163aec5b25a55fc2 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 7 Apr 2014 20:25:30 +0200 Subject: Fixed Errors --- src/Blocks/BlockEnchantmentTable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockEnchantmentTable.h b/src/Blocks/BlockEnchantmentTable.h index e8a87179b..81d2cb9a0 100644 --- a/src/Blocks/BlockEnchantmentTable.h +++ b/src/Blocks/BlockEnchantmentTable.h @@ -19,7 +19,7 @@ public: } - virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { cWindow * Window = new cEnchantingWindow(a_BlockX, a_BlockY, a_BlockZ); a_Player->OpenWindow(Window); -- cgit v1.2.3 From 013da806ec20b62a742aded9a9d2b8131193f30d Mon Sep 17 00:00:00 2001 From: jfhumann Date: Fri, 18 Apr 2014 21:09:44 +0200 Subject: Did some static analysis, fixed some bugs and optimized a lot of code --- src/Blocks/BlockChest.h | 1 + src/Blocks/BlockRail.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index a1ded4c26..c9a769c75 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -56,6 +56,7 @@ public: (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST) ) { + // FIXME: This is unreachable, as the condition is the same as the above one a_BlockMeta = (yaw < 0) ? 4 : 5; return true; } diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index ad78d290a..358b5ca11 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -141,7 +141,7 @@ public: NIBBLETYPE Meta = 0; char RailsCnt = 0; bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP - memset(Neighbors, false, sizeof(Neighbors)); + memset(Neighbors, 0, sizeof(Neighbors)); Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN)); Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)); Neighbors[2] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN)); -- cgit v1.2.3 From 9660c4816f75db569f14f5e40786f246dcde2386 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 23 Apr 2014 16:57:32 +0200 Subject: The new leaves don't decay anymore. Fixes #792 --- src/Blocks/BlockLeaves.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 8af14686e..d21227b07 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -16,6 +16,7 @@ { \ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \ case E_BLOCK_LOG: return true; \ + case E_BLOCK_NEW_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \ case E_BLOCK_NEW_LOG: return true; \ } -- cgit v1.2.3 From 0e0c9d82483e01840faf7027fc01a998d5cf2f18 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 25 Apr 2014 12:24:09 -0700 Subject: Missed these CMakeLists. --- src/Blocks/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Blocks') diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index 082ff41ac..4b8c745ad 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../") file(GLOB SOURCE "*.cpp" + "*.h" ) add_library(Blocks ${SOURCE}) -- cgit v1.2.3 From 41f6643fd20e98aebfeffef4d6bd4416526d326f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 4 May 2014 00:38:06 +0100 Subject: Fixed portal Z direction loop coding failure * Fixed portals created in the ZP/ZM direction eating its frame * Changed return type of a function --- src/Blocks/BlockFire.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index c8f158e7e..f9f32eb50 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -68,7 +68,6 @@ public: { return 0; } - for (int newY = Y + 1; newY < cChunkDef::Height; newY++) { @@ -84,7 +83,7 @@ public: // This is because the frame is a solid obsidian pillar if ((MaxY != 0) && (newY == Y + 1)) { - return EvaluatePortalBorder(X, newY, Z, MaxY, a_ChunkInterface); + return EvaluatePortalBorder(X, newY, Z, MaxY, a_ChunkInterface) ? -1 /* -1 = found a frame */ : 0; } else { @@ -99,18 +98,18 @@ public: } /// Evaluates if coords have a valid border on top, based on MaxY - int EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface) + bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface) { for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners { if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN) { // Base obsidian, base + 1 obsidian, base + x NOT obsidian -> not complete portal - return 0; + return false; } } // Everything was obsidian, found a border! - return -1; // Return -1 for a frame border + return true; } /// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) @@ -169,7 +168,7 @@ public: { return false; // Not valid slice, no portal can be formed } - } XZP = X1 - 1; // Set boundary of frame interior, note that for some reason, the loop of X and the loop of Z go to different numbers, hence -1 here and -2 there + } XZP = X1 - 1; // Set boundary of frame interior for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM) { int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY); @@ -199,13 +198,13 @@ public: if ((Value == -1) || (ValueTwo == -1)) { FoundFrameZP = true; - continue; + break; } else if ((Value != MaxY) && (ValueTwo != MaxY)) { return false; } - } XZP = Z1 - 2; + } XZP = Z1 - 1; for (; ((a_ChunkInterface.GetBlock(X, Y, Z2) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X, Y + 1, Z2) == E_BLOCK_OBSIDIAN)); Z2--) { int Value = FindObsidianCeiling(X, Y, Z2, a_ChunkInterface, MaxY); @@ -213,13 +212,13 @@ public: if ((Value == -1) || (ValueTwo == -1)) { FoundFrameZM = true; - continue; + break; } else if ((Value != MaxY) && (ValueTwo != MaxY)) { return false; } - } XZM = Z2 + 2; + } XZM = Z2 + 1; return (FoundFrameZP && FoundFrameZM); } }; -- cgit v1.2.3 From 3c102870f600178b7cabf6714f83e06fc05b42fd Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 1 May 2014 00:47:57 +0200 Subject: Add anvil window and slot area. --- src/Blocks/BlockAnvil.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index 93a796ef7..c9eec961d 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -23,6 +23,13 @@ public: { a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2)); } + + + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + { + cWindow * Window = new cAnvilWindow(); + a_Player->OpenWindow(Window); + } virtual bool GetPlacementBlockTypeMeta( -- cgit v1.2.3 From 7fe6e40bf7d40347f7f452ea2b7c353a5bc8073f Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 3 May 2014 23:42:26 +0200 Subject: Add clicks, exp subtraction, item check, ... --- src/Blocks/BlockAnvil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index c9eec961d..35a356678 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -27,7 +27,7 @@ public: virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { - cWindow * Window = new cAnvilWindow(); + cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ); a_Player->OpenWindow(Window); } -- cgit v1.2.3