From edcf1d0556c74a09b7d7b25c003da31c15d46314 Mon Sep 17 00:00:00 2001 From: FreeHij Date: Sun, 8 Oct 2023 14:10:04 +0300 Subject: [PATCH] fence --- src/API/BlockAPI.php | 10 +++++ src/constants/BlockIDs.php | 10 +++++ src/material/Block.php | 5 +++ .../block/nonfull/AcaciaFenceGateBlock.php | 44 +++++++++++++++++++ .../block/nonfull/BirchFenceGateBlock.php | 44 +++++++++++++++++++ .../block/nonfull/DarkOakFenceGateBlock.php | 44 +++++++++++++++++++ src/material/block/nonfull/FenceBlock.php | 13 +++++- .../block/nonfull/JungleFenceGateBlock.php | 44 +++++++++++++++++++ .../block/nonfull/SpruceFenceGateBlock.php | 44 +++++++++++++++++++ src/recipes/CraftingRecipes.php | 14 +++++- src/recipes/FuelData.php | 5 +++ 11 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 src/material/block/nonfull/AcaciaFenceGateBlock.php create mode 100644 src/material/block/nonfull/BirchFenceGateBlock.php create mode 100644 src/material/block/nonfull/DarkOakFenceGateBlock.php create mode 100644 src/material/block/nonfull/JungleFenceGateBlock.php create mode 100644 src/material/block/nonfull/SpruceFenceGateBlock.php diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index d15fda93..7446d159 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -139,7 +139,17 @@ class BlockAPI{ [WOODEN_DOOR, 0], [TRAPDOOR, 0], [FENCE, 0], + [FENCE, 1], + [FENCE, 2], + [FENCE, 3], + [FENCE, 4], + [FENCE, 5], [FENCE_GATE, 0], + [SPRUCE_FENCE_GATE, 0], + [BIRCH_FENCE_GATE, 0], + [JUNGLE_FENCE_GATE, 0], + [ACACIA_FENCE_GATE, 0], + [DARK_OAK_FENCE_GATE, 0], [IRON_BARS, 0], [BED, 0], [BOOKSHELF, 0], diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 8b8c4797..c6042eaf 100755 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -157,6 +157,11 @@ define("REEDS", 83); define("SUGARCANE_BLOCK", 83); define("FENCE", 85); +define("SPRUCE_FENCE", "85:1"); +define("BIRCH_FENCE", "85:2"); +define("JUNGLE_FENCE", "85:3"); +define("ACACIA_FENCE", "85:4"); +define("DARK_OAK_FENCE", "85:5"); define("PUMPKIN", 86); define("NETHERRACK", 87); define("SOUL_SAND", 88); @@ -184,6 +189,11 @@ define("PUMPKIN_STEM", 104); define("MELON_STEM", 105); define("VINES", 106); define("FENCE_GATE", 107); +define("SPRUCE_FENCE_GATE", 183); +define("BIRCH_FENCE_GATE", 184); +define("JUNGLE_FENCE_GATE", 185); +define("ACACIA_FENCE_GATE", 186); +define("DARK_OAK_FENCE_GATE", 187); define("BRICK_STAIRS", 108); define("STONE_BRICK_STAIRS", 109); define("MYCELIUM", 110); diff --git a/src/material/Block.php b/src/material/Block.php index eb93ac8c..466e9f3b 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -151,6 +151,11 @@ abstract class Block extends Position{ PODZOL => "PodzolBlock", STAINED_CLAY => "StainedClayBlock", LILY_PAD => "LilypadBlock", + SPRUCE_FENCE_GATE => "SpruceFenceGateBlock", + BIRCH_FENCE_GATE => "BirchFenceGateBlock", + JUNGLE_FENCE_GATE => "JungleFenceGateBlock", + ACACIA_FENCE_GATE => "AcaciaFenceGateBlock", + DARK_OAK_FENCE_GATE => "DarkOakFenceGate" ); protected $id; protected $meta; diff --git a/src/material/block/nonfull/AcaciaFenceGateBlock.php b/src/material/block/nonfull/AcaciaFenceGateBlock.php new file mode 100644 index 00000000..244af041 --- /dev/null +++ b/src/material/block/nonfull/AcaciaFenceGateBlock.php @@ -0,0 +1,44 @@ +isActivable = true; + if(($this->meta & 0x04) === 0x04){ + $this->isFullBlock = true; + }else{ + $this->isFullBlock = false; + } + $this->hardness = 15; + } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 3, + 1 => 0, + 2 => 1, + 3 => 2, + ); + $this->meta = $faces[$player->entity->getDirection()] & 0x03; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + public function getDrops(Item $item, Player $player){ + return array( + array($this->id, 0, 1), + ); + } + public function onActivate(Item $item, Player $player){ + $this->meta ^= 0x04; + $this->level->setBlock($this, $this, true, false, true); + $players = ServerAPI::request()->api->player->getAll($this->level); + unset($players[$player->CID]); + $pk = new LevelEventPacket; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->evid = 1003; + $pk->data = 0; + ServerAPI::request()->api->player->broadcastPacket($players, $pk); + return true; + } +} diff --git a/src/material/block/nonfull/BirchFenceGateBlock.php b/src/material/block/nonfull/BirchFenceGateBlock.php new file mode 100644 index 00000000..3f31de1a --- /dev/null +++ b/src/material/block/nonfull/BirchFenceGateBlock.php @@ -0,0 +1,44 @@ +isActivable = true; + if(($this->meta & 0x04) === 0x04){ + $this->isFullBlock = true; + }else{ + $this->isFullBlock = false; + } + $this->hardness = 15; + } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 3, + 1 => 0, + 2 => 1, + 3 => 2, + ); + $this->meta = $faces[$player->entity->getDirection()] & 0x03; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + public function getDrops(Item $item, Player $player){ + return array( + array($this->id, 0, 1), + ); + } + public function onActivate(Item $item, Player $player){ + $this->meta ^= 0x04; + $this->level->setBlock($this, $this, true, false, true); + $players = ServerAPI::request()->api->player->getAll($this->level); + unset($players[$player->CID]); + $pk = new LevelEventPacket; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->evid = 1003; + $pk->data = 0; + ServerAPI::request()->api->player->broadcastPacket($players, $pk); + return true; + } +} diff --git a/src/material/block/nonfull/DarkOakFenceGateBlock.php b/src/material/block/nonfull/DarkOakFenceGateBlock.php new file mode 100644 index 00000000..94f21070 --- /dev/null +++ b/src/material/block/nonfull/DarkOakFenceGateBlock.php @@ -0,0 +1,44 @@ +isActivable = true; + if(($this->meta & 0x04) === 0x04){ + $this->isFullBlock = true; + }else{ + $this->isFullBlock = false; + } + $this->hardness = 15; + } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 3, + 1 => 0, + 2 => 1, + 3 => 2, + ); + $this->meta = $faces[$player->entity->getDirection()] & 0x03; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + public function getDrops(Item $item, Player $player){ + return array( + array($this->id, 0, 1), + ); + } + public function onActivate(Item $item, Player $player){ + $this->meta ^= 0x04; + $this->level->setBlock($this, $this, true, false, true); + $players = ServerAPI::request()->api->player->getAll($this->level); + unset($players[$player->CID]); + $pk = new LevelEventPacket; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->evid = 1003; + $pk->data = 0; + ServerAPI::request()->api->player->broadcastPacket($players, $pk); + return true; + } +} diff --git a/src/material/block/nonfull/FenceBlock.php b/src/material/block/nonfull/FenceBlock.php index 50e1d6cc..f38f7bf1 100644 --- a/src/material/block/nonfull/FenceBlock.php +++ b/src/material/block/nonfull/FenceBlock.php @@ -1,8 +1,17 @@ "Oak Fence", + 1 => "Spruce Fence", + 2 => "Birch Fence", + 3 => "Jungle Fence", + 4 => "Acacia Fence", + 5 => "Dark Oak Fence" + ]; + $this->name = $names[$this->meta & 0x07]; $this->isFullBlock = false; $this->hardness = 15; } diff --git a/src/material/block/nonfull/JungleFenceGateBlock.php b/src/material/block/nonfull/JungleFenceGateBlock.php new file mode 100644 index 00000000..28b346d4 --- /dev/null +++ b/src/material/block/nonfull/JungleFenceGateBlock.php @@ -0,0 +1,44 @@ +isActivable = true; + if(($this->meta & 0x04) === 0x04){ + $this->isFullBlock = true; + }else{ + $this->isFullBlock = false; + } + $this->hardness = 15; + } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 3, + 1 => 0, + 2 => 1, + 3 => 2, + ); + $this->meta = $faces[$player->entity->getDirection()] & 0x03; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + public function getDrops(Item $item, Player $player){ + return array( + array($this->id, 0, 1), + ); + } + public function onActivate(Item $item, Player $player){ + $this->meta ^= 0x04; + $this->level->setBlock($this, $this, true, false, true); + $players = ServerAPI::request()->api->player->getAll($this->level); + unset($players[$player->CID]); + $pk = new LevelEventPacket; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->evid = 1003; + $pk->data = 0; + ServerAPI::request()->api->player->broadcastPacket($players, $pk); + return true; + } +} diff --git a/src/material/block/nonfull/SpruceFenceGateBlock.php b/src/material/block/nonfull/SpruceFenceGateBlock.php new file mode 100644 index 00000000..2b7f6720 --- /dev/null +++ b/src/material/block/nonfull/SpruceFenceGateBlock.php @@ -0,0 +1,44 @@ +isActivable = true; + if(($this->meta & 0x04) === 0x04){ + $this->isFullBlock = true; + }else{ + $this->isFullBlock = false; + } + $this->hardness = 15; + } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 3, + 1 => 0, + 2 => 1, + 3 => 2, + ); + $this->meta = $faces[$player->entity->getDirection()] & 0x03; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + public function getDrops(Item $item, Player $player){ + return array( + array($this->id, 0, 1), + ); + } + public function onActivate(Item $item, Player $player){ + $this->meta ^= 0x04; + $this->level->setBlock($this, $this, true, false, true); + $players = ServerAPI::request()->api->player->getAll($this->level); + unset($players[$player->CID]); + $pk = new LevelEventPacket; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->evid = 1003; + $pk->data = 0; + ServerAPI::request()->api->player->broadcastPacket($players, $pk); + return true; + } +} diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 666719f9..3dad0cd4 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -92,8 +92,18 @@ class CraftingRecipes{ //Building "WOOL:?x3,WOODEN_PLANKS:?x3=>BED:0x1", "WOODEN_PLANKS:?x8=>CHEST:0x1", - "STICK:?x6=>FENCE:0x2", - "STICK:?x4,WOODEN_PLANKS:?x2=>FENCE_GATE:0x1", + "STICK:?x2,WOODEN_PLANKS:0x4=>FENCE:0x3", + "STICK:?x2,WOODEN_PLANKS:1x4=>FENCE:1x3", + "STICK:?x2,WOODEN_PLANKS:2x4=>FENCE:2x3", + "STICK:?x2,WOODEN_PLANKS:3x4=>FENCE:3x3", + "STICK:?x2,WOODEN_PLANKS:4x4=>FENCE:4x3", + "STICK:?x2,WOODEN_PLANKS:5x4=>FENCE:5x3", + "STICK:?x4,WOODEN_PLANKS:0x2=>FENCE_GATE:0x1", + "STICK:?x4,WOODEN_PLANKS:1x2=>SPRUCE_FENCE_GATE:0x1", + "STICK:?x4,WOODEN_PLANKS:2x2=>BIRCH_FENCE_GATE:0x1", + "STICK:?x4,WOODEN_PLANKS:3x2=>JUNGLE_FENCE_GATE:0x1", + "STICK:?x4,WOODEN_PLANKS:4x2=>ACACIA_FENCE_GATE:0x1", + "STICK:?x4,WOODEN_PLANKS:5x2=>DARK_OAK_FENCE_GATE:0x1", "COBBLESTONE:?x8=>FURNACE:0x1", "GLASS:?x6=>GLASS_PANE:0x16", "STICK:?x7=>LADDER:0x2", diff --git a/src/recipes/FuelData.php b/src/recipes/FuelData.php index e0c61bab..e476cdbc 100644 --- a/src/recipes/FuelData.php +++ b/src/recipes/FuelData.php @@ -16,6 +16,11 @@ class FuelData{ STICK => 5, FENCE => 15, FENCE_GATE => 15, + SPRUCE_FENCE_GATE => 15, + BIRCH_FENCE_GATE => 15, + JUNGLE_FENCE_GATE => 15, + ACACIA_FENCE_GATE => 15, + DARK_OAK_FENCE_GATE => 15, WOODEN_STAIRS => 15, SPRUCE_WOOD_STAIRS => 15, BIRCH_WOOD_STAIRS => 15,