Skip to content

Commit

Permalink
fix: fix crafting in singleplayer
Browse files Browse the repository at this point in the history
fix(generator): leaves were filled with water in new versions
fix(generator): set plains biome for light grass color
  • Loading branch information
zardoy committed Oct 20, 2024
1 parent c53ba87 commit b21146b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 44 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ New React components, improve UI (including mobile support).
3. Develop, try to fix and test. Finally we should find a way to fix it. It's ideal to have an automatic test but it's not necessary for now
3. Repeat step 1 to make sure the task is done and the problem is fixed (or the feature is implemented)

## Updating Dependencies

1. Ensure mineflayer fork is up to date with the latest version of mineflayer original repo
2. Update PrismarineJS dependencies to the latest version: `minecraft-data` (be sure to replace the version twice in the package.json), `mineflayer`, `minecraft-protocol`, `prismarine-block`, `prismarine-chunk`, `prismarine-item`, ...
3. If `minecraft-protocol` patch fails, do this:
1. Remove the patch from `patchedDependencies` in `package.json`
2. Run `pnpm patch minecraft-protocol`, open patch directory
3. Apply the patch manually in this directory: `patch -p1 < minecraft-protocol@<version>.patch`
4. Run the suggested command from `pnpm patch ...` (previous step) to update the patch

### Would be useful to have

- cleanup folder & modules structure, cleanup playground code
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"esbuild-plugin-polyfill-node": "^0.3.0",
"express": "^4.18.2",
"filesize": "^10.0.12",
"flying-squid": "npm:@zardoy/flying-squid@^0.0.43",
"flying-squid": "npm:@zardoy/flying-squid@^0.0.44",
"fs-extra": "^11.1.1",
"google-drive-browserfs": "github:zardoy/browserfs#google-drive",
"jszip": "^3.10.1",
Expand Down Expand Up @@ -176,7 +176,8 @@
"prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything",
"minecraft-protocol": "github:PrismarineJS/node-minecraft-protocol#master",
"react": "^18.2.0",
"prismarine-chunk": "github:zardoy/prismarine-chunk"
"prismarine-chunk": "github:zardoy/prismarine-chunk",
"prismarine-item": "latest"
},
"updateConfig": {
"ignoreDependencies": []
Expand Down
91 changes: 51 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/inventoryWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ export const onGameLoad = (onLoad) => {
})

// workaround: singleplayer player inventory crafting
let skipUpdate = false
bot.inventory.on('updateSlot', ((_oldSlot, oldItem, newItem) => {
const currentSlot = _oldSlot as number
if (!miscUiState.singleplayer) return
if (!miscUiState.singleplayer || oldItem === newItem || skipUpdate) return
const { craftingResultSlot } = bot.inventory
if (currentSlot === craftingResultSlot && oldItem && !newItem) {
for (let i = 1; i < 5; i++) {
Expand All @@ -88,7 +89,10 @@ export const onGameLoad = (onLoad) => {
const craftingSlots = bot.inventory.slots.slice(1, 5)
try {
const resultingItem = getResultingRecipe(craftingSlots, 2)
void bot.creative.setInventorySlot(craftingResultSlot, resultingItem ?? null)
skipUpdate = true
void bot.creative.setInventorySlot(craftingResultSlot, resultingItem ?? null).then(() => {
skipUpdate = false
})
} catch (err) {
console.error(err)
// todo resolve the error! and why would we ever get here on every update?
Expand Down

0 comments on commit b21146b

Please sign in to comment.