Fixing almost everything + README !
(just need to finish Trap Blocks)
This commit is contained in:
parent
020718b525
commit
a2dba5e17f
5 changed files with 88 additions and 18 deletions
BIN
Banner.png
Normal file
BIN
Banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
49
README.md
Normal file
49
README.md
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
![banner](https://raw.githubusercontent.com/Ad5001/BetterBlocks/master/Banner.png)
|
||||||
|
Are normal minecraft blocks features enought for you?
|
||||||
|
If not, discover 6 (soon 7) features that changes how will your player see blocks !
|
||||||
|
|
||||||
|
## Blocks that gets a variant:
|
||||||
|
### 1. Sticky Slime blocks:
|
||||||
|
These blocks are variants of slime blocks that can be crafted using a slime block and an ender pearl.
|
||||||
|
When a player walks under this block, he cannot fall down !
|
||||||
|
When a player walks on this block, he cannot jump !
|
||||||
|
Please note that this feature is not supported by PocketMine-MP by the PMMP team.
|
||||||
|
|
||||||
|
Usability: Jumps, traps, and many other things !
|
||||||
|
### 2. Vacuum Hoppers:
|
||||||
|
These blocks are varients of hoppers ported from [Open Blocks](https://github.com/OpenMods/OpenBlocks) are hoppers that attract blocks from a **3 blocks** distance.
|
||||||
|
They can be crafted using a hopper, an ender pearl, and an obsidian in a crafting table !
|
||||||
|
Please note that this feature is not supported by PocketMine-MP by the PMMP team.
|
||||||
|
|
||||||
|
Usability: Farms, Redstone systems, and many other things.
|
||||||
|
## Features that can be applied to any block:
|
||||||
|
### 3. Fallable blocks:
|
||||||
|
Uppon walking on this blocks, it falls as sand, gravel or any other blocks !
|
||||||
|
To create them, it's a bit difficulter that before:
|
||||||
|
First of, craft an **hammer** using 3 materials (that could be wood planks, cobblestone, iron, gold, or diamond) along with 2 sticks).
|
||||||
|
Then hit any block to make it fallable.
|
||||||
|
|
||||||
|
Usability: Jumps, traps, world generation, and many other things.
|
||||||
|
### 4. Sound blocks:
|
||||||
|
These blocks plays a predefined sound when a player walks on it.
|
||||||
|
Drop a noteblock on it to make transform it as a Sound Block.
|
||||||
|
Hit it to change it's sound (you'll receive a popup with the choosen sound).
|
||||||
|
|
||||||
|
Usability: Role play, jumps, traps... Pretty meach everywhere.
|
||||||
|
### 5. Trap blocks (in dev):
|
||||||
|
These blocks will disappear when a player walks on it, then reappear 2 seconds later.
|
||||||
|
Craft a trapper using a stone pressure plate and a redstone then drop the trapper to set the blocks under it as a trap block.
|
||||||
|
Please note that this feature is not supported by PocketMine-MP by the PMMP team.
|
||||||
|
|
||||||
|
Usability: Jumps, traps, and many other things !
|
||||||
|
### 6. Redstone Powering blocks (when redstone will be implemented):
|
||||||
|
These blocks emits a redstone signal when a player walks on it.
|
||||||
|
It's better than pressure plates because no sound is emited, it could be any blocks, and the player has no way to see it before getting on it.
|
||||||
|
Craft it by droping a redstone block on the ground and this block will become a redstone powering block.
|
||||||
|
|
||||||
|
Usability: Traps, redstone contraptions, ... Pretty much everywhere !
|
||||||
|
|
||||||
|
## Other blocks:
|
||||||
|
### 7. Graves:
|
||||||
|
This block is also a port from [Open Blocks](https://github.com/OpenMods/OpenBlocks) and are made so when you die, all your inventory will be stored in a grave. You can get it back by breaking it.
|
||||||
|
A grave is composed of a cobblestone block and a sign with the name of the player, and how did he die.
|
|
@ -77,7 +77,6 @@ class SoundHolderTile extends CustomBlockData {
|
||||||
*/
|
*/
|
||||||
public function play() {
|
public function play() {
|
||||||
$s = "\\pocketmine\\level\\sound\\" . $this->namedtag->Sound->getValue();
|
$s = "\\pocketmine\\level\\sound\\" . $this->namedtag->Sound->getValue();
|
||||||
Main::$instance->getLogger()->debug("Playing sound $s...");
|
|
||||||
$this->getLevel()->addSound(new $s($this));
|
$this->getLevel()->addSound(new $s($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Ad5001\BetterBlocks\CustomBlockData\GraveTile;
|
||||||
use Ad5001\BetterBlocks\CustomBlockData\RedstonePoweringTile;
|
use Ad5001\BetterBlocks\CustomBlockData\RedstonePoweringTile;
|
||||||
use Ad5001\BetterBlocks\CustomBlockData\SoundHolderTile;
|
use Ad5001\BetterBlocks\CustomBlockData\SoundHolderTile;
|
||||||
use Ad5001\BetterBlocks\CustomBlockData\StickTile;
|
use Ad5001\BetterBlocks\CustomBlockData\StickTile;
|
||||||
|
use Ad5001\BetterBlocks\CustomBlockData\TrapTile;
|
||||||
|
|
||||||
use Ad5001\BetterBlocks\tasks\AttractTask;
|
use Ad5001\BetterBlocks\tasks\AttractTask;
|
||||||
use Ad5001\BetterBlocks\tasks\BlockRegenerateTask;
|
use Ad5001\BetterBlocks\tasks\BlockRegenerateTask;
|
||||||
|
@ -41,13 +42,14 @@ class Main extends PluginBase implements Listener {
|
||||||
|
|
||||||
const PMMP_INCOMPATIBLE = [
|
const PMMP_INCOMPATIBLE = [
|
||||||
"Vacuum Hoppers",
|
"Vacuum Hoppers",
|
||||||
"Sticky Slime Blocks"
|
"Sticky Slime Blocks",
|
||||||
|
"Trappers"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function onEnable(){
|
public function onEnable(){
|
||||||
if($this->getServer()->getName() == "PocketMine-MP") {
|
if(!$this->isCompatible()) {
|
||||||
$this->getLogger()->notice("This plugin only has partial support of Pocketmine due to all the features an API missing. The following things will be deactivated: " . implode(", ", self::PMMP_INCOMPATIBLE));
|
$this->getLogger()->notice("This plugin only has partial support of this PocketMine version ({$this->getServer()->getName()}) due to all the features an API missing. The following things will be deactivated: " . implode(", ", self::PMMP_INCOMPATIBLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$instance = $this;
|
self::$instance = $this;
|
||||||
|
@ -102,11 +104,15 @@ class Main extends PluginBase implements Listener {
|
||||||
Tile::registerTile(GraveTile::class);
|
Tile::registerTile(GraveTile::class);
|
||||||
Tile::registerTile(RedstonePoweringTile::class);
|
Tile::registerTile(RedstonePoweringTile::class);
|
||||||
Tile::registerTile(SoundHolderTile::class);
|
Tile::registerTile(SoundHolderTile::class);
|
||||||
Tile::registerTile(StickTile::class);
|
Tile::registerTile(TrapTile::class);
|
||||||
|
|
||||||
|
if($this->isCompatible()) {
|
||||||
|
Tile::registerTile(StickTile::class);
|
||||||
|
}
|
||||||
|
|
||||||
// Launch tasks
|
// Launch tasks
|
||||||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new Drop2CraftTask($this), 5);
|
$this->getServer()->getScheduler()->scheduleRepeatingTask(new Drop2CraftTask($this), 5);
|
||||||
if($this->getServer()->getName() !== "PocketMine-MP") { // Removes uncessery lag on PMMP
|
if($this->isCompatible()) { // Removes uncessery lag on PMMP
|
||||||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new AttractTask($this), 5);
|
$this->getServer()->getScheduler()->scheduleRepeatingTask(new AttractTask($this), 5);
|
||||||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new StickTask($this), 1);
|
$this->getServer()->getScheduler()->scheduleRepeatingTask(new StickTask($this), 1);
|
||||||
}
|
}
|
||||||
|
@ -122,14 +128,15 @@ class Main extends PluginBase implements Listener {
|
||||||
@param $event \pocketmine\event\block\BlockPlaceEvent
|
@param $event \pocketmine\event\block\BlockPlaceEvent
|
||||||
*/
|
*/
|
||||||
public function onBlockPlace(\pocketmine\event\block\BlockPlaceEvent $event) {
|
public function onBlockPlace(\pocketmine\event\block\BlockPlaceEvent $event) {
|
||||||
if(isset($event->getItem()->getNamedTag()->isStickable) && $event->getItem()->getNamedTag()->isStickable->getValue() == "true") {
|
if($this->isCompatible()) {
|
||||||
$this->getLogger()->debug("Created tile Sticky Slime Block");
|
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(["x" => $event->getBlock()->x, "y" => $event->getBlock()->y, "z" => $event->getBlock()->z], JSON_FORCE_OBJECT)));
|
Tile::createTile("StickTile", $event->getBlock()->getLevel()->getChunk($event->getBlock()->x >> 4, $event->getBlock()->z >> 4), NBT::parseJSON(json_encode(["x" => $event->getBlock()->x, "y" => $event->getBlock()->y, "z" => $event->getBlock()->z], JSON_FORCE_OBJECT)));
|
||||||
} elseif(isset($event->getItem()->getNamedTag()->isVacuum) && $event->getItem()->getNamedTag()->isVacuum->getValue() == "true") {
|
} elseif(isset($event->getItem()->getNamedTag()->isVacuum) && $event->getItem()->getNamedTag()->isVacuum->getValue() == "true") {
|
||||||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new SetVacuumTask($this, $event->getBlock()), 1); // Tile gets created after the event so delaying it one 1 tick.
|
$this->getServer()->getScheduler()->scheduleRepeatingTask(new SetVacuumTask($this, $event->getBlock()), 1); // Tile gets created after the event so delaying it one 1 tick.
|
||||||
} elseif(isset($event->getItem()->getNamedTag()->isTrapper) && $event->getItem()->getNamedTag()->isTrapper->getValue() == "true") {
|
} 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(["x" => $event->getBlock()->x, "y" => $event->getBlock()->y - 1, "z" => $event->getBlock()->z], JSON_FORCE_OBJECT)));
|
Tile::createTile("TrapTile", $event->getBlock()->getLevel()->getChunk($event->getBlock()->x >> 4, $event->getBlock()->z >> 4), NBT::parseJSON(json_encode(["x" => $event->getBlock()->x, "y" => $event->getBlock()->y - 1, "z" => $event->getBlock()->z], JSON_FORCE_OBJECT)));
|
||||||
$this->getServer()->getScheduler()->scheduleDelayedTask(new BlockRegenerateTask($this, Block::get(0, 0), $event->getBlock()->getLevel()), 30); // Clears the lever
|
$this->getServer()->getScheduler()->scheduleDelayedTask(new BlockRegenerateTask($this, Block::get(0, 0), $event->getBlock()->getLevel()), 30); // Clears the lever
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +191,7 @@ class Main extends PluginBase implements Listener {
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if a player touches a block. Check if he right clicks ill a hammer.
|
Check if a player touches a block. Check if he right clicks ill a hammer or will change the sound of a sound holder block.
|
||||||
@param $event \pocketmine\event\player\PlayerInteractEvent
|
@param $event \pocketmine\event\player\PlayerInteractEvent
|
||||||
*/
|
*/
|
||||||
public function onInteract(\pocketmine\event\player\PlayerInteractEvent $event) {
|
public function onInteract(\pocketmine\event\player\PlayerInteractEvent $event) {
|
||||||
|
@ -205,7 +212,13 @@ class Main extends PluginBase implements Listener {
|
||||||
@param $event \pocketmine\event\player\PlayerDropItemEvent
|
@param $event \pocketmine\event\player\PlayerDropItemEvent
|
||||||
*/
|
*/
|
||||||
public function onPlayerItemDrop(\pocketmine\event\player\PlayerDropItemEvent $event) {
|
public function onPlayerItemDrop(\pocketmine\event\player\PlayerDropItemEvent $event) {
|
||||||
$event->getItem()->setNamedTag(NBT::parseJSON('{"isDropedByPlayer":"true"}'));
|
$tag = $event->getItem()->getNamedTag();
|
||||||
|
if(is_null($tag)) {
|
||||||
|
$tag = NBT::parseJSON('{"isDropedByPlayer":"true"}');
|
||||||
|
} else {
|
||||||
|
$tag->isDropedByPlayer = new \pocketmine\nbt\tag\StringTag("true");
|
||||||
|
}
|
||||||
|
$event->getItem()->setNamedTag($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,4 +276,14 @@ class Main extends PluginBase implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cheks compatibilty issues for PMMP and other uncompatible software.
|
||||||
|
@return bool
|
||||||
|
*/
|
||||||
|
public function isCompatible() : bool {
|
||||||
|
return class_exists("pocketmine\\tile\\Hopper") && class_exists("pocketmine\\block\\SlimeBlock") && class_exists("pocketmine\\item\\Lever");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -67,11 +67,10 @@ class Drop2CraftTask extends PluginTask {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 69: // Levers drops
|
case 69: // Levers drops
|
||||||
$this->getLogger()->debug("Found lever");
|
|
||||||
$v3 = $et->round();
|
$v3 = $et->round();
|
||||||
$v3->y--;
|
$v3->y--;
|
||||||
|
if(isset($et->getItem()->getNamedTag()->isTrapper)) $this->main->getLogger()->debug("Found trapper");
|
||||||
if($et->getLevel()->getBlock($v3)->isSolid() && isset($et->getItem()->getNamedTag()->isTrapper)) {
|
if($et->getLevel()->getBlock($v3)->isSolid() && isset($et->getItem()->getNamedTag()->isTrapper)) {
|
||||||
$this->getLogger()->debug("Found trapper");
|
|
||||||
Tile::createTile("TrapTile", $et->getLevel()->getChunk($v3->x >> 4, $v3->z >> 4), NBT::parseJSON(json_encode(["x" => $v3->x, "y" => $v3->y - 1, "z" => $v3->z], JSON_FORCE_OBJECT)));
|
Tile::createTile("TrapTile", $et->getLevel()->getChunk($v3->x >> 4, $v3->z >> 4), NBT::parseJSON(json_encode(["x" => $v3->x, "y" => $v3->y - 1, "z" => $v3->z], JSON_FORCE_OBJECT)));
|
||||||
$et->close();
|
$et->close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue