From 1ad00a453bec2c781bab43379333ae3089cdd6be Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 16:36:30 +0100 Subject: [PATCH] Added Iron bars, Pumpkins, lit pumpkins and pumpkin grow, pumpkin growth, pumpkin seeds, pumpkin pie... --- src/Player.php | 1 + src/constants/BlockIDs.php | 9 ++- src/constants/ItemIDs.php | 4 +- src/material/Block.php | 6 +- src/material/Item.php | 1 + src/material/block/nonfull/IronBars.php | 27 +++++++ src/material/block/plant/PumpkinStem.php | 87 ++++++++++++++++++++++ src/material/block/solid/LitPumpkin.php | 28 +++++++ src/material/block/solid/Pumpkin.php | 28 +++++++ src/material/block/solid/Sponge.php | 2 +- src/material/item/generic/PumpkinSeeds.php | 27 +++++++ src/recipes/CraftingRecipes.php | 6 +- 12 files changed, 219 insertions(+), 7 deletions(-) create mode 100644 src/material/block/nonfull/IronBars.php create mode 100644 src/material/block/plant/PumpkinStem.php create mode 100644 src/material/block/solid/LitPumpkin.php create mode 100644 src/material/block/solid/Pumpkin.php create mode 100644 src/material/item/generic/PumpkinSeeds.php diff --git a/src/Player.php b/src/Player.php index b132105cf..82b6f54b7 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1721,6 +1721,7 @@ class Player{ RAW_CHICKEN => 2, MELON_SLICE => 2, GOLDEN_APPLE => 10, + PUMPKIN_PIE => 8, //COOKIE => 2, //COOKED_FISH => 5, //RAW_FISH => 2, diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 0bac016c9..19596520e 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -120,12 +120,15 @@ define("REEDS", 83); define("SUGARCANE_BLOCK", 83); define("FENCE", 85); - +define("PUMPKIN", 86); define("NETHERRACK", 87); define("SOUL_SAND", 88); define("GLOWSTONE", 89); define("GLOWSTONE_BLOCK", 89); + +define("LIT_PUMPKIN", 91); +define("JACK_O_LANTERN", 91); define("CAKE_BLOCK", 92); define("TRAPDOOR", 96); @@ -133,10 +136,12 @@ define("TRAPDOOR", 96); define("STONE_BRICKS", 98); define("STONE_BRICK", 98); +define("IRON_BAR", 101); +define("IRON_BARS", 101); define("GLASS_PANE", 102); define("GLASS_PANEL", 102); define("MELON_BLOCK", 103); - +define("PUMPKIN_STEM", 104); define("MELON_STEM", 105); define("FENCE_GATE", 107); diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index 276e8a4ee..372719f78 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -132,7 +132,7 @@ define("BED", 355); define("SHEARS", 359); define("MELON", 360); define("MELON_SLICE", 360); - +define("PUMPKIN_SEEDS", 361); define("MELON_SEEDS", 362); define("RAW_BEEF", 363); define("STEAK", 364); @@ -143,6 +143,8 @@ define("COOKED_CHICKEN", 366); define("SPAWN_EGG", 383); +define("PUMPKIN_PIE", 400); + define("NETHER_BRICK", 405); define("QUARTZ", 406); define("NETHER_QUARTZ", 406); diff --git a/src/material/Block.php b/src/material/Block.php index 1b4cf80e6..b340856fb 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -95,20 +95,22 @@ abstract class Block extends Position{ SUGARCANE_BLOCK => "SugarcaneBlock", FENCE => "FenceBlock", - + PUMPKIN => "PumpkinBlock", NETHERRACK => "NetherrackBlock", SOUL_SAND => "SoulSandBlock", GLOWSTONE_BLOCK => "GlowstoneBlock", + LIT_PUMPKIN => "LitPumpkinBlock", CAKE_BLOCK => "CakeBlock", TRAPDOOR => "TrapdoorBlock", STONE_BRICKS => "StoneBricksBlock", + IRON_BARS => "IronBarsBlock", GLASS_PANE => "GlassPaneBlock", MELON_BLOCK => "MelonBlock", - + PUMPKIN_STEM => "PumpkinStemBlock", MELON_STEM => "MelonStemBlock", FENCE_GATE => "FenceGateBlock", diff --git a/src/material/Item.php b/src/material/Item.php index f7e11089c..f09480f5e 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -23,6 +23,7 @@ class Item{ public static $class = array( SUGARCANE => "SugarcaneItem", WHEAT_SEEDS => "WheatSeedsItem", + PUMPKIN_SEEDS => "PumpkinSeedsItem", MELON_SEEDS => "MelonSeedsItem", SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", diff --git a/src/material/block/nonfull/IronBars.php b/src/material/block/nonfull/IronBars.php new file mode 100644 index 000000000..11136b2d4 --- /dev/null +++ b/src/material/block/nonfull/IronBars.php @@ -0,0 +1,27 @@ +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 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(PUMPKIN_SEEDS, 0, mt_rand(0, 2))); + $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{ + for($side = 2; $side <= 5; ++$side){ + $b = $this->getSide($side); + if($b->getID() === PUMPKIN){ + return BLOCK_UPDATE_RANDOM; + } + } + $side = $this->getSide(mt_rand(2,5)); + $d = $side->getSide(0); + if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){ + $this->level->setBlock($side, new PumpkinBlock(), true, false, true); + } + } + } + return BLOCK_UPDATE_RANDOM; + } + 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 getDrops(Item $item, Player $player){ + return array( + array(PUMPKIN_SEEDS, 0, mt_rand(0, 2)), + ); + } +} \ No newline at end of file diff --git a/src/material/block/solid/LitPumpkin.php b/src/material/block/solid/LitPumpkin.php new file mode 100644 index 000000000..cebe24968 --- /dev/null +++ b/src/material/block/solid/LitPumpkin.php @@ -0,0 +1,28 @@ +hardness = 5; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/Pumpkin.php b/src/material/block/solid/Pumpkin.php new file mode 100644 index 000000000..e69e96df8 --- /dev/null +++ b/src/material/block/solid/Pumpkin.php @@ -0,0 +1,28 @@ +hardness = 5; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/Sponge.php b/src/material/block/solid/Sponge.php index 1a671d43f..9c3cdba4e 100644 --- a/src/material/block/solid/Sponge.php +++ b/src/material/block/solid/Sponge.php @@ -21,7 +21,7 @@ class SpongeBlock extends SolidBlock{ public function __construct(){ - parent::__construct(SPONGE, $meta, "Sponge"); + parent::__construct(SPONGE, "Sponge"); $this->hardness = 3; } diff --git a/src/material/item/generic/PumpkinSeeds.php b/src/material/item/generic/PumpkinSeeds.php new file mode 100644 index 000000000..b615bb5dd --- /dev/null +++ b/src/material/item/generic/PumpkinSeeds.php @@ -0,0 +1,27 @@ +block = BlockAPI::get(PUMPKIN_STEM); + parent::__construct(PUMPKIN_SEEDS, 0, $count, "Pumpkin Seeds"); + } +} \ No newline at end of file diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 62e7395a9..df1967e90 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -25,6 +25,7 @@ class CraftingRecipes{ "CLAY:?x4=>CLAY_BLOCK:0x1", "WOODEN_PLANKS:?x4=>WORKBENCH:0x1", "GLOWSTONE_DUST:?x4=>GLOWSTONE_BLOCK:0x1", + "PUMPKIN:?x1,TORCH:?x1=>LIT_PUMPKIN:0x1", "SNOWBALL:?x4=>SNOW_BLOCK:0x1", "WOODEN_PLANKS:?x2=>STICK:0x4", "COBBLESTONE:?x4=>STONECUTTER:0x1", @@ -55,7 +56,10 @@ class CraftingRecipes{ "COAL:0x1,STICK:?x1=>TORCH:0x4", "COAL:1x1,STICK:?x1=>TORCH:0x4", - //Food & protection + //Food & protection + "MELON_SLICE:?x1=>MELON_SEEDS:0x1", + "PUMPKIN:?x1=>PUMPKIN_SEEDS:0x4", + "PUMPKIN:?x1,EGG:?x1,SUGAR:?x1=>PUMPKIN_PIE:0x1", "BROWN_MUSHROOM:?x1,RED_MUSHROOM:?x1,BOWL:?x1=>MUSHROOM_STEW:0x1", "SUGARCANE:?x1=>SUGAR:0x1", "MELON_SLICE:?x1=>MELON_SEEDS:0x1",