feat: add gamemode selector in create world screen. always use creative with ?singleplayer=1

This commit is contained in:
Vitaly Turovsky 2024-05-26 18:58:46 +03:00
commit 0d8beef65c
11 changed files with 56 additions and 50 deletions

View file

@ -40,7 +40,7 @@ export const startWatchingHmr = () => {
const mesherSharedPlugins = [
{
name: 'minecraft-data',
setup (build) {
setup(build) {
build.onLoad({
filter: /data[\/\\]pc[\/\\]common[\/\\]legacy.json$/,
}, async (args) => {
@ -59,7 +59,7 @@ const plugins = [
...mesherSharedPlugins,
{
name: 'strict-aliases',
setup (build) {
setup(build) {
build.onResolve({
filter: /^minecraft-protocol$/,
}, async ({ kind, resolveDir }) => {
@ -110,7 +110,7 @@ const plugins = [
},
{
name: 'data-assets',
setup (build) {
setup(build) {
build.onResolve({
filter: /.*/,
}, async ({ path, ...rest }) => {
@ -161,7 +161,7 @@ const plugins = [
},
{
name: 'prevent-incorrect-linking',
setup (build) {
setup(build) {
build.onResolve({
filter: /.+/,
}, async ({ resolveDir, path, importer, kind, pluginData }) => {
@ -184,7 +184,7 @@ const plugins = [
},
{
name: 'watch-notify',
setup (build) {
setup(build) {
let count = 0
let time
let prevHash
@ -234,7 +234,7 @@ const plugins = [
},
{
name: 'esbuild-readdir',
setup (build) {
setup(build) {
build.onResolve({
filter: /^esbuild-readdir:.+$/,
}, ({ resolveDir, path }) => {
@ -262,7 +262,7 @@ const plugins = [
},
{
name: 'esbuild-import-glob',
setup (build) {
setup(build) {
build.onResolve({
filter: /^esbuild-import-glob\(path:(.+),skipFiles:(.+)\)+$/,
}, ({ resolveDir, path }) => {
@ -292,7 +292,7 @@ const plugins = [
},
{
name: 'fix-dynamic-require',
setup (build) {
setup(build) {
build.onResolve({
filter: /1\.14\/chunk/,
}, async ({ resolveDir, path }) => {
@ -321,7 +321,7 @@ const plugins = [
},
{
name: 'react-displayname',
setup (build) {
setup(build) {
build.onLoad({
filter: /.tsx$/,
}, async ({ path }) => {

View file

@ -6,10 +6,10 @@ const fns = {
async getAlias () {
const aliasesRaw = process.env.ALIASES
if (!aliasesRaw) throw new Error('No aliases found')
const aliases = aliasesRaw.split('\n').map((x) => x.split('='))
const aliases = aliasesRaw.split('\n').map((x) => x.trim().split('='))
const githubActionsPull = process.env.PULL_URL?.split('/').at(-1)
if (!githubActionsPull) throw new Error(`Not a pull request, got ${process.env.GITHUB_REF}`)
const prNumber = githubActionsPull[1]
if (!githubActionsPull) throw new Error(`Not a pull request, got ${process.env.PULL_URL}`)
const prNumber = githubActionsPull
const alias = aliases.find((x) => x[0] === prNumber)
if (alias) {
// set github output
@ -18,7 +18,7 @@ const fns = {
}
}
function setOutput(key, value) {
function setOutput (key, value) {
// Temporary hack until core actions library catches up with github new recommendations
const output = process.env['GITHUB_OUTPUT']
fs.appendFileSync(output, `${key}=${value}${os.EOL}`)