make sugarcane break when no block under them
This commit is contained in:
parent
db9847634e
commit
a6da71e6a2
2 changed files with 20 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
import AABB from "../AABB";
|
||||
import { World } from "../World";
|
||||
import { BlockBehaviourSapling } from "./BlockBehaviorSapling";
|
||||
import { BlockBehaviourSugarcane } from "./BlockBehaviorSugarcane";
|
||||
import { BlockBehaviour } from "./BlockBehaviour";
|
||||
import { BlockBehaviourClay } from "./BlockBehaviourClay";
|
||||
import { BlockBehaviourFlower } from "./BlockBehaviourFlower";
|
||||
|
@ -25,6 +26,7 @@ abstract class Behaviour {
|
|||
public static redstoneOre = new BlockBehaviourRedstoneOre();
|
||||
|
||||
public static clay = new BlockBehaviourClay();
|
||||
public static sugarcane = new BlockBehaviourSugarcane();
|
||||
}
|
||||
|
||||
export class Block {
|
||||
|
@ -236,7 +238,7 @@ export class Block {
|
|||
static readonly snowBlock = new Block(80).setHardness(0.2).setBlockName("Snow"); // TODO: Behavior script
|
||||
static readonly cactus = new Block(81).setHardness(0.4).setBlockName("Cactus"); // TODO: Behavior script
|
||||
static readonly clay = new Block(82).setHardness(0.6).setBehaviour(Behaviour.clay).setBlockName("Clay");
|
||||
static readonly sugarcane = new Block(83).setHardness(0).setLightPassage(255).setBlockName("Sugar Cane"); // TODO: Behavior script
|
||||
static readonly sugarcane = new Block(83).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.sugarcane).setBlockName("Sugar Cane"); // TODO: Behavior script
|
||||
static readonly jukebox = new Block(84).setHardness(2).setBlockName("Jukebox"); // TODO: Behavior script
|
||||
static readonly fence = new Block(85).setHardness(2).setBlockName("Fence"); // TODO: Behavior script
|
||||
static readonly pumpkin = new Block(86).setHardness(1).setBlockName("Pumpkin");
|
||||
|
|
17
server/blocks/BlockBehaviorSugarcane.ts
Normal file
17
server/blocks/BlockBehaviorSugarcane.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import AABB from "../AABB";
|
||||
import { World } from "../World";
|
||||
import { Block } from "./Block";
|
||||
import { BlockBehaviour } from "./BlockBehaviour";
|
||||
|
||||
export class BlockBehaviourSugarcane extends BlockBehaviour {
|
||||
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
||||
const block = world.getBlockId(x, y - 1, z);
|
||||
if (block === 0 || block !== Block.sugarcane.blockId) {
|
||||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public getBoundingBox() {
|
||||
return AABB.getAABB(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue