diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index 54e062321..1d79f627d 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -95,6 +95,10 @@ define("PAINTING", 321); define("GOLDEN_APPLE", 322); define("SIGN", 323); define("WOODEN_DOOR", 324); +define("BUCKET", 325); +define("WATER_BUCKET", 326); +define("LAVA_BUCKET", 327); + define("IRON_DOOR", 330); diff --git a/src/material/Item.php b/src/material/Item.php index 170684c8e..ae035f9ae 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -32,6 +32,9 @@ class Item{ MELON_SEEDS => "MelonSeedsItem", SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", + BUCKET => "BucketItem", + WATER_BUCKET => "WaterBucketItem", + LAVA_BUCKET => "LavaBucketItem", IRON_DOOR => "IronDoorItem", BED => "BedItem", PAINTING => "PaintingItem", diff --git a/src/material/item/generic/Bucket.php b/src/material/item/generic/Bucket.php new file mode 100644 index 000000000..4fa13485f --- /dev/null +++ b/src/material/item/generic/Bucket.php @@ -0,0 +1,44 @@ +isActivable = true; + $this->maxStackSize = 1; + } + + public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($target->getID() === STILL_WATER or $target->getID() === STILL_LAVA){ + $level->setBlock($target, AIR, 0); + $player->removeItem($this->getID(), $this->getMetadata(), $this->count); + $player->addItem(($target->getID() === STILL_LAVA ? LAVA_BUCKET:WATER_BUCKET), 0, 1); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/material/item/generic/LavaBucket.php b/src/material/item/generic/LavaBucket.php new file mode 100644 index 000000000..52894cada --- /dev/null +++ b/src/material/item/generic/LavaBucket.php @@ -0,0 +1,44 @@ +isActivable = true; + $this->maxStackSize = 1; + } + + public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($target->getID() === AIR){ + $level->setBlock($target, STILL_LAVA, 0); + $player->removeItem($this->getID(), $this->getMetadata(), $this->count); + $player->addItem(BUCKET, 0, 1); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/material/item/generic/WaterBucket.php b/src/material/item/generic/WaterBucket.php new file mode 100644 index 000000000..199e92d15 --- /dev/null +++ b/src/material/item/generic/WaterBucket.php @@ -0,0 +1,44 @@ +isActivable = true; + $this->maxStackSize = 1; + } + + public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($target->getID() === AIR){ + $level->setBlock($target, STILL_WATER, 0); + $player->removeItem($this->getID(), $this->getMetadata(), $this->count); + $player->addItem(BUCKET, 0, 1); + return true; + } + return false; + } +} \ No newline at end of file