This repository was archived by the owner on Nov 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoUpdateFarmland.php
153 lines (118 loc) · 2.83 KB
/
NoUpdateFarmland.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/**
* @name NoUpdateFarmland
* @author AvasKr
* @main NoUpdateFarmland\NoUpdateFarmland
* @api 3.10.0
* @version 1.0.0
*/
namespace NoUpdateFarmland;
use pocketmine\plugin\PluginBase;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\Liquid;
use pocketmine\block\BlockToolType;
use pocketmine\block\Transparent;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\entity\Entity;
use pocketmine\level\Level;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\math\Vector3;
use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
class NoUpdateFarmland extends PluginBase
{
public function onLoad (): void
{
BlockFactory::registerBlock (new Farmland (), true);
BlockFactory::registerBlock (new Water (), true);
}
}
class Farmland extends Transparent
{
/** @var int */
protected $id = self::FARMLAND;
public function __construct (int $meta = 0)
{
$this->meta = $meta;
}
public function getName (): string
{
return "Farmland";
}
public function getHardness (): float
{
return 0.6;
}
public function getToolType (): int
{
return BlockToolType::TYPE_SHOVEL;
}
public function ticksRandomly (): bool
{
return true;
}
protected function recalculateBoundingBox (): ?AxisAlignedBB
{
return new AxisAlignedBB (
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 0.9375,
$this->z + 1
);
}
public function getDrops (Item $item): array
{
return [
ItemFactory::get (Item::DIRT, 0, 1)
];
}
}
class Water extends Liquid
{
/** @var int */
protected $id = self::FLOWING_WATER;
public function __construct (int $meta = 0)
{
$this->meta = $meta;
}
public function getStillForm (): Block
{
return BlockFactory::get (Block::STILL_WATER, $this->meta);
}
public function getFlowingForm (): Block
{
return BlockFactory::get (Block::FLOWING_WATER, $this->meta);
}
public function getName (): string
{
return "Water";
}
public function getBucketFillSound (): int
{
return LevelSoundPacket::SOUND_BUCKET_FILL_WATER;
}
public function tickRate (): int
{
return 1;
}
public function getBucketEmptySound (): int
{
return LevelSoundEventPacket::SOUND_BUCKET_EMPTY_WATER;
}
public function onUpdate ($type): bool
{
return false;
}
public function onEntityCollide (Entity $entity): void
{
$entity->resetFallDistance ();
if ($entity->fireTicks > 0) {
$entity->extinguish ();
}
}
}