convert classes to es6

(cherry picked from commit e7615d49a4071fe5b5f192884f142c9f3385211a)
This commit is contained in:
LabyStudio
2022-04-15 05:59:25 +02:00
parent dacd2496ea
commit 45961bbfbb
66 changed files with 319 additions and 210 deletions
@@ -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;