mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Block: Invert default behaviour of silk touch (more logical)
Now, blocks do not respond to silk touch unless specifically opted into. Since this always involves custom drops in one way or another, it's easy enough to figure out which blocks need to be marked for silk touch - anything that overrides getDrops, getDropsForCompatibleTool or getSilkTouchDrops is a block which _might_ need to be flagged. Using these criteria to reduce the number of blocks needing to be checked, I was able to manually invert the behaviour as needed. This fixes reoccurring bugs with blocks erroneously dropping themselves whenever new blocks are added and someone forgot to set that flag, granting players access to internal blocks with strange behaviour.
This commit is contained in:
parent
72f59eca3c
commit
8e2b9b686b
@ -195,8 +195,4 @@ class Banner extends Transparent{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -402,11 +402,10 @@ class Block{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether Silk Touch enchanted tools will cause this block to drop as itself. Since most blocks drop
|
||||
* themselves anyway, this is implicitly true.
|
||||
* Returns whether Silk Touch enchanted tools will cause this block to drop as itself.
|
||||
*/
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,6 +325,10 @@ class BlockFactory{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaBlocks::COBBLESTONE()->asItem()];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
$this->register(new Stair(new BID(Ids::NORMAL_STONE_STAIRS), "Stone Stairs", $stoneBreakInfo));
|
||||
$this->register(new Opaque(new BID(Ids::SMOOTH_STONE), "Smooth Stone", $stoneBreakInfo));
|
||||
|
@ -38,6 +38,10 @@ class Bookshelf extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
@ -33,4 +33,8 @@ class BrownMushroomBlock extends RedMushroomBlock{
|
||||
VanillaBlocks::BROWN_MUSHROOM()->asItem()->setCount(mt_rand(0, 2))
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -86,10 +86,6 @@ class Cake extends Transparent implements FoodSource{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$player->consumeObject($this);
|
||||
|
@ -37,4 +37,8 @@ class Clay extends Opaque{
|
||||
VanillaItems::CLAY()->setCount(4)
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ class CoalOre extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(0, 2);
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ class Cobweb extends Flowable{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function diffusesSkyLight() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -59,10 +59,6 @@ class CocoaBlock extends Transparent{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
|
@ -104,8 +104,4 @@ abstract class Crops extends Flowable{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,10 @@ class DeadBush extends Flowable{
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFlameEncouragement() : int{
|
||||
return 60;
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ class DiamondOre extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(3, 7);
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ class EmeraldOre extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(3, 7);
|
||||
}
|
||||
|
@ -103,10 +103,6 @@ class Farmland extends Transparent{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
return VanillaBlocks::DIRT()->asItem();
|
||||
}
|
||||
|
@ -151,8 +151,4 @@ class FlowerPot extends Flowable{
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
return $this->plant !== null ? $this->plant->asItem() : parent::getPickedItem($addUserData);
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,8 @@ class Glass extends Transparent{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,8 @@ class GlassPane extends Thin{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -42,4 +42,8 @@ class Glowstone extends Transparent{
|
||||
VanillaItems::GLOWSTONE_DUST()->setCount(mt_rand(2, 4))
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ class Grass extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ticksRandomly() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -51,4 +51,8 @@ class GrassPath extends Transparent{
|
||||
VanillaBlocks::DIRT()->asItem()
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ class Gravel extends Opaque implements Fallable{
|
||||
return parent::getDropsForCompatibleTool($item);
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function tickFalling() : ?Block{
|
||||
return null;
|
||||
}
|
||||
|
@ -62,4 +62,8 @@ class Ice extends Transparent{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -35,5 +35,9 @@ abstract class InfestedStone extends Opaque{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -177,8 +177,4 @@ class ItemFrame extends Flowable{
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
return $this->framedItem !== null ? clone $this->framedItem : parent::getPickedItem($addUserData);
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ class LapisOre extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(2, 5);
|
||||
}
|
||||
|
@ -38,4 +38,8 @@ class Melon extends Transparent{
|
||||
VanillaItems::MELON()->setCount(mt_rand(3, 7))
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,6 @@ class MonsterSpawner extends Transparent{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(15, 43);
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ class Mycelium extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ticksRandomly() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ class NetherQuartzOre extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(2, 5);
|
||||
}
|
||||
|
@ -38,4 +38,8 @@ class PackedIce extends Opaque{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -58,4 +58,8 @@ class RedMushroomBlock extends Opaque{
|
||||
VanillaBlocks::RED_MUSHROOM()->asItem()->setCount(mt_rand(0, 2))
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,10 @@ class RedstoneOre extends Opaque{
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getXpDropAmount() : int{
|
||||
return mt_rand(1, 5);
|
||||
}
|
||||
|
@ -41,4 +41,8 @@ class SeaLantern extends Transparent{
|
||||
VanillaItems::PRISMARINE_CRYSTALS()->setCount(3)
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,4 @@ class Slab extends Transparent{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [$this->asItem()->setCount($this->slabType->equals(SlabType::DOUBLE()) ? 2 : 1)];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -38,4 +38,8 @@ class Snow extends Opaque{
|
||||
VanillaItems::SNOWBALL()->setCount(4)
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +105,4 @@ class SnowLayer extends Flowable implements Fallable{
|
||||
VanillaItems::SNOWBALL()->setCount(max(1, (int) floor($this->layers / 2)))
|
||||
];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,4 @@ class Tripwire extends Flowable{
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user