Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyPlot and Pistons... #24

Closed
Wertzui123 opened this issue Apr 3, 2019 · 19 comments
Closed

MyPlot and Pistons... #24

Wertzui123 opened this issue Apr 3, 2019 · 19 comments

Comments

@Wertzui123
Copy link

Wertzui123 commented Apr 3, 2019

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
Copy link
Contributor

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
Copy link
Author

Wertzui123 commented Apr 3, 2019

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

@DenielWorld
Copy link
Contributor

That fix did not work.

@Wertzui123
Copy link
Author

Ok

@Wertzui123
Copy link
Author

But I hope tedo will fix it.

@usser1976
Copy link

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

@jasonw4331
Copy link

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

@Wertzui123
Copy link
Author

Ok

@usser1976
Copy link

Jason Reads Everything 😂 Step by Step my Friend 😉

@Wertzui123
Copy link
Author

No, I asked him in his discord xD

@Wertzui123
Copy link
Author

Releas the plugin so that jason makes a interacct pl xD

@jasonw4331
Copy link

jasonw4331 commented Jan 12, 2020

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
Copy link

usser1976 commented Jan 15, 2020 via email

@Wertzui123
Copy link
Author

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

@jasonw4331
Copy link

I said that in my message

@Wertzui123
Copy link
Author

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
Copy link

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

@Wertzui123
Copy link
Author

jasonwynn10#4331

@zPqguro zPqguro mentioned this issue May 1, 2020
@EasyF0xCB
Copy link

Do you can add "p set flag redstone true"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants