Last active
February 26, 2023 16:18
-
-
Save screret/62fec5abf961de2626d1f9303241bffb to your computer and use it in GitHub Desktop.
ScreenJS cursed showcase
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
StartupEvents.registry('menu', event => { | |
event.create('grass_block', 'block') | |
.addOutputSlot(98, 36, 0, 0, 1, 'minecraft:crafting') | |
.loop(builder => { | |
for (let y = 0; y < 3; y++) { | |
for(let x = 0; x < 3; x++) { | |
builder.addSlot(x * 18 + 8 /*<- the width of a slot, remember to add this*/, y * 18 + 18, x + y * 3, 0) | |
} | |
} | |
}) | |
.addItemHandler(9) | |
.addItemHandler(1) | |
.inputSlotIndices(0) | |
.playerInventoryY(100) | |
.tintColor(0xFF00FF00) | |
.setBlock('minecraft:grass_block') // the block that should open this GUI on right-click | |
.slotChanged((menu, level, player, items) => { | |
global.slotChanged(menu, level, player, items) | |
}) | |
}) | |
global.slotChanged = (menu, level, player, items) => { | |
if (!level.clientSide) { | |
let stack = '0x minecraft:air' | |
let wrapper = new CraftingWrapper(menu, 3, 3, items.getContainer(0)) | |
let optional = level.server.recipeManager.getRecipeFor('minecraft:crafting', wrapper, level) | |
if (optional.present) { | |
stack = optional.get().assemble(wrapper) | |
} | |
let output = items.getContainer(1) | |
output.setStackInSlot(0, stack) | |
menu.setRemoteSlot(9, stack) | |
menu.broadcastChanges() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment