mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
better fire
This commit is contained in:
parent
168ef84165
commit
773e18282c
3 changed files with 72 additions and 3 deletions
|
|
@ -36,6 +36,9 @@ class StaticBlock
|
|||
self::$slipperiness[$b->getID()] = $b->slipperiness;
|
||||
self::$boundingBoxes[$b->getID()] = $b->boundingBox;
|
||||
self::$hardness[$b->getID()] = $b->getHardness();
|
||||
|
||||
|
||||
FireBlock::setFlammabilityAndCatchingChance($b->getID(), 0, 0);
|
||||
}
|
||||
|
||||
Block::$class[BED_BLOCK]::setBlockBounds(0, 0, 0, 1, 0.5625, 1);
|
||||
|
|
@ -64,6 +67,29 @@ class StaticBlock
|
|||
Block::$class[SNOW_LAYER]::setBlockBounds(0, 0, 0, 1, 0.125, 1);
|
||||
//Stairs: based on different factors
|
||||
//Stone wall: based on state
|
||||
|
||||
//Fire related stuff
|
||||
FireBlock::setFlammabilityAndCatchingChance(PLANKS, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(DOUBLE_WOOD_SLAB, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(WOODEN_SLAB, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(FENCE, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(FENCE_GATE, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(SIGN, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(WALL_SIGN, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(WOODEN_STAIRS, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(BIRCH_WOODEN_STAIRS, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(SPRUCE_WOODEN_STAIRS, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(JUNGLE_WOODEN_STAIRS, 5, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(TRUNK, 5, 5);
|
||||
FireBlock::setFlammabilityAndCatchingChance(LEAVES, 30, 60);
|
||||
FireBlock::setFlammabilityAndCatchingChance(BOOKSHELF, 30, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(TNT, 15, 100);
|
||||
FireBlock::setFlammabilityAndCatchingChance(TALL_GRASS, 60, 100);
|
||||
FireBlock::setFlammabilityAndCatchingChance(WOOL, 30, 60);
|
||||
FireBlock::setFlammabilityAndCatchingChance(CARPET, 30, 60);
|
||||
FireBlock::setFlammabilityAndCatchingChance(COAL_BLOCK, 5, 5);
|
||||
FireBlock::setFlammabilityAndCatchingChance(HAY_BALE, 60, 20);
|
||||
FireBlock::setFlammabilityAndCatchingChance(SPONGE, 30, 60);
|
||||
}
|
||||
|
||||
public static function getBlock($id){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
|
||||
class FireBlock extends FlowableBlock implements LightingBlock{
|
||||
|
||||
public static $flammability = [];
|
||||
public static $fireCatchingChance = [];
|
||||
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FIRE, $meta, "Fire");
|
||||
$this->isReplaceable = true;
|
||||
|
|
@ -9,9 +13,18 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public static function setFlammabilityAndCatchingChance($blockID, $flammability, $v){
|
||||
self::$flammability[$blockID] = $flammability;
|
||||
self::$fireCatchingChance[$blockID] = $v;
|
||||
}
|
||||
|
||||
public static function canBurn(Level $level, $x, $y, $z){
|
||||
return self::$flammability[$level->level->getBlockID($x, $y, $z)] > 0;
|
||||
}
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
if($level->level->getBlockID($x, $y - 1, $z) !== NETHERRACK){
|
||||
$level->setBlock(new Position($x, $y, $z, $level), new AirBlock(), true, false, true);
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,8 +44,38 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
|||
}
|
||||
$this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}else if($type === BLOCK_UPDATE_SCHEDULED){
|
||||
$idBelow = $this->level->level->getBlockID($this->x, $this->y - 1, $this->z);
|
||||
$alwaysBurn = $idBelow == NETHERRACK;
|
||||
|
||||
if($this->meta < 15){
|
||||
$newMeta = $this->meta + 1; //TODO better formula
|
||||
if($newMeta > 15) $newMeta = 15;
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->id, $newMeta);
|
||||
}
|
||||
if($this->meta == 15){
|
||||
if(!$alwaysBurn && !self::canBurn($this->level, $this->x, $this->y - 1, $this->z) && mt_rand(0, 4) == 0){
|
||||
REMOVE_FIRE:
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, 0, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$chance = self::$fireCatchingChance[$idBelow];
|
||||
|
||||
if(mt_rand(0, 249) < $chance){
|
||||
//TODO ignite tnt
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y - 1, $this->z, 0, 0, true);
|
||||
goto REMOVE_FIRE;
|
||||
}
|
||||
|
||||
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED); //TODO looks like it also adds mt_rand(0, 9) to it
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ class FlintSteelItem extends ItemTool{
|
|||
}
|
||||
if($block->getID() === AIR and ($target instanceof SolidBlock)){
|
||||
$level->setBlock($block, new FireBlock(), true, false, true);
|
||||
$block->level->scheduleBlockUpdate($block, Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
|
||||
$level->scheduleBlockUpdate($block, 30, BLOCK_UPDATE_SCHEDULED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue