Make tall grass not drop
This commit is contained in:
parent
604bec9e89
commit
278c90f5f9
3 changed files with 32 additions and 6 deletions
|
@ -161,9 +161,12 @@ export class MPClient {
|
|||
this.entity.world.setBlockWithNotify(this.diggingAt.x, this.diggingAt.y, this.diggingAt.z, 0);
|
||||
this.inventory.addItemStack(new ItemStack(Block.blockBehaviours[brokenBlockId].droppedItem(brokenBlockId), 1, metadata));
|
||||
this.send(new PacketWindowItems(0, this.inventory.getInventorySize(), this.inventory.constructInventoryPayload()).writeData());
|
||||
/*const itemEntity = new EntityItem(this.entity.world, new ItemStack(Block.blockBehaviours[brokenBlockId].droppedItem(brokenBlockId), 1, metadata));
|
||||
/*const itemId = Block.blockBehaviours[brokenBlockId].droppedItem(brokenBlockId);
|
||||
if (itemId !== -1) {
|
||||
const itemEntity = new EntityItem(this.entity.world, new ItemStack(itemId, 1, metadata));
|
||||
itemEntity.position.set(x + 0.5, y + 0.5, z + 0.5);
|
||||
this.entity.world.addEntity(itemEntity);*/
|
||||
this.entity.world.addEntity(itemEntity);
|
||||
}*/
|
||||
}
|
||||
|
||||
// TODO: Cap how far away a player is able to break blocks
|
||||
|
|
|
@ -4,6 +4,7 @@ import { BlockBehaviour } from "./BlockBehaviour";
|
|||
import { BlockBehaviourFlower } from "./BlockBehaviourFlower";
|
||||
import { BlockBehaviourGrass } from "./BlockBehaviourGrass";
|
||||
import { BlockBehaviourStone } from "./BlockBehaviourStone";
|
||||
import { BlockBehaviourTallGrass } from "./BlockBehaviourTallGrass";
|
||||
import { IBlockBehaviour } from "./IBlockBehaviour";
|
||||
|
||||
abstract class Behaviour {
|
||||
|
@ -12,6 +13,7 @@ abstract class Behaviour {
|
|||
public static stone = new BlockBehaviourStone();
|
||||
public static grass = new BlockBehaviourGrass();
|
||||
|
||||
public static tallGrass = new BlockBehaviourTallGrass();
|
||||
public static flower = new BlockBehaviourFlower();
|
||||
}
|
||||
|
||||
|
@ -142,10 +144,10 @@ export class Block {
|
|||
|
||||
static readonly glass = new Block(20).setHardness(0.3).setLightPassage(255).setBlockName("Glass");
|
||||
|
||||
static readonly tallGrass = new Block(31).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.flower).setBlockName("Tall Grass");
|
||||
static readonly tallGrass = new Block(31).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.tallGrass).setBlockName("Tall Grass");
|
||||
|
||||
static readonly flowerDandelion = new Block(37).setHardness(0).setLightPassage(255).setBlockName("Dandelion");
|
||||
static readonly flowerRose = new Block(38).setHardness(0).setLightPassage(255).setBlockName("Rose");
|
||||
static readonly flowerDandelion = new Block(37).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.flower).setBlockName("Dandelion");
|
||||
static readonly flowerRose = new Block(38).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.flower).setBlockName("Rose");
|
||||
|
||||
static readonly clay = new Block(82).setHardness(0.6).setBlockName("Clay");
|
||||
|
||||
|
|
21
server/blocks/BlockBehaviourTallGrass.ts
Normal file
21
server/blocks/BlockBehaviourTallGrass.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import AABB from "../AABB";
|
||||
import { World } from "../World";
|
||||
import { Block } from "./Block";
|
||||
import { BlockBehaviour } from "./BlockBehaviour";
|
||||
|
||||
export class BlockBehaviourTallGrass extends BlockBehaviour {
|
||||
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
||||
const block = world.getBlockId(x, y - 1, z);
|
||||
if (block !== Block.grass.blockId && block !== Block.dirt.blockId) {
|
||||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public droppedItem(blockId:number) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public getBoundingBox() {
|
||||
return AABB.getAABB(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue