mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Cleaned up fuel duration handling, fixed some fuel items not working in furnaces
This commit is contained in:
parent
dc3f13cd30
commit
6efa4343b1
@ -718,6 +718,14 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
return $this->getHardness() !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time in ticks which the block will fuel a furnace for.
|
||||
* @return int
|
||||
*/
|
||||
public function getFuelTime() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Block on the side $side, works like Vector3::side()
|
||||
*
|
||||
|
@ -52,4 +52,8 @@ class Bookshelf extends Solid{
|
||||
];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
@ -174,4 +174,8 @@ class Chest extends Transparent{
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -55,4 +55,8 @@ class Coal extends Solid{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 16000;
|
||||
}
|
||||
}
|
@ -60,4 +60,8 @@ class CraftingTable extends Solid{
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -38,4 +38,8 @@ class DaylightSensor extends Transparent{
|
||||
public function getHardness(){
|
||||
return 0.2;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
@ -88,4 +88,8 @@ class Fence extends Transparent{
|
||||
return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,4 +92,8 @@ class FenceGate extends Transparent{
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,8 @@ class NoteBlock extends Solid{
|
||||
public function getName(){
|
||||
return "Note Block";
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
@ -59,4 +59,8 @@ class Planks extends Solid{
|
||||
return $names[$this->meta & 0x07] ?? "Unknown";
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,4 +112,8 @@ class Sapling extends Flowable{
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 100;
|
||||
}
|
||||
}
|
@ -75,4 +75,8 @@ class StoneSlab extends WoodenSlab{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -156,4 +156,8 @@ class Trapdoor extends Transparent{
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
@ -78,4 +78,8 @@ class Wood extends Solid{
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -34,4 +34,8 @@ class WoodenPressurePlate extends StonePressurePlate{
|
||||
public function getName(){
|
||||
return "Wooden Pressure Plate";
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
@ -134,4 +134,8 @@ class WoodenSlab extends Transparent{
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
//TODO: remove this
|
||||
abstract class Fuel{
|
||||
public static $duration = [
|
||||
Item::COAL => 1600,
|
||||
Item::COAL_BLOCK => 16000,
|
||||
Item::WOOD => 300,
|
||||
Item::WOODEN_PLANKS => 300,
|
||||
Item::SAPLING => 100,
|
||||
Item::WOODEN_AXE => 200,
|
||||
Item::WOODEN_PICKAXE => 200,
|
||||
Item::WOODEN_SWORD => 200,
|
||||
Item::WOODEN_SHOVEL => 200,
|
||||
Item::WOODEN_HOE => 200,
|
||||
Item::STICK => 100,
|
||||
Item::FENCE => 300,
|
||||
Item::FENCE_GATE => 300,
|
||||
Item::SPRUCE_FENCE_GATE => 300,
|
||||
Item::BIRCH_FENCE_GATE => 300,
|
||||
Item::JUNGLE_FENCE_GATE => 300,
|
||||
Item::ACACIA_FENCE_GATE => 300,
|
||||
Item::DARK_OAK_FENCE_GATE => 300,
|
||||
Item::WOODEN_STAIRS => 300,
|
||||
Item::SPRUCE_STAIRS => 300,
|
||||
Item::BIRCH_STAIRS => 300,
|
||||
Item::JUNGLE_STAIRS => 300,
|
||||
Item::TRAPDOOR => 300,
|
||||
Item::WORKBENCH => 300,
|
||||
Item::BOOKSHELF => 300,
|
||||
Item::CHEST => 300,
|
||||
Item::BUCKET => 20000,
|
||||
];
|
||||
|
||||
}
|
@ -27,4 +27,8 @@ class Boat extends Item{
|
||||
public function __construct($meta = 0, $count = 1){
|
||||
parent::__construct(self::BOAT, $meta, $count, "Boat");
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 1200; //400 in PC
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,8 @@ class Bow extends Tool{
|
||||
parent::__construct(self::BOW, $meta, $count, "Bow");
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
|
||||
}
|
@ -39,6 +39,14 @@ class Bucket extends Item{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
if($this->meta === Block::LAVA or $this->meta === Block::FLOWING_LAVA){
|
||||
return 20000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$targetBlock = Block::get($this->meta);
|
||||
|
||||
|
@ -32,4 +32,8 @@ class Coal extends Item{
|
||||
}
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 1600;
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,6 @@ namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\inventory\Fuel;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\NBT;
|
||||
@ -917,15 +916,12 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
return 64;
|
||||
}
|
||||
|
||||
final public function getFuelTime(){
|
||||
if(!isset(Fuel::$duration[$this->id])){
|
||||
return null;
|
||||
}
|
||||
if($this->id !== self::BUCKET or $this->meta === 10){
|
||||
return Fuel::$duration[$this->id];
|
||||
}
|
||||
|
||||
return null;
|
||||
/**
|
||||
* Returns the time in ticks which the item will fuel a furnace for.
|
||||
* @return int
|
||||
*/
|
||||
public function getFuelTime() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,4 +43,8 @@ class ItemBlock extends Item{
|
||||
return $this->block;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->block->getFuelTime();
|
||||
}
|
||||
|
||||
}
|
@ -29,4 +29,8 @@ class Stick extends Item{
|
||||
parent::__construct(self::STICK, $meta, $count, "Stick");
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
@ -32,4 +32,8 @@ class WoodenAxe extends Tool{
|
||||
public function isAxe(){
|
||||
return Tool::TIER_WOODEN;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class WoodenHoe extends Tool{
|
||||
public function isHoe(){
|
||||
return Tool::TIER_WOODEN;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
}
|
@ -32,4 +32,8 @@ class WoodenPickaxe extends Tool{
|
||||
public function isPickaxe(){
|
||||
return Tool::TIER_WOODEN;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class WoodenShovel extends Tool{
|
||||
public function isShovel(){
|
||||
return Tool::TIER_WOODEN;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,8 @@ class WoodenSword extends Tool{
|
||||
public function isSword(){
|
||||
return Tool::TIER_WOODEN;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
$smelt = $this->server->getCraftingManager()->matchFurnaceRecipe($raw);
|
||||
$canSmelt = ($smelt instanceof FurnaceRecipe and $raw->getCount() > 0 and (($smelt->getResult()->equals($product) and $product->getCount() < $product->getMaxStackSize()) or $product->getId() === Item::AIR));
|
||||
|
||||
if($this->namedtag->BurnTime->getValue() <= 0 and $canSmelt and $fuel->getFuelTime() !== null and $fuel->getCount() > 0){
|
||||
if($this->namedtag->BurnTime->getValue() <= 0 and $canSmelt and $fuel->getFuelTime() > 0 and $fuel->getCount() > 0){
|
||||
$this->checkFuel($fuel);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user