block light

This commit is contained in:
GameHerobrine 2025-06-23 01:24:00 +03:00
parent fd5b103df7
commit d1a724c143
66 changed files with 266 additions and 1 deletions

View file

@ -160,6 +160,10 @@ abstract class Block extends Position{
public $y = 0;
public $z = 0;
public $slipperiness;
public $lightEmission = 0;
public $lightBlock = 0;
public static function interact(Level $level, $x, $y, $z, Player $player){}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){}

View file

@ -22,10 +22,13 @@ class StaticBlock
public static $destroyTime = [];
public static $slipperiness = [];
public static $boundingBoxes = [];
public static $lightBlock = [];
public static $lightEmission = [];
public static $minXs = [], $minYs = [], $minZs = [], $maxXs = [], $maxYs = [], $maxZs = [];
public static function init(){
self::$NULL_BOUNDS = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
for($i = 0; $i < 256; ++$i) self::$lightBlock[$i] = self::$lightEmission[$i] = 0;
foreach(Block::$class as $nonstaticname){
/**@var Block $b*/
$b = new $nonstaticname();
@ -43,6 +46,8 @@ class StaticBlock
self::$hardness[$b->getID()] = $b->getHardness();
self::$destroyTime[$b->getID()] = $b->breakTime;
self::$material[$b->getID()] = $b->material;
self::$lightBlock[$b->getID()] = $b->lightBlock;
self::$lightEmission[$b->getID()] = $b->lightEmission;
self::$prealloc[$b->getID()] = $b;
$b::$blockID = $b->getID();
FireBlock::setFlammabilityAndCatchingChance($b->getID(), 0, 0);

View file

@ -7,6 +7,7 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
$this->hardness = 0;
$this->breakTime = 0;
$this->material = Material::$decoration;
$this->lightEmission = 14;
}
public function getMaxLightValue(){

View file

@ -8,6 +8,8 @@ class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
$this->hardness = 500; //0 in vanilla
$this->breakTime = -1; //in vanilla it is 0, but you cant interact with the block so it is not possible to destroy it
$this->material = Material::$lava;
$this->lightEmission = 15;
$this->lightBlock = 255;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -8,6 +8,8 @@ class StillLavaBlock extends LiquidBlockStatic{
$this->hardness = 500;
$this->breakTime = -1; //in vanilla it is 100, but you cant interact with the block so it is not possible to destroy it
$this->material = Material::$lava;
$this->lightEmission = 15;
$this->lightBlock = 255;
}
public static function getTickDelay(){

View file

@ -14,6 +14,7 @@ class StillWaterBlock extends LiquidBlockStatic{
$this->hardness = 500;
$this->breakTime = -1; //in vanilla it is 100, but you cant interact with the block so it is not possible to destroy it
$this->material = Material::$water;
$this->lightBlock = 3;
}
public static function getTickDelay(){

View file

@ -9,6 +9,7 @@ class WaterBlock extends LiquidBlockDynamic{
$this->hardness = 500;
$this->breakTime = -1; //in vanilla it is 100, but you cant interact with the block so it is not possible to destroy it
$this->material = Material::$water;
$this->lightBlock = 3;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -13,6 +13,7 @@ class FireBlock extends FlowableBlock implements LightingBlock{
$this->hardness = 0;
$this->breakTime = 0;
$this->material = Material::$fire;
$this->lightEmission = 15;
}
public static function getAABB(Level $level, $x, $y, $z){
return null;

View file

@ -9,6 +9,7 @@ class NetherReactorBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3;
$this->material = Material::$metal;
$this->lightBlock = 255;
}
public function onActivate(Item $item, Player $player){

View file

@ -8,6 +8,7 @@ class TNTBlock extends SolidBlock{
$this->breakTime = 0;
$this->isActivable = true;
$this->material = Material::$explosive;
$this->lightBlock = 255;
}
public function onActivate(Item $item, Player $player){

View file

@ -9,6 +9,7 @@ class CobwebBlock extends FlowableBlock{
$this->hardness = 30;
$this->breakTime = 4;
$this->material = Material::$web;
$this->lightBlock = 1;
}
public static function getAABB(Level $level, $x, $y, $z){

View file

@ -7,6 +7,7 @@ class CoalOreBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3.0;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class DiamondOreBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,8 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
$this->hardness = 15;
$this->breakTime = 3;
$this->material = Material::$stone;
$this->lightBlock = 255;
$this->lightEmission = 9;
}
public static function onRandomTick(Level $level, $x, $y, $z){

View file

@ -7,6 +7,7 @@ class GoldOreBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3.0;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class IronOreBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3.0;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class LapisOreBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3.0;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class RedstoneOreBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public static function interact(Level $level, $x, $y, $z, Player $player){

View file

@ -7,6 +7,7 @@ class BrownMushroomBlock extends FlowableBlock{
$this->hardness = 0;
$this->breakTime = 0;
$this->material = Material::$plant;
$this->lightEmission = 1;
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){

View file

@ -8,6 +8,7 @@ class BedrockBlock extends SolidBlock{
$this->hardness = 18000000;
$this->breakTime = -1;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function isBreakable(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class BookshelfBlock extends SolidBlock{
$this->hardness = 7.5;
$this->breakTime = 1.5;
$this->material = Material::$wood;
$this->lightBlock = 255;
}
}

View file

@ -7,6 +7,7 @@ class BricksBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 2;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -8,6 +8,8 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
$this->hardness = 17.5;
$this->breakTime = 3.5;
$this->material = Material::$stone;
$this->lightBlock = 255;
$this->lightEmission = 13;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -7,6 +7,7 @@ class ClayBlock extends SolidBlock{
$this->hardness = 3;
$this->breakTime = 0.6;
$this->material = Material::$clay;
$this->lightBlock = 255;
}
public function getDrops(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class CoalBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 5;
$this->material = Material::$metal;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class CobblestoneBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 2;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class DiamondBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 5;
$this->material = Material::$metal;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -8,6 +8,7 @@ class DirtBlock extends SolidBlock{
$this->hardness = 2.5;
$this->breakTime = 0.5;
$this->material = Material::$dirt;
$this->lightBlock = 255;
}
public function onActivate(Item $item, Player $player){

View file

@ -18,6 +18,7 @@ class DoubleSlabBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 2;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -14,6 +14,7 @@ class DoubleWoodSlabBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 2;
$this->material = Material::$wood;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -13,5 +13,7 @@ class FurnaceBlock extends BurningFurnaceBlock{
$this->name = "Furnace";
$this->isActivable = true;
$this->material = Material::$stone;
$this->lightBlock = 255;
$this->lightEmission = 0;
}
}

View file

@ -7,6 +7,8 @@ class GlowingObsidianBlock extends SolidBlock implements LightingBlock{
$this->hardness = 6000;
$this->breakTime = 10;
$this->material = Material::$stone;
$this->lightBlock = 255;
$this->lightEmission = 13;
}
public function getMaxLightValue(){

View file

@ -7,6 +7,8 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{
$this->hardness = 1.5;
$this->breakTime = 0.3;
$this->material = Material::$glass;
$this->lightBlock = 255;
$this->lightEmission = 15;
}
public function getMaxLightValue(){

View file

@ -7,6 +7,7 @@ class GoldBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 3;
$this->material = Material::$metal;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -8,6 +8,7 @@ class GrassBlock extends SolidBlock{
$this->hardness = 3;
$this->breakTime = 0.6;
$this->material = Material::$dirt;
$this->lightBlock = 255;
}
public function getDrops(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class GravelBlock extends FallableBlock{
$this->hardness = 3;
$this->breakTime = 0.6;
$this->material = Material::$sand;
$this->lightBlock = 255;
}
public function getDrops(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class HayBaleBlock extends SolidBlock{
$this->hardness = 2.5;
$this->breakTime = 0.5;
$this->material = Material::$dirt;
$this->lightBlock = 255;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -8,6 +8,7 @@ class IceBlock extends TransparentBlock{
$this->breakTime = 0.5;
$this->slipperiness = 0.98;
$this->material = Material::$ice;
$this->lightBlock = 3;
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){

View file

@ -8,6 +8,7 @@ class InvisibleBedrockBlock extends SolidBlock{
$this->hardness = 18000000;
$this->breakTime = -1;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function isBreakable(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class IronBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 5;
$this->material = Material::$metal;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class LapisBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 3.0;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -17,6 +17,7 @@ class LeavesBlock extends TransparentBlock{
$this->hardness = 1;
$this->breakTime = 0.2;
$this->material = Material::$leaves;
$this->lightBlock = 1;
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){

View file

@ -15,6 +15,8 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
$this->hardness = 5;
$this->breakTime = 1.0;
$this->material = Material::$vegetable;
$this->lightBlock = 255;
$this->lightEmission = 15;
}
public function getMaxLightValue(){

View file

@ -7,6 +7,7 @@ class MelonBlock extends TransparentBlock{
$this->hardness = 5;
$this->breakTime = 1;
$this->material = Material::$vegetable;
$this->lightBlock = 255;
}
public function getDrops(Item $item, Player $player){
return array(

View file

@ -7,6 +7,7 @@ class MossStoneBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 2;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class NetherBricksBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 2;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class NetherrackBlock extends SolidBlock{
$this->hardness = 2;
$this->breakTime = 0.4;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class ObsidianBlock extends SolidBlock{
$this->hardness = 6000;
$this->breakTime = 10;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -14,6 +14,7 @@ class PlanksBlock extends SolidBlock{
$this->hardness = 15;
$this->breakTime = 2;
$this->material = Material::$wood;
$this->lightBlock = 255;
}
}

View file

@ -7,6 +7,7 @@ class PumpkinBlock extends SolidBlock{
$this->hardness = 5;
$this->breakTime = 1;
$this->material = Material::$vegetable;
$this->lightBlock = 255;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -14,6 +14,7 @@ class QuartzBlock extends SolidBlock{
$this->breakTime = 0.8;
$this->hardness = 4;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -8,6 +8,7 @@ class Reserved6Block extends SolidBlock{
$this->hardness = 0;
$this->breakTime = 0;
$this->material = Material::$dirt;
$this->lightBlock = 255;
}
}

View file

@ -7,6 +7,7 @@ class SandBlock extends FallableBlock{
$this->hardness = 2.5;
$this->breakTime = 0.5;
$this->material = Material::$sand;
$this->lightBlock = 255;
}
}

View file

@ -13,6 +13,7 @@ class SandstoneBlock extends SolidBlock{
$this->hardness = 4;
$this->breakTime = 0.8;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class SnowBlock extends SolidBlock{
$this->hardness = 1;
$this->breakTime = 0.2;
$this->material = Material::$snow;
$this->lightBlock = 255;
}
public function getDrops(Item $item, Player $player){

View file

@ -7,6 +7,7 @@ class SpongeBlock extends SolidBlock{
$this->hardness = 3;
$this->breakTime = 0.6;
$this->material = Material::$dirt;
$this->lightBlock = 255;
}
}

View file

@ -7,6 +7,7 @@ class StoneBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 1.5;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -14,6 +14,7 @@ class StoneBricksBlock extends SolidBlock{
$this->hardness = 30;
$this->breakTime = 1.5;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function getBreakTime(Item $item, Player $player){

View file

@ -8,6 +8,7 @@ class StonecutterBlock extends SolidBlock{
$this->breakTime = 2.5;
$this->hardness = 2.5*5;
$this->material = Material::$stone;
$this->lightBlock = 255;
}
public function onActivate(Item $item, Player $player){

View file

@ -19,6 +19,7 @@ class WoodBlock extends SolidBlock{
$this->hardness = 10;
$this->breakTime = 2.0;
$this->material = Material::$wood;
$this->lightBlock = 255;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -29,6 +29,7 @@ class WoolBlock extends SolidBlock{
$this->hardness = 4;
$this->breakTime = 0.8;
$this->material = Material::$cloth;
$this->lightBlock = 255;
}
}

View file

@ -8,6 +8,7 @@ class WorkbenchBlock extends SolidBlock{
$this->hardness = 12.5;
$this->breakTime = 2.5;
$this->material = Material::$wood;
$this->lightBlock = 255;
}
public function onActivate(Item $item, Player $player){