From fc7c14ae16489d92950329f01f85f7b53142a6ec Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 25 Nov 2013 09:34:36 +0100 Subject: [PATCH 1/5] BeetRoot soup doesn't need a class --- src/material/item/generic/BeetrootSoup.php | 26 ---------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/material/item/generic/BeetrootSoup.php diff --git a/src/material/item/generic/BeetrootSoup.php b/src/material/item/generic/BeetrootSoup.php deleted file mode 100644 index d52a60042..000000000 --- a/src/material/item/generic/BeetrootSoup.php +++ /dev/null @@ -1,26 +0,0 @@ - Date: Mon, 25 Nov 2013 09:34:57 +0100 Subject: [PATCH 2/5] Added beetroot IDs TODO: Beetroot Soup ID --- src/constants/BlockIDs.php | 1 + src/constants/ItemIDs.php | 2 +- src/material/Item.php | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 3eae94fbb..d2f572d6d 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -187,6 +187,7 @@ define("CARPET", 171); define("COAL_BLOCK", 173); +define("BEETROOT_BLOCK", 244); define("STONECUTTER", 245); define("GLOWING_OBSIDIAN", 246); define("NETHER_REACTOR", 247); diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index 7867723a4..a00dbd1c2 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -25,7 +25,6 @@ define("IRON_AXE", 258);//Implemented define("FLINT_STEEL", 259); define("FLINT_AND_STEEL", 259); define("APPLE", 260);//Implemented -define("BEETROOT_SOUP", 260);//TODO: Change Item ID define("BOW", 261); define("ARROW", 262); define("COAL", 263);//Implemented @@ -159,3 +158,4 @@ define("QUARTZ", 406); define("NETHER_QUARTZ", 406); define("CAMERA", 456); +define("BEETROOT", 457); \ No newline at end of file diff --git a/src/material/Item.php b/src/material/Item.php index 208193f74..4c4d5f79b 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -26,7 +26,6 @@ class Item{ PUMPKIN_SEEDS => "PumpkinSeedsItem", MELON_SEEDS => "MelonSeedsItem", CARROT => "CarrotItem", - BEETROOT_SOUP => "BeetrootSoupItem", POTATO => "PotatoItem", SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", From 03e71ee3ff5ae61a46d3e618c18962ba9a544c7e Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 25 Nov 2013 09:35:54 +0100 Subject: [PATCH 3/5] Added comment in Player.php --- src/Player.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Player.php b/src/Player.php index 70b622873..2f2ef6650 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1778,6 +1778,7 @@ class Player{ $items = array( APPLE => 2, MUSHROOM_STEW => 10, + //BEETROOT_SOUP => ??, BREAD => 5, RAW_PORKCHOP => 3, COOKED_PORKCHOP => 8, From fb9f7891c7696b9e99cf24d4aaa7521b644434a6 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 25 Nov 2013 09:42:41 +0100 Subject: [PATCH 4/5] Added Beetroot soup, beetroot seeds, crafting --- src/constants/ItemIDs.php | 5 +- src/material/Block.php | 3 +- src/material/Item.php | 1 + src/material/block/plant/Beetroot.php | 82 +++++++++++++++++++++ src/material/item/generic/BeetrootSeeds.php | 27 +++++++ 5 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/material/block/plant/Beetroot.php create mode 100644 src/material/item/generic/BeetrootSeeds.php diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index a00dbd1c2..f0e81dbaf 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -158,4 +158,7 @@ define("QUARTZ", 406); define("NETHER_QUARTZ", 406); define("CAMERA", 456); -define("BEETROOT", 457); \ No newline at end of file +define("BEETROOT", 457); +define("BEETROOT_SEEDS", 458); +define("BEETROOT_SEED", 458); +define("BEETROOT_SOUP", 459); \ No newline at end of file diff --git a/src/material/Block.php b/src/material/Block.php index 255645409..c7f1ffdea 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -140,7 +140,8 @@ abstract class Block extends Position{ CARPET => "CarpetBlock", COAL_BLOCK => "CoalBlock", - + + BEETROOT_BLOCK => "BeetrootBlock", STONECUTTER => "StonecutterBlock", GLOWING_OBSIDIAN => "GlowingObsidianBlock", NETHER_REACTOR => "NetherReactorBlock", diff --git a/src/material/Item.php b/src/material/Item.php index 4c4d5f79b..12a4b97e8 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -27,6 +27,7 @@ class Item{ MELON_SEEDS => "MelonSeedsItem", CARROT => "CarrotItem", POTATO => "PotatoItem", + BEETROOT_SEEDS => "BeetrootSeedsItem", SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", BUCKET => "BucketItem", diff --git a/src/material/block/plant/Beetroot.php b/src/material/block/plant/Beetroot.php new file mode 100644 index 000000000..d133d8278 --- /dev/null +++ b/src/material/block/plant/Beetroot.php @@ -0,0 +1,82 @@ +isActivable = true; + $this->hardness = 0; + } + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $down = $this->getSide(0); + if($down->getID() === FARMLAND){ + $this->level->setBlock($block, $this, true, false, true); + $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); + return true; + } + return false; + } + + public function onActivate(Item $item, Player $player){ + if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal + $this->meta = 0x07; + $this->level->setBlock($this, $this, true, false, true); + if(($player->gamemode & 0x01) === 0){ + $item->count--; + } + return true; + } + return false; + } + + public function onUpdate($type){ + if($type === BLOCK_UPDATE_NORMAL){ + if($this->getSide(0)->isTransparent === true){ //Replace with common break method + ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(BEETROOT_SEEDS, 0, 1)); + $this->level->setBlock($this, new AirBlock(), false, false, true); + return BLOCK_UPDATE_NORMAL; + } + }elseif($type === BLOCK_UPDATE_RANDOM){ + if(mt_rand(0, 2) == 1){ + if($this->meta < 0x07){ + ++$this->meta; + $this->level->setBlock($this, $this, true, false, true); + return BLOCK_UPDATE_RANDOM; + } + }else{ + return BLOCK_UPDATE_RANDOM; + } + } + return false; + } + + public function getDrops(Item $item, Player $player){ + $drops = array(); + if($this->meta >= 0x07){ + $drops[] = array(BEETROOT, 0, 1); + $drops[] = array(BEETROOT_SEEDS, 0, mt_rand(0, 3)); + }else{ + $drops[] = array(BEETROOT_SEEDS, 0, 1); + } + return $drops; + } +} \ No newline at end of file diff --git a/src/material/item/generic/BeetrootSeeds.php b/src/material/item/generic/BeetrootSeeds.php new file mode 100644 index 000000000..e94e934b8 --- /dev/null +++ b/src/material/item/generic/BeetrootSeeds.php @@ -0,0 +1,27 @@ +block = BlockAPI::get(BEETROOT_BLOCK); + parent::__construct(BEETROOT_SEEDS, 0, $count, "Beetroot Seeds"); + } +} \ No newline at end of file From 75e1a6e97e23d979382d56ecf47a557010fef6db Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 25 Nov 2013 09:52:28 +0100 Subject: [PATCH 5/5] Added bowl crafting --- src/recipes/CraftingRecipes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 328c25967..e20db2c5a 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -143,6 +143,8 @@ class CraftingRecipes{ "WOODEN_PLANKS:?x2,STICK:?x1=>WOODEN_SWORD:0x1", //Food & protection + "BEETROOT:?x4,BOWL:?x1=>BEETROOT_SOUP:0x1", + "WOODEN_PLANKS:?x3=>BOWL:0x1", "WHEAT:?x3=>BREAD:0x1", "WHEAT:?x3,BUCKET:1x3,EGG:?x1,SUGAR:?x2=>CAKE:0x1", "DIAMOND:?x4=>DIAMOND_BOOTS:0x1",