Compare commits
No commits in common. "9f93f144619fedce34e5ff7f76bdb7651b3507b7" and "5c60d1d758a3378352ace1aae33dca787ee04363" have entirely different histories.
9f93f14461
...
5c60d1d758
9 changed files with 28 additions and 212 deletions
|
@ -123,16 +123,6 @@ export class Chunk {
|
||||||
this.blocks[x << 11 | z << 7 | y] = blockId;
|
this.blocks[x << 11 | z << 7 | y] = blockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setBlockMetadata(metadata:number, x:number, y:number, z:number) {
|
|
||||||
const index = x << 11 | z << 7 | y;
|
|
||||||
if (x < 0 || x > 15 || y < 0 || y > 127 || z < 0 || z > 15) {
|
|
||||||
this.queueBlockUpdateForOuterChunkBlock(this.blocks[index], metadata, x, y, z);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.metadata.set(index, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
public setBlockWithMetadata(blockId:number, metadata:number, x:number, y:number, z:number) {
|
public setBlockWithMetadata(blockId:number, metadata:number, x:number, y:number, z:number) {
|
||||||
if (x < 0 || x > 15 || y < 0 || y > 127 || z < 0 || z > 15) {
|
if (x < 0 || x > 15 || y < 0 || y > 127 || z < 0 || z > 15) {
|
||||||
this.queueBlockUpdateForOuterChunkBlock(blockId, metadata, x, y, z);
|
this.queueBlockUpdateForOuterChunkBlock(blockId, metadata, x, y, z);
|
||||||
|
|
|
@ -125,7 +125,18 @@ export class MinecraftServer {
|
||||||
//this.worlds.set(0, new World(this.saveManager, 0, worldSeed, new NewOverworld(worldSeed)));
|
//this.worlds.set(0, new World(this.saveManager, 0, worldSeed, new NewOverworld(worldSeed)));
|
||||||
this.worlds.set(0, new World(this.saveManager, 0, worldSeed, new HillyGenerator(worldSeed)));
|
this.worlds.set(0, new World(this.saveManager, 0, worldSeed, new HillyGenerator(worldSeed)));
|
||||||
this.worlds.set(-1, new World(this.saveManager, -1, worldSeed, new NetherGenerator(worldSeed)));
|
this.worlds.set(-1, new World(this.saveManager, -1, worldSeed, new NetherGenerator(worldSeed)));
|
||||||
|
|
||||||
|
// Generate spawn area (overworld)
|
||||||
|
/*(async () => {
|
||||||
|
const generateStartTime = Date.now();
|
||||||
|
Console.printInfo("Generating spawn area...");
|
||||||
|
for (let x = -3; x < 3; x++) {
|
||||||
|
for (let z = -3; z < 3; z++) {
|
||||||
|
await this.overworld.getChunkSafe(x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.printInfo(`Done! Took ${Date.now() - generateStartTime}ms`);
|
||||||
|
}).bind(this)();*/
|
||||||
(async () => {
|
(async () => {
|
||||||
const generateStartTime = Date.now();
|
const generateStartTime = Date.now();
|
||||||
let timer = Date.now();
|
let timer = Date.now();
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import mulberry32 from "./mulberry32";
|
|
||||||
|
|
||||||
export default class Random {
|
|
||||||
private readonly mulberry32;
|
|
||||||
|
|
||||||
public constructor(seed:number = Date.now()) {
|
|
||||||
this.mulberry32 = mulberry32(seed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public nextInt(bound = Number.MAX_SAFE_INTEGER) {
|
|
||||||
return Math.floor(this.mulberry32() * bound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public nextFloat() {
|
|
||||||
return this.mulberry32();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ import { PacketPickupSpawn } from "./packets/PickupSpawn";
|
||||||
import { QueuedBlockUpdate } from "./queuedUpdateTypes/BlockUpdate";
|
import { QueuedBlockUpdate } from "./queuedUpdateTypes/BlockUpdate";
|
||||||
import { IQueuedUpdate } from "./queuedUpdateTypes/IQueuedUpdate";
|
import { IQueuedUpdate } from "./queuedUpdateTypes/IQueuedUpdate";
|
||||||
import AABB from "./AABB";
|
import AABB from "./AABB";
|
||||||
import Random from "./Random";
|
|
||||||
|
|
||||||
export class World {
|
export class World {
|
||||||
public static ENTITY_MAX_SEND_DISTANCE = 50;
|
public static ENTITY_MAX_SEND_DISTANCE = 50;
|
||||||
|
@ -33,8 +32,6 @@ export class World {
|
||||||
public queuedUpdates:Array<IQueuedUpdate>;
|
public queuedUpdates:Array<IQueuedUpdate>;
|
||||||
public generator:IGenerator;
|
public generator:IGenerator;
|
||||||
|
|
||||||
public random:Random = new Random();
|
|
||||||
|
|
||||||
public readonly dimension:number;
|
public readonly dimension:number;
|
||||||
|
|
||||||
public constructor(saveManager:WorldSaveManager, dimension:number, seed:number, generator:IGenerator) {
|
public constructor(saveManager:WorldSaveManager, dimension:number, seed:number, generator:IGenerator) {
|
||||||
|
@ -160,18 +157,8 @@ export class World {
|
||||||
return this.getChunk(chunkX, chunkZ).getBlockMetadata(x & 0xf, y, z & 0xf);
|
return this.getChunk(chunkX, chunkZ).getBlockMetadata(x & 0xf, y, z & 0xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBlockLight(x:number, y:number, z:number) {
|
public getChunkBlockMetadata(chunk:Chunk, x:number, y:number, z:number) {
|
||||||
const chunkX = x >> 4,
|
return chunk.getBlockMetadata(x & 0xf, y, z & 0xf);
|
||||||
chunkZ = z >> 4;
|
|
||||||
|
|
||||||
return this.getChunk(chunkX, chunkZ).getBlockLight(x & 0xf, y, z & 0xf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getSkyLight(x:number, y:number, z:number) {
|
|
||||||
const chunkX = x >> 4,
|
|
||||||
chunkZ = z >> 4;
|
|
||||||
|
|
||||||
return this.getChunk(chunkX, chunkZ).getSkyLight(x & 0xf, y, z & 0xf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setBlock(blockId:number, x:number, y:number, z:number, doBlockUpdate?:boolean) {
|
public setBlock(blockId:number, x:number, y:number, z:number, doBlockUpdate?:boolean) {
|
||||||
|
@ -206,33 +193,11 @@ export class World {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setBlockMetadata(x:number, y:number, z:number, metadata:number, doBlockUpdate?:boolean) {
|
|
||||||
const chunkX = x >> 4, chunkZ = z >> 4;
|
|
||||||
|
|
||||||
const chunk = this.getChunk(chunkX, chunkZ);
|
|
||||||
const xc = x & 0xf, zc = z & 0xf;
|
|
||||||
chunk.setBlockMetadata(metadata, xc, y, zc);
|
|
||||||
|
|
||||||
if (doBlockUpdate) {
|
|
||||||
const blockId = chunk.getBlockId(xc, y, zc);
|
|
||||||
const blockUpdatePacket = new PacketBlockChange(x, y, z, blockId, metadata).writeData();
|
|
||||||
// Send block update to all players that have this chunk loaded
|
|
||||||
chunk.playersInChunk.forEach(player => {
|
|
||||||
player.mpClient?.send(blockUpdatePacket);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public setBlockWithNotify(x:number, y:number, z:number, blockId:number) {
|
public setBlockWithNotify(x:number, y:number, z:number, blockId:number) {
|
||||||
this.setBlock(blockId, x, y, z, true);
|
this.setBlock(blockId, x, y, z, true);
|
||||||
this.notifyNeighborBlocksOfChange(x, y, z, blockId);
|
this.notifyNeighborBlocksOfChange(x, y, z, blockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setBlockMetadataWithNotify(x:number, y:number, z:number, metadata:number) {
|
|
||||||
this.setBlockMetadata(x, y, z, metadata, true);
|
|
||||||
this.notifyNeighborBlocksOfChange(x, y, z, this.getBlockId(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
public setBlockAndMetadataWithNotify(x:number, y:number, z:number, blockId:number, metadata:number) {
|
public setBlockAndMetadataWithNotify(x:number, y:number, z:number, blockId:number, metadata:number) {
|
||||||
this.setBlockWithMetadata(blockId, metadata, x, y, z, true);
|
this.setBlockWithMetadata(blockId, metadata, x, y, z, true);
|
||||||
this.notifyNeighborBlocksOfChange(x, y, z, blockId);
|
this.notifyNeighborBlocksOfChange(x, y, z, blockId);
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
import { World } from "../World";
|
import { World } from "../World";
|
||||||
import { BlockBehaviourSapling } from "./BlockBehaviorSapling";
|
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import { BlockBehaviour } from "./BlockBehaviour";
|
||||||
import { BlockBehaviourClay } from "./BlockBehaviourClay";
|
import { BlockBehaviourClay } from "./BlockBehaviourClay";
|
||||||
import { BlockBehaviourFlower } from "./BlockBehaviourFlower";
|
import { BlockBehaviourFlower } from "./BlockBehaviourFlower";
|
||||||
import { BlockBehaviourGrass } from "./BlockBehaviourGrass";
|
import { BlockBehaviourGrass } from "./BlockBehaviourGrass";
|
||||||
import BlockBehaviourOre from "./BlockBehaviourOre";
|
|
||||||
import BlockBehaviourRedstoneOre from "./BlockBehaviourRedstoneOre";
|
|
||||||
import { BlockBehaviourStone } from "./BlockBehaviourStone";
|
import { BlockBehaviourStone } from "./BlockBehaviourStone";
|
||||||
import { BlockBehaviourTallGrass } from "./BlockBehaviourTallGrass";
|
import { BlockBehaviourTallGrass } from "./BlockBehaviourTallGrass";
|
||||||
import { IBlockBehaviour } from "./IBlockBehaviour";
|
import { IBlockBehaviour } from "./IBlockBehaviour";
|
||||||
|
@ -16,14 +13,10 @@ abstract class Behaviour {
|
||||||
|
|
||||||
public static stone = new BlockBehaviourStone();
|
public static stone = new BlockBehaviourStone();
|
||||||
public static grass = new BlockBehaviourGrass();
|
public static grass = new BlockBehaviourGrass();
|
||||||
public static sapling = new BlockBehaviourSapling();
|
|
||||||
public static ore = new BlockBehaviourOre();
|
|
||||||
|
|
||||||
public static tallGrass = new BlockBehaviourTallGrass();
|
public static tallGrass = new BlockBehaviourTallGrass();
|
||||||
public static flower = new BlockBehaviourFlower();
|
public static flower = new BlockBehaviourFlower();
|
||||||
|
|
||||||
public static redstoneOre = new BlockBehaviourRedstoneOre();
|
|
||||||
|
|
||||||
public static clay = new BlockBehaviourClay();
|
public static clay = new BlockBehaviourClay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +25,6 @@ export class Block {
|
||||||
|
|
||||||
public static readonly blocks:Array<Block> = new Array<Block>();
|
public static readonly blocks:Array<Block> = new Array<Block>();
|
||||||
public static readonly lightPassage:Array<number> = new Array<number>();
|
public static readonly lightPassage:Array<number> = new Array<number>();
|
||||||
public static readonly lightEmission:Array<number> = new Array<number>();
|
|
||||||
public static readonly hardness:Array<number> = new Array<number>();
|
public static readonly hardness:Array<number> = new Array<number>();
|
||||||
public static readonly blockAABBs:Array<AABB> = new Array<AABB>();
|
public static readonly blockAABBs:Array<AABB> = new Array<AABB>();
|
||||||
public static readonly blockBehaviours:Array<IBlockBehaviour> = new Array<IBlockBehaviour>();
|
public static readonly blockBehaviours:Array<IBlockBehaviour> = new Array<IBlockBehaviour>();
|
||||||
|
@ -41,7 +33,6 @@ export class Block {
|
||||||
public constructor(blockId:number) {
|
public constructor(blockId:number) {
|
||||||
Block.blocks[blockId] = this;
|
Block.blocks[blockId] = this;
|
||||||
Block.lightPassage[blockId] = 0;
|
Block.lightPassage[blockId] = 0;
|
||||||
Block.lightEmission[blockId] = 0;
|
|
||||||
Block.blockNames[blockId] = "";
|
Block.blockNames[blockId] = "";
|
||||||
Block.blockBehaviours[blockId] = Behaviour.base;
|
Block.blockBehaviours[blockId] = Behaviour.base;
|
||||||
this.blockId = blockId;
|
this.blockId = blockId;
|
||||||
|
@ -55,14 +46,6 @@ export class Block {
|
||||||
Block.lightPassage[this.blockId] = value;
|
Block.lightPassage[this.blockId] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get lightEmission() {
|
|
||||||
return Block.lightEmission[this.blockId];
|
|
||||||
}
|
|
||||||
|
|
||||||
public set lightEmission(value:number) {
|
|
||||||
Block.lightEmission[this.blockId] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get hardness() {
|
public get hardness() {
|
||||||
return Block.hardness[this.blockId];
|
return Block.hardness[this.blockId];
|
||||||
}
|
}
|
||||||
|
@ -105,11 +88,6 @@ export class Block {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setLightEmission(value:number) {
|
|
||||||
this.lightEmission = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public setBlockName(value:string) {
|
public setBlockName(value:string) {
|
||||||
this.blockName = value;
|
this.blockName = value;
|
||||||
return this;
|
return this;
|
||||||
|
@ -158,96 +136,27 @@ export class Block {
|
||||||
static readonly grass = new Block(2).setHardness(0.6).setBehaviour(Behaviour.grass).setBlockName("Grass");
|
static readonly grass = new Block(2).setHardness(0.6).setBehaviour(Behaviour.grass).setBlockName("Grass");
|
||||||
static readonly dirt = new Block(3).setHardness(0.5).setBlockName("Dirt");
|
static readonly dirt = new Block(3).setHardness(0.5).setBlockName("Dirt");
|
||||||
static readonly cobblestone = new Block(4).setHardness(2).setBlockName("Cobblestone");
|
static readonly cobblestone = new Block(4).setHardness(2).setBlockName("Cobblestone");
|
||||||
static readonly planks = new Block(5).setHardness(2).setBlockName("Planks");
|
|
||||||
static readonly sapling = new Block(6).setHardness(0).setBehaviour(Behaviour.sapling).setBlockName("Sapling");
|
|
||||||
static readonly bedrock = new Block(7).setUnbreakable().setBlockName("Bedrock");
|
static readonly bedrock = new Block(7).setUnbreakable().setBlockName("Bedrock");
|
||||||
static readonly waterFlowing = new Block(8).setHardness(100).setLightPassage(128).setBlockName("Flowing Water"); // TODO: Behavior script
|
|
||||||
static readonly waterStill = new Block(9).setHardness(100).setLightPassage(255).setBlockName("Still Water"); // TODO: Behavior script
|
static readonly waterStill = new Block(9).setHardness(100).setLightPassage(128).setBlockName("Still Water");
|
||||||
static readonly lavaFlowing = new Block(10).setHardness(0).setLightPassage(255).setBlockName("Flowing Lava"); // TODO: Behavior script
|
|
||||||
static readonly lavaStill = new Block(11).setHardness(100).setBlockName("Still Lava"); // TODO: Behavior script
|
static readonly lavaStill = new Block(11).setHardness(100).setBlockName("Still Lava");
|
||||||
|
|
||||||
static readonly sand = new Block(12).setHardness(0.5).setBlockName("Sand");
|
static readonly sand = new Block(12).setHardness(0.5).setBlockName("Sand");
|
||||||
static readonly gravel = new Block(13).setHardness(0.6).setBlockName("Gravel"); // TODO: Behavior script
|
static readonly gravel = new Block(13).setHardness(0.6).setBlockName("Gravel");
|
||||||
static readonly goldOre = new Block(14).setHardness(3).setBehaviour(Behaviour.ore).setBlockName("Gold Ore"); // TODO: Behavior script
|
|
||||||
static readonly ironOre = new Block(15).setHardness(3).setBehaviour(Behaviour.ore).setBlockName("Iron Ore"); // TODO: Behavior script
|
|
||||||
static readonly coalOre = new Block(16).setHardness(3).setBehaviour(Behaviour.ore).setBlockName("Coal Ore"); // TODO: Behavior script
|
|
||||||
static readonly wood = new Block(17).setHardness(2).setBlockName("Wood");
|
static readonly wood = new Block(17).setHardness(2).setBlockName("Wood");
|
||||||
static readonly leaves = new Block(18).setHardness(0.2).setLightPassage(240).setBlockName("Leaves");
|
static readonly leaves = new Block(18).setHardness(0.2).setLightPassage(240).setBlockName("Leaves");
|
||||||
static readonly sponge = new Block(19).setHardness(0.6).setBlockName("Sponge");
|
|
||||||
static readonly glass = new Block(20).setHardness(0.3).setLightPassage(255).setBlockName("Glass"); // TODO: Behavior script
|
static readonly glass = new Block(20).setHardness(0.3).setLightPassage(255).setBlockName("Glass");
|
||||||
static readonly lapisOre = new Block(21).setHardness(3).setBehaviour(Behaviour.ore).setBlockName("Lapis Ore"); // TODO: Behavior script
|
|
||||||
static readonly lapisBlock = new Block(22).setHardness(3).setBlockName("Lapis Block");
|
|
||||||
static readonly dispenser = new Block(23).setHardness(3.5).setBlockName("Dispenser");
|
|
||||||
static readonly sandStone = new Block(24).setHardness(0.8).setBlockName("Sand Stone");
|
|
||||||
static readonly noteblock = new Block(25).setHardness(0.8).setBlockName("Noteblock");
|
|
||||||
static readonly bed = new Block(26).setHardness(0.2).setBlockName("Bed"); // TODO: Behavior script
|
|
||||||
static readonly poweredRail = new Block(27).setHardness(0.7).setBlockName("Powered Rail"); // TODO: Behavior script
|
|
||||||
static readonly detectorRail = new Block(28).setHardness(0.7).setBlockName("Detector Rail"); // TODO: Behavior script
|
|
||||||
static readonly stickyPistonBase = new Block(29).setBlockName("Sticky Piston Base"); // TODO: Behavior script
|
|
||||||
static readonly web = new Block(30).setHardness(4).setLightPassage(255).setBlockName("Web"); // TODO: Behavior script
|
|
||||||
static readonly tallGrass = new Block(31).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.tallGrass).setBlockName("Tall Grass");
|
static readonly tallGrass = new Block(31).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.tallGrass).setBlockName("Tall Grass");
|
||||||
static readonly deadBush = new Block(32).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.tallGrass).setBlockName("Dead Bush"); // TODO: Give it's own behavior script
|
|
||||||
static readonly pistonBase = new Block(33).setBlockName("Piston Base"); // TODO: Behavior script
|
|
||||||
static readonly pistonExtension = new Block(34).setBlockName("Piston Extension"); // TODO: Behavior script?
|
|
||||||
static readonly wool = new Block(35).setHardness(0.8).setBlockName("Wool"); // TODO: Behavior script?
|
|
||||||
static readonly pistonMoving = new Block(36).setBlockName("Piston Move Event Block Why Is This A Block"); // TODO: Behavior script
|
|
||||||
static readonly flowerDandelion = new Block(37).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.flower).setBlockName("Dandelion");
|
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 flowerRose = new Block(38).setHardness(0).setLightPassage(255).setBehaviour(Behaviour.flower).setBlockName("Rose");
|
||||||
static readonly brownMushroom = new Block(39).setHardness(0).setLightEmission(0.125).setBlockName("Brown Mushroom"); // TODO: Behavior script
|
|
||||||
static readonly redMushroom = new Block(40).setHardness(0).setBlockName("Red Mushroom"); // TODO: Behavior script
|
|
||||||
static readonly goldBlock = new Block(41).setHardness(3).setBlockName("Gold Block");
|
|
||||||
static readonly ironBlock = new Block(42).setHardness(5).setBlockName("Iron Block");
|
|
||||||
static readonly doubleSlab = new Block(43).setHardness(2).setBlockName("Slab"); // TODO: Behavior script
|
|
||||||
static readonly singleSlab = new Block(44).setHardness(2).setBlockName("Slab"); // TODO: Behavior script
|
|
||||||
static readonly brick = new Block(45).setHardness(2).setBlockName("Brick");
|
|
||||||
static readonly tnt = new Block(46).setHardness(0).setBlockName("TNT"); // TODO: Behavior script
|
|
||||||
static readonly bookshelf = new Block(47).setHardness(1.5).setBlockName("Bookshelf"); // TODO: Behavior script
|
|
||||||
static readonly mossyCobblestone = new Block(48).setHardness(2).setBlockName("Mossy Cobblestone");
|
|
||||||
static readonly obsidian = new Block(49).setHardness(10).setBlockName("Obsidian"); // TODO: Behavior script?
|
|
||||||
static readonly torch = new Block(50).setHardness(0).setLightEmission(0.9).setBlockName("Torch"); // TODO: Behavior script
|
|
||||||
static readonly fire = new Block(51).setHardness(0).setLightEmission(1).setBlockName("Fire"); // TODO: Behavior script
|
|
||||||
static readonly mobSpawner = new Block(52).setHardness(5).setBlockName("Mob Spawner"); // TODO: Behavior script
|
|
||||||
static readonly woodenStairs = new Block(53).setBlockName("Wooden Stairs"); // TODO: Behavior script
|
|
||||||
static readonly chest = new Block(54).setHardness(2.5).setBlockName("Chest"); // TODO: Behavior script
|
|
||||||
static readonly redstoneDust = new Block(55).setHardness(0).setBlockName("Redstone Dust"); // TODO: Behavior script
|
|
||||||
static readonly diamondOre = new Block(56).setHardness(3).setBlockName("Diamond Ore"); // TODO: Behavior script
|
|
||||||
static readonly diamondBlock = new Block(57).setHardness(5).setBlockName("Diamond Block"); // TODO: Behavior script
|
|
||||||
static readonly craftingTable = new Block(58).setHardness(2.5).setBlockName("Crafting Table"); // TODO: Behavior script
|
|
||||||
static readonly wheatCrop = new Block(59).setHardness(0).setBlockName("Wheet Crop"); // TODO: Behavior script
|
|
||||||
static readonly farmland = new Block(60).setHardness(0.6).setBlockName("Farmland"); // TODO: Behavior script
|
|
||||||
static readonly furnaceIdle = new Block(61).setHardness(3.5).setBlockName("Furnace"); // TODO: Behavior script
|
|
||||||
static readonly furnaceActive = new Block(62).setHardness(3.5).setBlockName("Furnace"); // TODO: Behavior script
|
|
||||||
static readonly sign = new Block(63).setHardness(1).setBlockName("Sign"); // TODO: Behavior script
|
|
||||||
static readonly woodenDoor = new Block(64).setHardness(3).setBlockName("Wooden Door"); // TODO: Behavior script
|
|
||||||
static readonly ladder = new Block(65).setHardness(0.4).setBlockName("Ladder"); // TODO: Behavior script
|
|
||||||
static readonly rail = new Block(66).setHardness(0.7).setBlockName("Rail"); // TODO: Behavior script
|
|
||||||
static readonly cobblestoneStairs = new Block(67).setBlockName("Cobblestone Stairs"); // TODO: Behavior script
|
|
||||||
static readonly signWall = new Block(68).setHardness(1).setBlockName("Sign"); // TODO: Behavior script
|
|
||||||
static readonly lever = new Block(69).setHardness(0.5).setBlockName("Lever"); // TODO: Behavior script
|
|
||||||
static readonly stonePressurePlate = new Block(70).setHardness(0.5).setBlockName("Stone Pressure Plate"); // TODO: Behavior script
|
|
||||||
static readonly ironDoor = new Block(71).setHardness(5).setBlockName("Iron Door"); // TODO: Behavior script
|
|
||||||
static readonly woodenPressurePlate = new Block(72).setHardness(0.5).setBlockName("Wooden Pressure Plate"); // TODO: Behavior script
|
|
||||||
static readonly redstoneOre = new Block(73).setHardness(3).setBehaviour(Behaviour.redstoneOre).setBlockName("Redstone Ore"); // TODO: Behavior script
|
|
||||||
static readonly redstoneOreGlowing = new Block(74).setHardness(3).setLightEmission(0.625).setBehaviour(Behaviour.redstoneOre).setBlockName("Redstone Ore"); // TODO: Behavior script
|
|
||||||
static readonly redstoneTorchIdle = new Block(75).setHardness(0).setBlockName("Redstone Torch"); // TODO: Behavior script
|
|
||||||
static readonly redstoneTorchActive = new Block(76).setHardness(0).setLightEmission(0.5).setBlockName("Redstone Torch"); // TODO: Behavior script
|
|
||||||
static readonly button = new Block(77).setHardness(0.5).setBlockName("Button"); // TODO: Behavior script
|
|
||||||
static readonly snow = new Block(78).setHardness(0.1).setBlockName("Snow Layer"); // TODO: Behavior script
|
|
||||||
static readonly ice = new Block(79).setHardness(0.5).setLightPassage(128).setBlockName("Ice"); // TODO: Behavior script
|
|
||||||
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 clay = new Block(82).setHardness(0.6).setBehaviour(Behaviour.clay).setBlockName("Clay");
|
||||||
static readonly sugarcane = new Block(83).setHardness(0).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");
|
|
||||||
static readonly netherrack = new Block(87).setHardness(0.4).setBlockName("Netherrack");
|
static readonly netherrack = new Block(87).setHardness(0.4).setBlockName("Netherrack");
|
||||||
static readonly soulSand = new Block(88).setHardness(0.5).setBlockName("Soul Sand");
|
|
||||||
static readonly glowStone = new Block(89).setHardness(0.3).setBlockName("Glowstone"); // TODO: Behavior script
|
|
||||||
static readonly netherPortal = new Block(90).setUnbreakable().setLightEmission(0.75).setBlockName("Nether Portal"); // TODO: Behavior script
|
|
||||||
static readonly jackOLantern = new Block(91).setHardness(1).setLightEmission(1).setBlockName("Jack O' Lantern");
|
|
||||||
static readonly cake = new Block(92).setHardness(0.5).setBlockName("Cake"); // TODO: Behavior script
|
|
||||||
static readonly redstoneRepeaterIdle = new Block(93).setHardness(0).setBlockName("Redstone Repeater"); // TODO: Behavior script
|
|
||||||
static readonly redstoneRepeaterActive = new Block(94).setHardness(0).setLightEmission(0.625).setBlockName("Redstone Repeater"); // TODO: Behavior script
|
|
||||||
static readonly aprilFoolsLockedChest = new Block(95).setHardness(0).setLightEmission(1).setBlockName("Locked Chest");
|
|
||||||
static readonly trapdoor = new Block(96).setHardness(3).setBlockName("Trapdoor"); // TODO: Behavior script
|
|
||||||
}
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
import Random from "../Random";
|
|
||||||
import { World } from "../World";
|
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
|
||||||
|
|
||||||
export class BlockBehaviourSapling extends BlockBehaviour {
|
|
||||||
public randomTick(world:World, x:number, y:number, z:number, random:Random) {
|
|
||||||
if (world.getBlockLight(x, y + 1, z) >= 9 && random.nextInt(30) === 0) {
|
|
||||||
const blockMetadata = world.getBlockMetadata(x, y, z);
|
|
||||||
if ((blockMetadata & 8) === 0) {
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, blockMetadata | 8);
|
|
||||||
} else {
|
|
||||||
console.log("UNIMPLEMENTED TREE GROW!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
import Random from "../Random";
|
|
||||||
import { World } from "../World";
|
import { World } from "../World";
|
||||||
import { IBlockBehaviour } from "./IBlockBehaviour";
|
import { IBlockBehaviour } from "./IBlockBehaviour";
|
||||||
|
|
||||||
|
@ -8,5 +7,4 @@ export class BlockBehaviour implements IBlockBehaviour {
|
||||||
public droppedItem(blockId:number) { return blockId; }
|
public droppedItem(blockId:number) { return blockId; }
|
||||||
public droppedCount(blockId:number) { return 1; }
|
public droppedCount(blockId:number) { return 1; }
|
||||||
public getBoundingBox(x:number, y:number, z:number) { return AABB.getAABB(0 + x, 0 + y, 0 + z, 1 + x, 1 + y, 1 + z); }
|
public getBoundingBox(x:number, y:number, z:number) { return AABB.getAABB(0 + x, 0 + y, 0 + z, 1 + x, 1 + y, 1 + z); }
|
||||||
public randomTick(world:World, x:number, y:number, z:number, random:Random) {}
|
|
||||||
}
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
import { Item } from "../items/Item";
|
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
|
||||||
|
|
||||||
export default class BlockBehaviourOre extends BlockBehaviour {
|
|
||||||
public droppedItem(blockId:number) {
|
|
||||||
return Item.clay.shiftedItemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public droppedCount(blockId:number) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
import { Item } from "../items/Item";
|
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
|
||||||
|
|
||||||
export default class BlockBehaviourRedstoneOre extends BlockBehaviour {
|
|
||||||
public droppedItem(blockId:number) {
|
|
||||||
return Item.clay.shiftedItemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public droppedCount(blockId:number) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue