convert classes to es6
(cherry picked from commit e7615d49a4071fe5b5f192884f142c9f3385211a)
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
window.Chunk = class {
|
||||
import EnumSkyBlock from "../../util/EnumSkyBlock.js";
|
||||
import Block from "./block/Block.js";
|
||||
import World from "./World.js";
|
||||
import ChunkSection from "./ChunkSection.js";
|
||||
|
||||
export default class Chunk {
|
||||
|
||||
constructor(world, x, z) {
|
||||
this.world = world;
|
||||
@@ -92,7 +97,7 @@ window.Chunk = class {
|
||||
}
|
||||
}
|
||||
|
||||
this.world.updateLight(EnumSkyBlock.Block,
|
||||
this.world.updateLight(EnumSkyBlock.BLOCK,
|
||||
this.x * 16, targetY - 1, this.z * 16,
|
||||
this.x * 16 + 16, targetY + 1, this.z * 16 + 16
|
||||
);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
window.ChunkSection = class {
|
||||
import EnumSkyBlock from "../../util/EnumSkyBlock.js";
|
||||
import Block from "./block/Block.js";
|
||||
|
||||
export default class ChunkSection {
|
||||
|
||||
static SIZE = 16;
|
||||
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
window.World = class {
|
||||
import ChunkSection from "./ChunkSection.js";
|
||||
import WorldGenerator from "./generator/WorldGenerator.js";
|
||||
import Chunk from "./Chunk.js";
|
||||
import MathHelper from "../../util/MathHelper.js";
|
||||
import BoundingBox from "../../util/BoundingBox.js";
|
||||
import MetadataChunkBlock from "../../util/MetadataChunkBlock.js";
|
||||
import EnumSkyBlock from "../../util/EnumSkyBlock.js";
|
||||
import Block from "./block/Block.js";
|
||||
import EnumBlockFace from "../../util/EnumBlockFace.js";
|
||||
import Vector3 from "../../util/Vector3.js";
|
||||
|
||||
export default class World {
|
||||
|
||||
static TOTAL_HEIGHT = ChunkSection.SIZE * 8 - 1; // ChunkSection.SIZE * 16 - 1;
|
||||
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
window.Block = class {
|
||||
import BlockRenderType from "../../../util/BlockRenderType.js";
|
||||
import EnumBlockFace from "../../../util/EnumBlockFace.js";
|
||||
import MovingObjectPosition from "../../../util/MovingObjectPosition.js";
|
||||
import BoundingBox from "../../../util/BoundingBox.js";
|
||||
|
||||
export default class Block {
|
||||
|
||||
static blocks = new Map();
|
||||
|
||||
static sounds = {};
|
||||
|
||||
static create() {
|
||||
// Sounds
|
||||
Block.sounds.stone = new Sound("stone", 1.0);
|
||||
Block.sounds.wood = new Sound("wood", 1.0);
|
||||
Block.sounds.gravel = new Sound("gravel", 1.0);
|
||||
Block.sounds.grass = new Sound("grass", 1.0);
|
||||
Block.sounds.cloth = new Sound("cloth", 1.0);
|
||||
Block.sounds.sand = new Sound("sand", 1.0);
|
||||
|
||||
// Blocks
|
||||
Block.STONE = new BlockStone(1, 0);
|
||||
Block.GRASS = new BlockGrass(2, 1);
|
||||
Block.DIRT = new BlockDirt(3, 2);
|
||||
Block.LOG = new BlockLog(17, 4);
|
||||
Block.LEAVE = new BlockLeave(18, 6);
|
||||
Block.WATER = new BlockWater(9, 7);
|
||||
Block.SAND = new BlockSand(12, 8)
|
||||
Block.TORCH = new BlockTorch(50, 9)
|
||||
}
|
||||
|
||||
constructor(id, textureSlotId = id) {
|
||||
this.id = id;
|
||||
this.textureSlotId = textureSlotId;
|
||||
@@ -209,5 +194,5 @@ window.Block = class {
|
||||
static getById(typeId) {
|
||||
return Block.blocks.get(typeId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
window.BlockDirt = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
|
||||
export default class BlockDirt extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
window.BlockGrass = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
import EnumBlockFace from "../../../util/EnumBlockFace.js";
|
||||
|
||||
export default class BlockGrass extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
window.BlockLeave = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
|
||||
export default class BlockLeave extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
window.BlockLog = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
|
||||
export default class BlockLog extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import BlockLog from "./BlockLog.js";
|
||||
import BlockStone from "./BlockStone.js";
|
||||
import BlockGrass from "./BlockGrass.js";
|
||||
import BlockDirt from "./BlockDirt.js";
|
||||
import BlockLeave from "./BlockLeave.js";
|
||||
import BlockWater from "./BlockWater.js";
|
||||
import BlockSand from "./BlockSand.js";
|
||||
import BlockTorch from "./BlockTorch.js";
|
||||
import Sound from "./sound/Sound.js";
|
||||
import Block from "./Block.js";
|
||||
|
||||
export class BlockRegistry {
|
||||
|
||||
static create() {
|
||||
// Sounds
|
||||
Block.sounds.stone = new Sound("stone", 1.0);
|
||||
Block.sounds.wood = new Sound("wood", 1.0);
|
||||
Block.sounds.gravel = new Sound("gravel", 1.0);
|
||||
Block.sounds.grass = new Sound("grass", 1.0);
|
||||
Block.sounds.cloth = new Sound("cloth", 1.0);
|
||||
Block.sounds.sand = new Sound("sand", 1.0);
|
||||
|
||||
// Blocks
|
||||
Block.STONE = new BlockStone(1, 0);
|
||||
Block.GRASS = new BlockGrass(2, 1);
|
||||
Block.DIRT = new BlockDirt(3, 2);
|
||||
Block.LOG = new BlockLog(17, 4);
|
||||
Block.LEAVE = new BlockLeave(18, 6);
|
||||
Block.WATER = new BlockWater(9, 7);
|
||||
Block.SAND = new BlockSand(12, 8)
|
||||
Block.TORCH = new BlockTorch(50, 9)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
window.BlockSand = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
|
||||
export default class BlockSand extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
window.BlockStone = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
|
||||
export default class BlockStone extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
window.BlockTorch = class extends Block {
|
||||
import BoundingBox from "../../../util/BoundingBox.js";
|
||||
import Block from "./Block.js";
|
||||
import EnumBlockFace from "../../../util/EnumBlockFace.js";
|
||||
import BlockRenderType from "../../../util/BlockRenderType.js";
|
||||
|
||||
export default class BlockTorch extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
window.BlockWater = class extends Block {
|
||||
import Block from "./Block.js";
|
||||
|
||||
export default class BlockWater extends Block {
|
||||
|
||||
constructor(id, textureSlotId) {
|
||||
super(id, textureSlotId);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
window.Sound = class {
|
||||
export default class Sound {
|
||||
|
||||
constructor(name, pitch) {
|
||||
this.name = name;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
window.NoiseGenerator = class {
|
||||
export default class NoiseGenerator {
|
||||
perlin(x, z) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
window.WorldGenerator = class {
|
||||
import Random from "../../../util/Random.js";
|
||||
import NoiseGeneratorCombined from "./noise/NoiseGeneratorCombined.js";
|
||||
import NoiseGeneratorOctaves from "./noise/NoiseGeneratorOctaves.js";
|
||||
import ChunkSection from "../ChunkSection.js";
|
||||
import Block from "../block/Block.js";
|
||||
|
||||
export default class WorldGenerator {
|
||||
|
||||
constructor(world, seed) {
|
||||
this.world = world;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
window.NoiseGeneratorCombined = class extends NoiseGenerator {
|
||||
import NoiseGenerator from "../NoiseGenerator.js";
|
||||
|
||||
export default class NoiseGeneratorCombined extends NoiseGenerator {
|
||||
|
||||
constructor(firstGenerator, secondGenerator) {
|
||||
super();
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
window.NoiseGeneratorOctaves = class extends NoiseGenerator {
|
||||
import NoiseGenerator from "../NoiseGenerator.js";
|
||||
import NoiseGeneratorPerlin from "./NoiseGeneratorPerlin.js";
|
||||
|
||||
export default class NoiseGeneratorOctaves extends NoiseGenerator {
|
||||
|
||||
constructor(random, octaves) {
|
||||
super();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
window.NoiseGeneratorPerlin = class extends NoiseGenerator {
|
||||
import NoiseGenerator from "../NoiseGenerator.js";
|
||||
|
||||
export default class NoiseGeneratorPerlin extends NoiseGenerator {
|
||||
|
||||
constructor(random) {
|
||||
super();
|
||||
|
||||
Reference in New Issue
Block a user