tedo0627 / RedstoneCircuit

This is the PocketMine plugin that implements the Redstone circuit.
GNU General Public License v3.0
84 stars 51 forks source link

MyPlot and Pistons... #24

Closed Wertzui123 closed 2 years ago

Wertzui123 commented 5 years ago

Oh no, I have noticed that pistons can edit the plot borders and the road if you use the plugin "MyPlot". It would be wonderfull if you can fix this because I think that many other people with a citybuild server would love pistons!

DenielWorld commented 5 years ago

This plugin doesnt provide fixes with any other plugins, yet if you look into some piston code you may see theres a code line to set blocks unmovable by pistons. You can make your own fork of this plugin and implement it easily.

Wertzui123 commented 5 years ago

I know, but there was a fix for FactionsPE to in another point!

DenielWorld commented 5 years ago

That fix did not work.

Wertzui123 commented 5 years ago

Ok

Wertzui123 commented 5 years ago

But I hope tedo will fix it.

usser1976 commented 5 years ago

Think it would be easier if Jason blocks this in myplot.

jasonw4331 commented 5 years ago

You need a Redstone-MyPlot interaction plugin. I might make one when this plugin is released on Poggit.

Wertzui123 commented 5 years ago

Ok

usser1976 commented 5 years ago

Jason Reads Everything 😂 Step by Step my Friend 😉

Wertzui123 commented 5 years ago

No, I asked him in his discord xD

Wertzui123 commented 5 years ago

Releas the plugin so that jason makes a interacct pl xD

jasonw4331 commented 4 years ago

Put this on your server as a php file in the plugins folder. Be warned though, it depends on BlockEntityPistonArm::recalculatePushBlocks() being modified to be public.

<?php
declare(strict_types=1);

/**
 * @name RedstoneMyPlotHelper
 * @main jasonwynn10\RedstoneMyPlotHelper\Main
 * @version 0.1.0
 * @api 3.0.0
 * @description A plugin script which Helps interaction between pistons and plot borders
 * @author jasonwynn10
 * @depend RedstoneCircuit
 */
namespace jasonwynn10\RedstoneMyPlotHelper {

    use MyPlot\MyPlot;
    use pocketmine\block\Block;
    use pocketmine\event\Listener;
    use pocketmine\level\Position;
    use pocketmine\plugin\PluginBase;
    use pocketmine\tile\Tile;
    use redstone\blockEntities\BlockEntityPistonArm;

    class Main extends PluginBase implements Listener {
        public function onEnable() {
            $myPlot = $this->getServer()->getPluginManager()->getPlugin("MyPlot");
            if(!$myPlot instanceof MyPlot)
                return;
            $redstone = $this->getServer()->getPluginManager()->getPlugin("RedstoneCircuit");
            if(!$redstone instanceof \redstone\Main)
                return;
            if ($redstone->getCustomConfig()->isEnablePiston()) {
                Tile::registerTile(HelperPistonArm::class, ["PistonArm", "minecraft:piston_arm"]);
            }
        }
    }

    class HelperPistonArm extends BlockEntityPistonArm {
        public function onUpdate() : bool {
            $piston = $this->getBlock();
            /** @var Block[] $blocks */
            $blocks = $this->recalculatePushBlocks();
            if (count($blocks) == 0) {
                $this->extend = false;
                return true;
            }

            $face = $piston->getFace();
            foreach($blocks as $block) {
                $pos = Position::fromObject($block->asVector3()->getSide($face), $block->level);
                if(MyPlot::getInstance()->isPositionBorderingPlot($pos))
                    return false;
            }
            return parent::onUpdate();
        }
    }
}
usser1976 commented 4 years ago

Thanks Jason, I'm really surprised now. I will try it. And hope the description is fun 😅

Wertzui123 commented 4 years ago

It won't work until RedstoneCircuit makes a certain method public.

jasonw4331 commented 4 years ago

I said that in my message

Wertzui123 commented 4 years ago

Thanks Jason, I'm really surprised now. I will try it. And hope the description is fun

I don't think he read it

MistakingManx commented 4 years ago

day 3 of trying to find Jason's Discord tag to friend him without asking

Wertzui123 commented 4 years ago

jasonwynn10#4331

EasyF0xCB commented 3 years ago

Do you can add "p set flag redstone true"