-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix spawning in 1.16.5 worlds, 1.17 (#660)
* Fix spawning in 1.16.5 worlds * registry updates * 1.17
- Loading branch information
1 parent
8f29e3a
commit 414d4dc
Showing
43 changed files
with
271 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,5 @@ | |
}, | ||
"everybody-op": false, | ||
"max-entities":100, | ||
"version": "1.16.5" | ||
"version": "1.17.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,28 @@ | ||
module.exports = (obj) => { | ||
return async (eventName, data, func, cancelFunc) => { | ||
let hiddenCancelled = false | ||
let cancelled = false | ||
const { emitAsync } = require('./utils') | ||
module.exports = function createBehavior (entity) { | ||
return async function (eventName, data, onSuccess, onCancel) { | ||
let isCancelled = false | ||
let runOnCancelCb = true | ||
let hideCancel = false | ||
let cancelCount = 0 | ||
let defaultCancel = true | ||
const cancel = (dC = true, hidden = false) => { // Hidden shouldn't be used often but it's not hard to implement so meh | ||
if (hidden) hiddenCancelled = true | ||
else { | ||
cancelled = true | ||
cancelCount++ | ||
} | ||
defaultCancel = dC | ||
function cancel (triggerCancelBehavior = true, hideFromPlugins = false) { | ||
runOnCancelCb = triggerCancelBehavior | ||
hideCancel = hideFromPlugins | ||
isCancelled = true | ||
cancelCount++ | ||
} | ||
|
||
let resp | ||
|
||
func = func || (() => {}) | ||
|
||
await obj.emitThen(eventName + '_cancel', data, cancel).catch((err) => setTimeout(() => { throw err }, 0)) | ||
await obj.emitThen(eventName, data, cancelled, cancelCount).catch((err) => setTimeout(() => { throw err }, 0)) | ||
|
||
if (!hiddenCancelled && !cancelled) { | ||
resp = func(data) | ||
if (resp instanceof Promise) resp = await resp.catch((err) => setTimeout(() => { throw err }, 0)) | ||
if (typeof resp === 'undefined') resp = true | ||
} else if (cancelFunc && defaultCancel) { | ||
resp = cancelFunc(data) | ||
if (resp instanceof Promise) resp = await resp.catch((err) => setTimeout(() => { throw err }, 0)) | ||
if (typeof resp === 'undefined') resp = false | ||
await emitAsync(entity, `${eventName}_cancel`, data, cancel) | ||
await emitAsync(entity, `${eventName}`, data, hideCancel ? false : isCancelled, hideCancel ? 0 : cancelCount) | ||
let resp = false | ||
if (isCancelled) { | ||
if (runOnCancelCb) { | ||
resp = await onCancel?.(data) | ||
} | ||
} else { | ||
resp = await onSuccess?.(data) | ||
resp ??= true | ||
} | ||
await obj.emitThen(eventName + '_done', data, cancelled).catch((err) => setTimeout(() => { throw err }, 0)) | ||
|
||
await emitAsync(entity, `${eventName}_done`, data, hideCancel ? false : isCancelled) | ||
return resp | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.