#!/bin/bash

SRC_DIR=src
OUTPUT=lib/minecraft.js

echo "Concatenating to ${OUTPUT}..."
SRC_FILES="${SRC_DIR}/minecraft.js \
	${SRC_DIR}/vector2.js \
	${SRC_DIR}/vector3.js \
	${SRC_DIR}/uint4Array.js \
	${SRC_DIR}/tag.js \
	${SRC_DIR}/tagFormat.js \
	${SRC_DIR}/enchantment.js \
	${SRC_DIR}/item.js \
	${SRC_DIR}/player.js \
	${SRC_DIR}/entity.js"
cat ${SRC_FILES} > ${OUTPUT}

find ${SRC_DIR}/entities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}
find ${SRC_DIR}/entities/dynamicTileEntities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}
find ${SRC_DIR}/entities/itemEntities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}
find ${SRC_DIR}/entities/mobEntities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}
find ${SRC_DIR}/entities/projectileEntities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}
find ${SRC_DIR}/entities/vehicleEntities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}
find ${SRC_DIR}/entities/vehicleEntities/minecartEntities/ -type f -maxdepth 1 -exec cat {} \; >> ${OUTPUT}

SRC_FILES="${SRC_DIR}/network/packet.js \
	${SRC_DIR}/network/protocol.js \
	${SRC_DIR}/network/socket.js"
cat ${SRC_FILES} >> ${OUTPUT}

SRC_FILES="${SRC_DIR}/block.js \
	${SRC_DIR}/chunk.js \
	${SRC_DIR}/region.js \
	${SRC_DIR}/tileEntity.js \
	${SRC_DIR}/tileTick.js \
	${SRC_DIR}/world.js \
	${SRC_DIR}/items.js"
cat ${SRC_FILES} >> ${OUTPUT}
