Added another handful of blocks

clearing out my workspace...
This commit is contained in:
Dylan K. Taylor 2022-07-05 20:42:22 +01:00
parent 3c017af6a0
commit a42bb9626d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
7 changed files with 73 additions and 5 deletions

View File

@ -243,7 +243,11 @@ class BlockFactory{
$this->register(new ItemFrame(new BID(Ids::ITEM_FRAME, TileItemFrame::class), "Item Frame", new BreakInfo(0.25)));
$this->register(new Jukebox(new BID(Ids::JUKEBOX, TileJukebox::class), "Jukebox", new BreakInfo(0.8, ToolType::AXE))); //TODO: in PC the hardness is 2.0, not 0.8, unsure if this is a MCPE bug or not
$this->register(new Ladder(new BID(Ids::LADDER), "Ladder", new BreakInfo(0.4, ToolType::AXE)));
$this->register(new Lantern(new BID(Ids::LANTERN), "Lantern", new BreakInfo(5.0, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));
$lanternBreakInfo = new BreakInfo(5.0, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel());
$this->register(new Lantern(new BID(Ids::LANTERN), "Lantern", $lanternBreakInfo, 15));
$this->register(new Lantern(new BID(Ids::SOUL_LANTERN), "Soul Lantern", $lanternBreakInfo, 10));
$this->register(new Opaque(new BID(Ids::LAPIS_LAZULI), "Lapis Lazuli Block", new BreakInfo(3.0, ToolType::PICKAXE, ToolTier::STONE()->getHarvestLevel())));
$this->register(new LapisOre(new BID(Ids::LAPIS_LAZULI_ORE), "Lapis Lazuli Ore", new BreakInfo(3.0, ToolType::PICKAXE, ToolTier::STONE()->getHarvestLevel())));
$this->register(new Lava(new BID(Ids::LAVA), "Lava", BreakInfo::indestructible(500.0)));
@ -568,6 +572,7 @@ class BlockFactory{
));
$this->registerBlocksR13();
$this->registerBlocksR14();
$this->registerBlocksR16();
$this->registerBlocksR17();
}
@ -711,6 +716,10 @@ class BlockFactory{
$this->register(new Light(new BID(Ids::LIGHT), "Light Block", BreakInfo::indestructible()));
}
private function registerBlocksR14() : void{
$this->register(new Opaque(new BID(Ids::HONEYCOMB), "Honeycomb Block", new BreakInfo(0.6)));
}
private function registerBlocksR16() : void{
//for some reason, slabs have weird hardness like the legacy ones
$slabBreakInfo = new BreakInfo(2.0, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel());
@ -745,7 +754,15 @@ class BlockFactory{
$this->register(new Wall(new BID(Ids::POLISHED_BLACKSTONE_BRICK_WALL), $prefix("Wall"), $blackstoneBreakInfo));
$this->register(new Opaque(new BID(Ids::CRACKED_POLISHED_BLACKSTONE_BRICKS), "Cracked Polished Blackstone Bricks", $blackstoneBreakInfo));
$this->register(new Torch(new BID(Ids::SOUL_TORCH), "Soul Torch", BreakInfo::instant()));
$this->register(new SoulFire(new BID(Ids::SOUL_FIRE), "Soul Fire", BreakInfo::instant()));
//TODO: soul soul ought to have 0.5 hardness (as per java) but it's 1.0 in Bedrock (probably parity bug)
$this->register(new Opaque(new BID(Ids::SOUL_SOIL), "Soul Soil", new BreakInfo(1.0, ToolType::SHOVEL)));
$this->register(new class(new BID(Ids::SHROOMLIGHT), "Shroomlight", new BreakInfo(1.0, ToolType::HOE)) extends Opaque{
public function getLightLevel() : int{ return 15; }
});
}
private function registerBlocksR17() : void{
@ -753,6 +770,7 @@ class BlockFactory{
$this->register(new Opaque(new BID(Ids::AMETHYST), "Amethyst", new BreakInfo(1.5, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));
$this->register(new Opaque(new BID(Ids::CALCITE), "Calcite", new BreakInfo(0.75, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));
$this->register(new Opaque(new BID(Ids::TUFF), "Tuff", new BreakInfo(1.5, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));
$this->register(new Opaque(new BID(Ids::RAW_COPPER), "Raw Copper Block", new BreakInfo(5, ToolType::PICKAXE, ToolTier::STONE()->getHarvestLevel())));
$this->register(new Opaque(new BID(Ids::RAW_GOLD), "Raw Gold Block", new BreakInfo(5, ToolType::PICKAXE, ToolTier::IRON()->getHarvestLevel())));

View File

@ -613,10 +613,12 @@ final class BlockTypeIds{
public const CHISELED_DEEPSLATE = 10586;
public const CHISELED_NETHER_BRICKS = 10587;
public const CRACKED_NETHER_BRICKS = 10588;
public const TUFF = 10589;
public const SOUL_TORCH = 10590;
public const SOUL_LANTERN = 10591;
public const SOUL_SOIL = 10592;
public const SOUL_FIRE = 10593;
public const SHROOMLIGHT = 10594;
public const MANGROVE_PLANKS = 10595;
public const CRIMSON_PLANKS = 10596;
public const WARPED_PLANKS = 10597;
@ -657,5 +659,7 @@ final class BlockTypeIds{
public const CRIMSON_WALL_SIGN = 10632;
public const WARPED_WALL_SIGN = 10633;
public const FIRST_UNUSED_BLOCK_ID = 10634;
public const HONEYCOMB = 10635;
public const FIRST_UNUSED_BLOCK_ID = 10636;
}

View File

@ -35,8 +35,15 @@ use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
class Lantern extends Transparent{
private int $lightLevel; //readonly
protected bool $hanging = false;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, int $lightLevel){
$this->lightLevel = $lightLevel;
parent::__construct($idInfo, $name, $breakInfo);
}
public function getRequiredStateDataBits() : int{ return 1; }
protected function decodeState(RuntimeDataReader $r) : void{
@ -56,7 +63,7 @@ class Lantern extends Transparent{
}
public function getLightLevel() : int{
return 15;
return $this->lightLevel;
}
/**

View File

@ -360,6 +360,7 @@ use pocketmine\utils\CloningRegistryTrait;
* @method static HardenedGlass HARDENED_GLASS()
* @method static HardenedGlassPane HARDENED_GLASS_PANE()
* @method static HayBale HAY_BALE()
* @method static Opaque HONEYCOMB()
* @method static Hopper HOPPER()
* @method static Ice ICE()
* @method static InfestedStone INFESTED_CHISELED_STONE_BRICK()
@ -551,6 +552,7 @@ use pocketmine\utils\CloningRegistryTrait;
* @method static Wall SANDSTONE_WALL()
* @method static SeaLantern SEA_LANTERN()
* @method static SeaPickle SEA_PICKLE()
* @method static Opaque SHROOMLIGHT()
* @method static ShulkerBox SHULKER_BOX()
* @method static Slime SLIME()
* @method static Furnace SMOKER()
@ -569,7 +571,10 @@ use pocketmine\utils\CloningRegistryTrait;
* @method static Snow SNOW()
* @method static SnowLayer SNOW_LAYER()
* @method static SoulFire SOUL_FIRE()
* @method static Lantern SOUL_LANTERN()
* @method static SoulSand SOUL_SAND()
* @method static Opaque SOUL_SOIL()
* @method static Torch SOUL_TORCH()
* @method static Sponge SPONGE()
* @method static WoodenButton SPRUCE_BUTTON()
* @method static WoodenDoor SPRUCE_DOOR()
@ -610,6 +615,7 @@ use pocketmine\utils\CloningRegistryTrait;
* @method static TrappedChest TRAPPED_CHEST()
* @method static Tripwire TRIPWIRE()
* @method static TripwireHook TRIPWIRE_HOOK()
* @method static Opaque TUFF()
* @method static UnderwaterTorch UNDERWATER_TORCH()
* @method static Vine VINES()
* @method static WallBanner WALL_BANNER()
@ -985,6 +991,7 @@ final class VanillaBlocks{
self::register("hardened_glass", $factory->fromTypeId(Ids::HARDENED_GLASS));
self::register("hardened_glass_pane", $factory->fromTypeId(Ids::HARDENED_GLASS_PANE));
self::register("hay_bale", $factory->fromTypeId(Ids::HAY_BALE));
self::register("honeycomb", $factory->fromTypeId(Ids::HONEYCOMB));
self::register("hopper", $factory->fromTypeId(Ids::HOPPER));
self::register("ice", $factory->fromTypeId(Ids::ICE));
self::register("infested_chiseled_stone_brick", $factory->fromTypeId(Ids::INFESTED_CHISELED_STONE_BRICK));
@ -1176,6 +1183,7 @@ final class VanillaBlocks{
self::register("sandstone_wall", $factory->fromTypeId(Ids::SANDSTONE_WALL));
self::register("sea_lantern", $factory->fromTypeId(Ids::SEA_LANTERN));
self::register("sea_pickle", $factory->fromTypeId(Ids::SEA_PICKLE));
self::register("shroomlight", $factory->fromTypeId(Ids::SHROOMLIGHT));
self::register("shulker_box", $factory->fromTypeId(Ids::SHULKER_BOX));
self::register("slime", $factory->fromTypeId(Ids::SLIME));
self::register("smoker", $factory->fromTypeId(Ids::SMOKER));
@ -1194,7 +1202,10 @@ final class VanillaBlocks{
self::register("snow", $factory->fromTypeId(Ids::SNOW));
self::register("snow_layer", $factory->fromTypeId(Ids::SNOW_LAYER));
self::register("soul_fire", $factory->fromTypeId(Ids::SOUL_FIRE));
self::register("soul_lantern", $factory->fromTypeId(Ids::SOUL_LANTERN));
self::register("soul_sand", $factory->fromTypeId(Ids::SOUL_SAND));
self::register("soul_soil", $factory->fromTypeId(Ids::SOUL_SOIL));
self::register("soul_torch", $factory->fromTypeId(Ids::SOUL_TORCH));
self::register("sponge", $factory->fromTypeId(Ids::SPONGE));
self::register("spruce_button", $factory->fromTypeId(Ids::SPRUCE_BUTTON));
self::register("spruce_door", $factory->fromTypeId(Ids::SPRUCE_DOOR));
@ -1235,6 +1246,7 @@ final class VanillaBlocks{
self::register("trapped_chest", $factory->fromTypeId(Ids::TRAPPED_CHEST));
self::register("tripwire", $factory->fromTypeId(Ids::TRIPWIRE));
self::register("tripwire_hook", $factory->fromTypeId(Ids::TRIPWIRE_HOOK));
self::register("tuff", $factory->fromTypeId(Ids::TUFF));
self::register("underwater_torch", $factory->fromTypeId(Ids::UNDERWATER_TORCH));
self::register("vines", $factory->fromTypeId(Ids::VINES));
self::register("wall_banner", $factory->fromTypeId(Ids::WALL_BANNER));

View File

@ -1053,6 +1053,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
->writeBool(StateNames::DEAD_BIT, !$block->isUnderwater())
->writeInt(StateNames::CLUSTER_COUNT, $block->getCount() - 1);
});
$this->mapSimple(Blocks::SHROOMLIGHT(), Ids::SHROOMLIGHT);
$this->mapSimple(Blocks::SHULKER_BOX(), Ids::UNDYED_SHULKER_BOX);
$this->mapSimple(Blocks::SLIME(), Ids::SLIME);
$this->map(Blocks::SMOKER(), fn(Furnace $block) => Helper::encodeFurnace($block, Ids::SMOKER, Ids::LIT_SMOKER));
@ -1078,7 +1079,16 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
return Writer::create(Ids::SOUL_FIRE)
->writeInt(StateNames::AGE, 0); //useless for soul fire, we don't track it
});
$this->map(Blocks::SOUL_LANTERN(), function(Lantern $block) : Writer{
return Writer::create(Ids::SOUL_LANTERN)
->writeBool(StateNames::HANGING, $block->isHanging());
});
$this->mapSimple(Blocks::SOUL_SAND(), Ids::SOUL_SAND);
$this->mapSimple(Blocks::SOUL_SOIL(), Ids::SOUL_SOIL);
$this->map(Blocks::SOUL_TORCH(), function(Torch $block) : Writer{
return Writer::create(Ids::SOUL_TORCH)
->writeTorchFacing($block->getFacing());
});
$this->map(Blocks::SPONGE(), function(Sponge $block) : Writer{
return Writer::create(Ids::SPONGE)
->writeString(StateNames::SPONGE_TYPE, $block->isWet() ? StringValues::SPONGE_TYPE_WET : StringValues::SPONGE_TYPE_DRY);
@ -1168,6 +1178,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
->writeBool(StateNames::POWERED_BIT, $block->isPowered())
->writeLegacyHorizontalFacing($block->getFacing());
});
$this->mapSimple(Blocks::TUFF(), Ids::TUFF);
$this->map(Blocks::UNDERWATER_TORCH(), function(UnderwaterTorch $block) : Writer{
return Writer::create(Ids::UNDERWATER_TORCH)
->writeTorchFacing($block->getFacing());

View File

@ -971,6 +971,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
->setCount($in->readBoundedInt(StateNames::CLUSTER_COUNT, 0, 3) + 1)
->setUnderwater(!$in->readBool(StateNames::DEAD_BIT));
});
$this->map(Ids::SHROOMLIGHT, fn() => Blocks::SHROOMLIGHT());
$this->map(Ids::SHULKER_BOX, function(Reader $in) : Block{
return Blocks::DYED_SHULKER_BOX()
->setColor($in->readColor());
@ -1000,7 +1001,16 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
$in->ignored(StateNames::AGE); //this is useless for soul fire, since it doesn't have the logic associated
return Blocks::SOUL_FIRE();
});
$this->map(Ids::SOUL_LANTERN, function(Reader $in) : Block{
return Blocks::SOUL_LANTERN()
->setHanging($in->readBool(StateNames::HANGING));
});
$this->map(Ids::SOUL_SAND, fn() => Blocks::SOUL_SAND());
$this->map(Ids::SOUL_SOIL, fn() => Blocks::SOUL_SOIL());
$this->map(Ids::SOUL_TORCH, function(Reader $in) : Block{
return Blocks::SOUL_TORCH()
->setFacing($in->readTorchFacing());
});
$this->map(Ids::SPONGE, function(Reader $in) : Block{
return Blocks::SPONGE()->setWet(match($type = $in->readString(StateNames::SPONGE_TYPE)){
StringValues::SPONGE_TYPE_DRY => false,
@ -1120,6 +1130,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
->setFacing($in->readLegacyHorizontalFacing())
->setPowered($in->readBool(StateNames::POWERED_BIT));
});
$this->map(Ids::TUFF, fn() => Blocks::TUFF());
$this->map(Ids::UNDERWATER_TORCH, function(Reader $in) : Block{
return Blocks::UNDERWATER_TORCH()
->setFacing($in->readTorchFacing());

View File

@ -875,6 +875,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("sea_lantern", fn() => Blocks::SEA_LANTERN());
$result->registerBlock("sea_pickle", fn() => Blocks::SEA_PICKLE());
$result->registerBlock("sealantern", fn() => Blocks::SEA_LANTERN());
$result->registerBlock("shroomlight", fn() => Blocks::SHROOMLIGHT());
$result->registerBlock("shulker_box", fn() => Blocks::SHULKER_BOX());
$result->registerBlock("sign", fn() => Blocks::OAK_SIGN());
$result->registerBlock("sign_post", fn() => Blocks::OAK_SIGN());
@ -901,7 +902,10 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("snow", fn() => Blocks::SNOW());
$result->registerBlock("snow_block", fn() => Blocks::SNOW());
$result->registerBlock("snow_layer", fn() => Blocks::SNOW_LAYER());
$result->registerBlock("soul_lantern", fn() => Blocks::SOUL_LANTERN());
$result->registerBlock("soul_sand", fn() => Blocks::SOUL_SAND());
$result->registerBlock("soul_soil", fn() => Blocks::SOUL_SOIL());
$result->registerBlock("soul_torch", fn() => Blocks::SOUL_TORCH());
$result->registerBlock("sponge", fn() => Blocks::SPONGE());
$result->registerBlock("spruce_button", fn() => Blocks::SPRUCE_BUTTON());
$result->registerBlock("spruce_door", fn() => Blocks::SPRUCE_DOOR());
@ -985,6 +989,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("tripwire_hook", fn() => Blocks::TRIPWIRE_HOOK());
$result->registerBlock("trunk", fn() => Blocks::OAK_PLANKS());
$result->registerBlock("trunk2", fn() => Blocks::ACACIA_LOG()->setStripped(false));
$result->registerBlock("tuff", fn() => Blocks::TUFF());
$result->registerBlock("underwater_torch", fn() => Blocks::UNDERWATER_TORCH());
$result->registerBlock("undyed_shulker_box", fn() => Blocks::SHULKER_BOX());
$result->registerBlock("unlit_redstone_torch", fn() => Blocks::REDSTONE_TORCH());