commit c309a594c68aa0b754c12e524485fe145bd022a1 Author: Ad5001 Date: Sun Feb 12 17:57:36 2017 +0100 Adding plugin diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..05401b0 --- /dev/null +++ b/config.yml @@ -0,0 +1,4 @@ +--- +# This is the default config generated with ImagicalPlugCreator. (C) ImagicalPlugCreator - Ad5001 2016 +version: 1.0 +... \ No newline at end of file diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..1f64159 --- /dev/null +++ b/plugin.yml @@ -0,0 +1,16 @@ +--- +# ____ _ _ ____ _ _ +# | __ ) ___ | |_ | |_ ___ _ __ | __ ) | | ___ ___ | | __ ___ +# | _ \ / _ \ | __| | __| / _ \ | '__| | _ \ | | / _ \ / __| | |/ / / __| +# | |_) | | __/ | |_ | |_ | __/ | | | |_) | | | | (_) | | (__ | < \__ \ +# |____/ \___| \__| \__| \___| |_| |____/ |_| \___/ \___| |_|\_\ |___/ +# +# Extends your Minecraft PE blocks palette ! For PocketMine. +name: BetterBlocks +author: Ad5001 +version: 1.0 +api: [2.0.0] +main: Ad5001\BetterBlocks\Main +commands: +permissions: [] +... \ No newline at end of file diff --git a/resources/config.yml b/resources/config.yml new file mode 100644 index 0000000..05401b0 --- /dev/null +++ b/resources/config.yml @@ -0,0 +1,4 @@ +--- +# This is the default config generated with ImagicalPlugCreator. (C) ImagicalPlugCreator - Ad5001 2016 +version: 1.0 +... \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/CustomBlockData.php b/src/Ad5001/BetterBlocks/CustomBlockData.php new file mode 100644 index 0000000..2f776d7 --- /dev/null +++ b/src/Ad5001/BetterBlocks/CustomBlockData.php @@ -0,0 +1,14 @@ +Fallable)) $nbt->Fallable = new StringTag("Fallable", "true"); + parent::__construct($chunk, $nbt); + } + + + /* + Sets if the block can fall when a player walks on it. + @param $fallable bool + */ + public function setFallable(bool $fallable) { + if($fallable) { + $this->namedtag->Fallable->setValue("true"); + } else { + $this->namedtag->Fallable->setValue("false"); + } + return $this; + } + + + /* + Check if the block is fallable. + @return bool + */ + public function isFallable() : bool { + if($this->namedtag->Fallable->getValue() == "false") { + return false; + } + return true; + } + + + /* + Makes the block fall + */ + public function fall() { + if($this->level->getBlock($this->getSide(Vector3::SIDE_DOWN))->getId() == 0 || $this->level->getBlock($this->getSide(Vector3::SIDE_DOWN)) instanceof \pocketmine\block\Liquid) { + $fall = \pocketmine\entity\Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $this->x + 0.5), + new DoubleTag("", $this->y), + new DoubleTag("", $this->z + 0.5) + ]), + "Motion" => new ListTag("Motion", [ + new DoubleTag("", 0), + new DoubleTag("", 0), + new DoubleTag("", 0) + ]), + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", 0), + new FloatTag("", 0) + ]), + "TileID" => new IntTag("TileID", $this->getBlock()->getId()), + "Data" => new ByteTag("Data", $this->getBlock()->getDamage()), + ]))->spawnToAll(); + // $this->getLevel()->setBlock($this, Block::get(0, 0)); + } + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/CustomBlockData/GraveTile.php b/src/Ad5001/BetterBlocks/CustomBlockData/GraveTile.php new file mode 100644 index 0000000..e15dbab --- /dev/null +++ b/src/Ad5001/BetterBlocks/CustomBlockData/GraveTile.php @@ -0,0 +1,112 @@ + "Didn't saw the cactus in his path", + EDE::CAUSE_ENTITY_ATTACK => "Slain by %1", + EDE::CAUSE_PROJECTILE => "Shot by %1", + EDE::CAUSE_SUFFOCATION => "Suffocated in a wall", + EDE::CAUSE_FALL => "Failed his MLG", + EDE::CAUSE_FIRE => "Went up in flames", + EDE::CAUSE_FIRE_TICK => "Burnt to death", + EDE::CAUSE_LAVA => "Tried to swim in lava", + EDE::CAUSE_BLOCK_EXPLOSION => "Trapped with TNT", + EDE::CAUSE_ENTITY_EXPLOSION => "Blown up by a failed pig", + EDE::CAUSE_VOID => "You shouldn't see this sign...", + EDE::CAUSE_SUICIDE => "Suicided", + EDE::CAUSE_MAGIC => "Messed with a witch", + EDE::CAUSE_CUSTOM => "Unknown", + EDE::CAUSE_STARVATION => "Was to hungry to even eat" + ]; + + public function __construct(Chunk $chunk, CompoundTag $nbt){ + if(!isset($nbt->Items)) { + $nbt->Items = new ListTag("Items", []); + $nbt->Items->setTagType(NBT::TAG_Compound); + foreach(Server::getInstance()->getPlayer($nbt->Player->getValue())->getInventory()->getContents() as $key => $content) { + $nbt->Items[$index] = $content->nbtSerialize(); + } + } + parent::__construct($chunk, $nbt); + if(isset($nbt->Params)) { + $this->level->setBlock($this, \pocketmine\block\Block::get(4, 0)); + $v3 = $this->getSide(Vector3::SIDE_NORTH); + $this->level->setBlock($v3, \pocketmine\block\Block::get(68, 2)); + $dm = self::MESSAGES[$nbt->DeathCause]; + if(isset($nbt->Params[1])) $dm = str_ireplace("%1", $nbt->Params[1], $dm); + $t = Tile::createTile("Sign", $this->level->getChunk($v3->x >> 4, $v3->z >> 4), NBT::parseJSON(json_encode(["x" => $v3->x, "y" => $v3->y, "z" => $v3->z, "Text1" => "§a-=<>=-", "Text2" => "R.I.P", "Text3" => $nbt->Player, "Text4" => $dm], JSON_FORCE_OBJECT))); + $t->setText("§a-=<>=-", "R.I.P", $nbt->Player, $dm); + unset($nbt->Params); + } + } + + + /* + Return the item from it's index. + @param $index int + @return Item + */ + public function getItem($index) { + return isset($this->namedtag->Items->{$index}) ? $this->namedtag->Items->{$index} : Item::get(0, 0); + } + + + /* + Sets an item to it's index. + @param $index int + @param $item \pocketmine\item\Item + */ + public function setItem($index, \pocketmine\item\Item $item) { + $this->namedtag->Items->{$index} = $item; + return $this; + } + + /* + Returns the size of the Inventory + */ + public function getSize() { + return 40; + } + + + + /* + Drops all the contents of the grave on the ground (when a player goes on it) + */ + public function drop() { + foreach($this->namedtag->Items as $item) { + $item = Item::nbtDeserialize($item); + $this->getLevel()->dropItem($this, $item, new \pocketmine\math\Vector3(0, 0.001, 0), 0); + } + } +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/CustomBlockData/RedstonePoweringTile.php b/src/Ad5001/BetterBlocks/CustomBlockData/RedstonePoweringTile.php new file mode 100644 index 0000000..83662e5 --- /dev/null +++ b/src/Ad5001/BetterBlocks/CustomBlockData/RedstonePoweringTile.php @@ -0,0 +1,25 @@ +Sound)) $nbt->Sound = new StringTag("Sound", self::SOUND(rand(0, count(self::SOUNDS) - 1))); // TODO: Customize the sound + parent::__construct($chunk, $nbt); + } + + + /* + Sets the sound of the Block + @param $sound string + @return bool + */ + public function setSound(string $sound) : bool { + if(in_array($sound, self::SOUNDS)) { + $this->namedtag->Sound->setValue($sound); + return true; + } + return false;; + } + + /* + Gets the current used sound + @return string + */ + public function getSound() : string { + return $this->namedtag->Sound->getValue(); + } + + + /* + Plays the sound + */ + public function play() { + $s = "\\pocketmine\\level\\sound\\" . $this->namedtag->Sound->getValue(); + $this->getLevel()->addSound(new $s($this)); + } + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/CustomBlockData/StickTile.php b/src/Ad5001/BetterBlocks/CustomBlockData/StickTile.php new file mode 100644 index 0000000..504d4f9 --- /dev/null +++ b/src/Ad5001/BetterBlocks/CustomBlockData/StickTile.php @@ -0,0 +1,62 @@ +Stickable)) $nbt->Stickable = new StringTag("Stickable", "true"); + parent::__construct($chunk, $nbt); + } + + + /* + Sets if the block can stick when a player walks on it. + @param $stickable bool + */ + public function setStickable(bool $stickable) { + if($stickable) { + $this->namedtag->Stickable->setValue("true"); + } else { + $this->namedtag->Stickable->setValue("false"); + } + return $this; + } + + + /* + Check if the block is stickable. + @return bool + */ + public function isStickable() : bool { + if($this->namedtag->Stickable->getValue() == "false") { + return false; + } + return true; + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/CustomBlockData/TrapTile.php b/src/Ad5001/BetterBlocks/CustomBlockData/TrapTile.php new file mode 100644 index 0000000..00a0312 --- /dev/null +++ b/src/Ad5001/BetterBlocks/CustomBlockData/TrapTile.php @@ -0,0 +1,62 @@ +TrapActive)) $nbt->TrapActive = new StringTag("TrapActive", "true"); + parent::__construct($chunk, $nbt); + } + + + /* + Sets if the trap is active + @param $trapActive bool + */ + public function setTrapActive(bool $trapActive) { + if($trapActive) { + $this->namedtag->TrapActive->setValue("true"); + } else { + $this->namedtag->TrapActive->setValue("false"); + } + return $this; + } + + + /* + Check if the trap is active. + @return bool + */ + public function isTrapActive() : bool { + if($this->namedtag->TrapActive->getValue() == "false") { + return false; + } + return true; + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/CustomBlockData/VacuumTile.php b/src/Ad5001/BetterBlocks/CustomBlockData/VacuumTile.php new file mode 100644 index 0000000..aa7850b --- /dev/null +++ b/src/Ad5001/BetterBlocks/CustomBlockData/VacuumTile.php @@ -0,0 +1,66 @@ +AttractRadius)) $nbt->AttractRadius = new IntTag("AttractRadius", 5); + parent::__construct($chunk, $nbt); + } + + + /* + Sets the attracting radius of the vacuum hopper + @param $radius int + */ + public function setAttractRadius(int $radius) { + $this->namedtag->AttractRadius->setValue($radius); + return $this; + } + + + /* + Get the radius of attractivity of the Vacuum Hopper. + @return int + */ + public function getAttractRadius() : int { + return (int) $this->namedtag->AttractRadius->getValue(); + } + + /* + Attracts all blocks in the defined radius. + */ + public function attract() { + foreach ($this->getLevel()->getEntities() as $et) { + if($et->x < $this->x + $this->namedtag->AttractRadius->getValue() && $et->x > $this->x - $this->namedtag->AttractRadius->getValue() && + $et->y < $this->y + $this->namedtag->AttractRadius->getValue() && $et->y > $this->y - $this->namedtag->AttractRadius->getValue() && + $et->z < $this->z + $this->namedtag->AttractRadius->getValue() && $et->z > $this->z - $this->namedtag->AttractRadius->getValue()) { + $et->teleport(new Vector3($this->x, $this->y + 1, $this->z)); + } + } + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/Dummy3.php b/src/Ad5001/BetterBlocks/Dummy3.php new file mode 100644 index 0000000..79b7790 --- /dev/null +++ b/src/Ad5001/BetterBlocks/Dummy3.php @@ -0,0 +1,42 @@ +main = $main; + + + $this->server = $main->getServer() + + + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/Main.php b/src/Ad5001/BetterBlocks/Main.php new file mode 100644 index 0000000..3f1201d --- /dev/null +++ b/src/Ad5001/BetterBlocks/Main.php @@ -0,0 +1,236 @@ +setCustomName("§rSticky Slime Block"); + $ssb->setNamedTag(NBT::parseJSON('{"isStickable":"true"}')); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($ssb, 3, 3))->addIngredient(1, 1, $ep)->addIngredient(1, 2, Item::get(165, 0))); + // Vacuum Hopper + $vh = Item::get(410, 0); + $vh->setNamedTag(NBT::parseJSON('{"isVacuum":"true"}')); + $vh->setCustomName("§rVacuum Item Hopper"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($vh, 3, 3))->addIngredient(1, 0, $ep)->addIngredient(0, 0, Item::get(410, 0))->addIngredient(0, 1, Item::get(49, 0))); + // Trappers (used to create trap blocks) + $vh = Item::get(69, 0); + $vh->setNamedTag(NBT::parseJSON('{"isTrapper":"true"}')); + $vh->setCustomName("§rTrapper"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($vh, 3, 3))->addIngredient(1, 1, Item::get(70, 0))->addIngredient(0, 0, Item::get(331, 0))); + // Hammes (for fallable blocks) + // Wooden + $wt = Item::get(271, 0); + $wt->setNamedTag(NBT::parseJSON('{"isHammer":"true"}')); + $wt->setCustomName("§rWooden Hammer"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($wt, 3, 3))->addIngredient(2, 0, Item::get(280, 0))->addIngredient(1, 1, Item::get(280, 0))->addIngredient(0, 1, Item::get(5, 0))->addIngredient(0, 2, Item::get(5, 0))->addIngredient(1, 2, Item::get(5, 0))); + // Stone + $wt = Item::get(275, 0); + $wt->setNamedTag(NBT::parseJSON('{"isHammer":"true"}')); + $wt->setCustomName("§rStone Hammer"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($wt, 3, 3))->addIngredient(2, 0, Item::get(280, 0))->addIngredient(1, 1, Item::get(280, 0))->addIngredient(0, 1, Item::get(4, 0))->addIngredient(0, 2, Item::get(4, 0))->addIngredient(1, 2, Item::get(4, 0))); + // Iron + $wt = Item::get(258, 0); + $wt->setNamedTag(NBT::parseJSON('{"isHammer":"true"}')); + $wt->setCustomName("§rIron Hammer"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($wt, 3, 3))->addIngredient(2, 0, Item::get(280, 0))->addIngredient(1, 1, Item::get(280, 0))->addIngredient(0, 1, Item::get(265, 0))->addIngredient(0, 2, Item::get(265, 0))->addIngredient(1, 2, Item::get(265, 0))); + // Gold + $wt = Item::get(286, 0); + $wt->setNamedTag(NBT::parseJSON('{"isHammer":"true"}')); + $wt->setCustomName("§rGold Hammer"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($wt, 3, 3))->addIngredient(2, 0, Item::get(280, 0))->addIngredient(1, 1, Item::get(280, 0))->addIngredient(0, 1, Item::get(266, 0))->addIngredient(0, 2, Item::get(266, 0))->addIngredient(1, 2, Item::get(266, 0))); + // Diamond + $wt = Item::get(279, 0); + $wt->setNamedTag(NBT::parseJSON('{"isHammer":"true"}')); + $wt->setCustomName("§rDiamond Hammer"); + $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($wt, 3, 3))->addIngredient(2, 0, Item::get(280, 0))->addIngredient(1, 1, Item::get(280, 0))->addIngredient(0, 1, Item::get(264, 0))->addIngredient(0, 2, Item::get(264, 0))->addIngredient(1, 2, Item::get(264, 0))); + + + // Registering tiles + Tile::registerTile(FallableTile::class); + Tile::registerTile(GraveTile::class); + Tile::registerTile(RedstonePoweringTile::class); + Tile::registerTile(SoundHolderTile::class); + Tile::registerTile(StickTile::class); + Tile::registerTile(VacuumTile::class); + + $this->getServer()->getPluginManager()->registerEvents($this, $this); + $this->saveDefaultConfig(); + } + + + + /* + When a custom block item is placed (Sticcky Slime Blocks, Vaccum hoppers and for Trap Blocks) + @param $event \pocketmine\event\block\BlockPlaceEvent + @retu + */ + public function onBlockPlace(\pocketmine\event\block\BlockPlaceEvent $event) { + if(isset($event->getItem()->getNamedTag()->isStickable) && $event->getItem()->getNamedTag()->isStickable->getValue() == "true") { + Tile::createTile("StickTile", $event->getBlock()->getLevel()->getChunk($event->getBlock()->x >> 4, $event->getBlock()->z >> 4), NBT::parseJSON(json_encode([$event->getBlock()->x, $event->getBlock()->y, $event->getBlock()->z], JSON_FORCE_OBJECT))); + } elseif(isset($event->getItem()->getNamedTag()->isVacuum) && $event->getItem()->getNamedTag()->isVacuum->getValue() == "true") { + Tile::createTile("VacuumTile", $event->getBlock()->getLevel()->getChunk($event->getBlock()->x >> 4, $event->getBlock()->z >> 4), NBT::parseJSON(json_encode([$event->getBlock()->x, $event->getBlock()->y, $event->getBlock()->z], JSON_FORCE_OBJECT))); + } elseif(isset($event->getItem()->getNamedTag()->isTrapper) && $event->getItem()->getNamedTag()->isTrapper->getValue() == "true") { + Tile::createTile("TrapTile", $event->getBlock()->getLevel()->getChunk($event->getBlock()->x >> 4, $event->getBlock()->z >> 4), NBT::parseJSON(json_encode([$event->getBlock()->x, $event->getBlock()->y - 1, $event->getBlock()->z], JSON_FORCE_OBJECT))); + $this->getServer()->getScheduler()->scheduleDelayedTask(new BlockRegenerateTask($this, Block::get(0, 0), $event->getBlock()->getLevel()), 30); // Clears the lever + } + } + + + /* + Checks when a block breaks to drop the item if custom block. + @param $event BlockBreakEvent + */ + public function onBlockBreak(BlockBreakEvent $event) { + //1 + $block = $event->getBlock(); + if($event->getBlock()->getLevel()->getTile($block) instanceof CustomBlockData && !$event->isCancelled()) { + switch(substr(get_class($event->getBlock()->getLevel()->getTile($block)), 36)) { + case "GraveTile": + $event->getBlock()->getLevel()->getTile($block)->drop(); + break; + case "RedstonePoweringTile": + $redstoneblock = Item::get(152, 0); + $event->setDrops(array_merge([$redstoneblock], $event->getDrops())); + break; + case "SoundHolderTile": + $noteblock = Item::get(25, 0); + $event->setDrops(array_merge([$noteblock], $event->getDrops())); + break; + case "StickTile": + $ssb = Item::get(165, 0); + $ssb->setCustomName("§rSticky Slime Block"); + $ssb->setNamedTag(NBT::parseJSON('{"isStickable":"true"}')); + $event->setDrops([$ssb]); + break; + case "TrapTile": + break; + case "VacuumTile": + $vh = Item::get(410, 0); + $vh->setNamedTag(NBT::parseJSON('{"isVacuum":"true"}')); + $vh->setCustomName("§rVacuum Item Hopper"); + $event->setDrops([$vh]); + break; + } + } + } + + + + /* + Check if a player touches a block. Check if he right clicks ill a hammer. + @param $event \pocketmine\event\player\PlayerInteractEvent + */ + public function onInteract(\pocketmine\event\player\PlayerInteractEvent $event) { + if(isset($event->getItem()->getNamedTag()->isHammer) && $event->getItem()->getNamedTag()->isHammer == "true" && !($event->getBlock() instanceof \pocketmine\block\Fallable) && !($event->getBlock()->getLevel()->getTile($event->getBlock()) instanceof Tile)) { + Tile::createTile("FallableTile", $event->getBlock()->getLevel()->getChunk($event->getBlock()->x >> 4, $event->getBlock()->z >> 4), NBT::parseJSON('{"x":"'.$event->getBlock()->x.'","y":"' .$event->getBlock()->y.'","z":"'. $event->getBlock()->z . '"}')); + $event->getPlayer()->sendPopup("This block seems now unstable... You shouldn't walk on it..."); + } + } + + + /* + Detects when a player drops an item to set it as "Droped by the player" to build some custom blocks. + @param $event \pocketmine\event\player\PlayerDropItemEvent + */ + public function onPlayerItemDrop(\pocketmine\event\player\PlayerDropItemEvent $event) { + $event->getItem()->setNamedTag(NBT::parseJSON('{"isDropedByPlayer":"true"}')); + } + + + /* + Checks when a player death to set up a grave. + @param $event \pocketmine\event\player\PlayerDeathEvent + */ + public function onPlayerDeath(\pocketmine\event\player\PlayerDeathEvent $event) { + $player = $event->getPlayer(); + $cause = $player->getLastDamageCause(); + $nbt = NBT::parseJSON(json_encode([ + "x" => $player->x, + "y" => $player->y, + "z" => $player->z, + "Player" => $player->getName(), + "DeathCause" => $cause == null ? 14 : $cause->getCause(), + "Params" => $event->getDeathMessage()->getParameters() + ], JSON_FORCE_OBJECT)); + $nbt->Items = new ListTag("Items", []); + $nbt->Items->setTagType(NBT::TAG_Compound); + foreach($event->getDrops() as $index => $content) { + $nbt->Items[$index] = $content->nbtSerialize(); + } + $event->setDrops([]); + Tile::createTile("GraveTile", $player->getLevel()->getChunk($player->x >> 4, $player->z >> 4), $nbt); + } + + + /* + Checks when a player moves to 1) Trigger traps blocks, 2) Set person as sticky 3) Makes fallable block fall if a player walks on it. + @param $event \pocketmine\event\player\PlayerMoveEvent + */ + public function onPlayerMove(\pocketmine\event\player\PlayerMoveEvent $event) { + $v3Under = $event->getPlayer()->round(); + $v3Under->y--; + $v3Upper = $event->getPlayer()->round(); + $v3Upper->y += 2; + $tileUnder = $event->getPlayer()->getLevel()->getTile($v3Under); + $tileUpper = $event->getPlayer()->getLevel()->getTile($v3Upper); + + // 1) + if($tileUnder instanceof TrapTile) { + $block = clone $event->getPlayer()->getLevel()->getBlock($v3Under); + $event->getPlayer()->getLevel()->setBlock($v3Under, Block::get(0, 0)); + $this->getServer()->getScheduler()->scheduleDelayedTask(new BlockRegenerateTask($this, $block, $event->getPlayer()->getLevel()), 30); + } + // 2) + if($tileUnder instanceof StickTile || $tileUpper instanceof StickTile) { + $event->getPlayer()->setMotion($event->getPlayer()->getMotion()->x, 0, $event->getPlayer()->getMotion()->z); + } + // 3) + if($tileUnder instanceof FallableTile) { + $tileUnder->fall(); + } + } + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/tasks/AttractTask.php b/src/Ad5001/BetterBlocks/tasks/AttractTask.php new file mode 100644 index 0000000..e6c1de3 --- /dev/null +++ b/src/Ad5001/BetterBlocks/tasks/AttractTask.php @@ -0,0 +1,55 @@ +main = $main; + $this->server = $main->getServer(); + } + + + + + public function onRun($tick) { + foreach($this->server->getLevels() as $level) { + foreach($level->getTiles() as $tile) { + if($tile instanceof VacuumTile) { + + } + } + } + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/tasks/BlockRegenerateTask.php b/src/Ad5001/BetterBlocks/tasks/BlockRegenerateTask.php new file mode 100644 index 0000000..4bc3a5f --- /dev/null +++ b/src/Ad5001/BetterBlocks/tasks/BlockRegenerateTask.php @@ -0,0 +1,49 @@ +main = $main; + $this->server = $main->getServer(); + $this->block = $block; + $this->lvl = $lvl; + } + + + + + public function onRun($tick) { + $this->lvl->setBlock($this->block, $this->block); // Delays a the block setting. + $this->lvl->setBlock($this->block, $this->block); // Levers are not deleting + $this->main->getLogger()->debug($this->lvl->getBlock($this->block)); + } + + + + +} \ No newline at end of file diff --git a/src/Ad5001/BetterBlocks/tasks/Drop2CraftTask.php b/src/Ad5001/BetterBlocks/tasks/Drop2CraftTask.php new file mode 100644 index 0000000..bafc19e --- /dev/null +++ b/src/Ad5001/BetterBlocks/tasks/Drop2CraftTask.php @@ -0,0 +1,84 @@ +main = $main; + $this->server = $main->getServer(); + } + + + + + public function onRun($tick) { + foreach($this->server->getLevels() as $level) { + foreach($level->getEntities() as $et) { + if($et instanceof EtItem && isset($et->getItem()->getNamedTag()->isDropedByPlayer)) { + switch($et->getItem()->getId()) { + case 152: // Redstone block: For the Redstone Powering Block + $v3 = $et->round(); + $v3->y--; + if($et->getLevel()->getBlock($v3)->isSolid()) { + Tile::createTile("RedstonePoweringTile", $this->getLevel()->getChunk($et->x >> 4, $et->z >> 4), NBT::parseJSON(json_encode([$v3->x, $v3->y, $v3->z]))); + $et->close(); + } + break; + case 25: // Note block: For the Sound Holding block. + $v3 = $et->round(); + $v3->y--; + if($et->getLevel()->getBlock($v3)->isSolid()) { + Tile::createTile("SoundHolderTile", $this->getLevel()->getChunk($et->x >> 4, $et->z >> 4), NBT::parseJSON(json_encode([$v3->x, $v3->y, $v3->z]))); + $et->close(); + } + break; + case 69: // Levers drops + $v3 = $et->round(); + $v3->y--; + if($et->getLevel()->getBlock($v3)->isSolid() && isset($et->getItem()->getNamedTag()->isTrapper)) { + Tile::createTile("TrapTile", $v3->getLevel()->getChunk($v3->x >> 4, $v3->z >> 4), NBT::parseJSON(json_encode([$v3->x, $v3->y - 1, $v3->z]))); + $et->close(); + } + break; + } + } + } + } + } + + + + +} \ No newline at end of file