Skip to content

Instantly share code, notes, and snippets.

@screret
screret / advanced_example_1.js
Last active March 3, 2023 11:42
beJs & ScreenJS advanced example 1
// priority: 0
const Mth = Java.loadClass("net.minecraft.util.Mth")
const Boolean = Java.loadClass('java.lang.Boolean')
StartupEvents.registry('block', event => {
event.create('example_block_2', 'entity').material('wood').hardness(1.0).displayName('Example Block')
.entity(builder => {
builder.ticker((level, pos, state, be) => {
if (!level.clientSide) {
@screret
screret / multiblock.js
Created February 26, 2023 14:36
beJS multiblock example
StartupEvents.registry('block', event => {
let CAP_PREDICATE = be => {
return be != null && (be.getCapability(ForgeCapabilities.ITEM_HANDLER).present || be.getCapability(ForgeCapabilities.FLUID_HANDLER).present || be.getCapability(ForgeCapabilities.ENERGY).present)
}
event.create('multi_block', 'multiblock').material('wood').hardness(1.0).displayName('Multiblock')
.entity(builder => { // adds a BlockEntity onto this block
builder.ticker((level, pos, state, be) => { // a tick method, called on block entity tick
@screret
screret / grass_crafting.js
Last active February 26, 2023 16:18
ScreenJS cursed showcase
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)
}
@screret
screret / multiblock_with_io.js
Created February 27, 2023 21:25
beJS & screenJS multiblock w/ i/o "hatches"
StartupEvents.registry('block', event => {
event.create('output_item', 'entity').material('metal').hardness(1.0).displayName('Item Output Hatch')
.entity(builder => {
builder.itemHandler(9, false)
})
event.create('input_item', 'entity').material('metal').hardness(1.0).displayName('Item Input Hatch')
@screret
screret / any_processing.js
Created March 3, 2023 19:36
beJS & ScreenJS "automatic" processing BlockEntity script
// priority: 0
// This script, by default, creates a BlockEntity (that can do energy + items -> items) per call to processor() in block startup event.
// the blocks created also have their own recipe type and they are directional.
// if you want to make the output extractable with automation, you'll have to use PowerfulJS and make some modifications to this script.
// if you know how to read code, good!
const Mth = Java.loadClass("net.minecraft.util.Mth")
const Explosion = Java.loadClass("net.minecraft.world.level.Explosion")