#Redeclaration of const *insert here*
39 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
change all instances of const to let, const is broken in a lot of places in current rhino
mainly for-loops ect
seems like it stopped the error but has made it so only one of the two scripts work
i think what happened was you had 2 unrelated issues and changing all const to let solved one of them 
also
Never say 'it crashed', 'it errored', or 'it didn't work' without providing the full scripts and log/crash report!
another thing that could be happening is you were using one of those const as some global variable where it's no longer available, in that case youll want to make your global variable an actual global variable with global.somevariable = 10
though i cant really say without the current code or error report
let CharcoalMakingTime = 100
/**@param {Internal.BlockEntityJS} blockEntity */
global.charcoalKilnCore = blockEntity => {
let {data, block, level, x, y, z} = blockEntity
let exposedSeconds = data.getInt("Exposed")
let timePassed = data.getInt("Passed")
if(checkEncased(blockEntity)) data.putInt("Passed", timePassed + 1);
else data.putInt("Exposed", exposedSeconds + 1);
level.spawnParticles("adchimneys:modern_smoke", false, x + 0.5, y + 1, z + 0.5, 0, 1.5, 0, 3, 0)
spreadCharcoalKiln(blockEntity)
if(exposedSeconds >= 6) block.set("minecraft:fire")
if(timePassed >= CharcoalMakingTime) block.set("kubejs:pile_of_charcoal")
}
let $Direction = Java.loadClass("net.minecraft.core.Direction")
/@param {Internal.BlockEntityJS} blockEntity /
let checkEncased = (blockEntity) => {
let {level, block} = blockEntity
let encased = $Direction.values().every(dir => {
/ @type {Internal.BlockContainerJS} */let theBlock = block[dir]
let faceSize = theBlock.blockState.getCollisionShape(level, theBlock.pos)
.getFaceShape(dir.opposite)
.toAabbs()[0]?.size||0
let isFull = faceSize == 1
return isFull
})
return encased
}
/@param {Internal.BlockEntityJS} blockEntity /
let spreadCharcoalKiln = blockEntity => {
let {level, block} = blockEntity
$Direction.values().every(dir => {
/ @type {Internal.BlockContainerJS} /let theBlock = block[dir]
if(theBlock.hasTag('kubejs:charcoal_kiln_block')){
theBlock.set("kubejs:charcoal_kiln_core")
}
})
}
ForgeEvents.onEvent("net.minecraftforge.event.level.BlockEvent$NeighborNotifyEvent", event => {
global.fireCheck(event)
})
/*
*
- @param {Internal.BlockEvent$NeighborNotifyEvent} event
- @returns
*/
global.fireCheck = event => {
let {pos, state} = event
/**@type {Internal.ServerLevel} */let level = event.level
if(!state.isBurning(level, pos)) return;
let offsets = [1, -1].map(n => Array.from(Array(3).keys()).map(i => {let vec3i = [0, 0, 0]; vec3i[i] = n; return vec3i;})).reduce((a, b) => a.concat(b))
offsets.forEach(offset => {
let offsetPos = pos.offset.apply(pos, offset)
let offsetBlock = level.getBlock(offsetPos)
if(offsetBlock.hasTag("kubejs:charcoal_kiln_block")){
offsetBlock.set("kubejs:charcoal_kiln_core")
}
})
}
code for one script
let VesselCookTime = 10
/**@param {Internal.BlockEntityJS} blockEntity */
global.unfiredVesselCooking = blockEntity => {
let {data, block, level, x, y, z} = blockEntity
let exposedSeconds = data.getInt("Exposed")
let timePassed = data.getInt("Passed")
if(checkEncased(blockEntity)) data.putInt("Passed", timePassed + 1);
else data.putInt("Exposed", exposedSeconds + 1);
level.spawnParticles("adchimneys:modern_smoke", false, x + 0.5, y + 1, z + 0.5, 0, 1.5, 0, 3, 0)
spreadVesselCooking(blockEntity)
if(exposedSeconds >= 6) block.set("kubejs:unfired_vessel_log4")
if(timePassed >= VesselCookTime) block.set("kubejs:vessel_ash")
}
let $Direction1 = Java.loadClass("net.minecraft.core.Direction")
/@param {Internal.BlockEntityJS} blockEntity /
let checkEncased = (blockEntity) => {
let {level, block} = blockEntity
let encased = $Direction1.values().every(dir => {
/ @type {Internal.BlockContainerJS} */let theBlock = block[dir]
if(dir == "up"){
if(theBlock.blockState.air) theBlock.set("fire")
return theBlock.blockState.isBurning(level, theBlock.pos) || theBlock.blockState.air
}
let faceSize = theBlock.blockState.getCollisionShape(level, theBlock.pos)
.getFaceShape(dir.opposite)
.toAabbs()[0]?.size||0
let isFull = faceSize == 1
return isFull
})
return encased
}
/@param {Internal.BlockEntityJS} blockEntity /
let spreadVesselCooking = blockEntity => {
let {level, block} = blockEntity
$Direction1.values().every(dir => {
/ @type {Internal.BlockContainerJS} /let theBlock = block[dir]
if(theBlock.hasTag('kubejs:charcoal_kiln_block')){
theBlock.set("kubejs:charcoal_kiln_core")
}
})
}
ForgeEvents.onEvent("net.minecraftforge.event.level.BlockEvent$NeighborNotifyEvent", event => {
global.fireCheck1(event)
})
/*
*
- @param {Internal.BlockEvent$NeighborNotifyEvent} event
- @returns
*/
global.fireCheck1 = event => {
let {pos, state} = event
/**@type {Internal.ServerLevel} */let level = event.level
if(!state.isBurning(level, pos)) return;
let offsets = [1, -1].map(n => Array.from(Array(3).keys()).map(i => {let vec3i = [0, 0, 0]; vec3i[i] = n; return vec3i;})).reduce((a, b) => a.concat(b))
offsets.forEach(offset => {
let offsetPos = pos.offset.apply(pos, offset)
let offsetBlock = level.getBlock(offsetPos)
if(offsetBlock.hasTag("kubejs:vessel_cooking")){
offsetBlock.set("kubejs:unfired_vessel_cooking")
}
})
}
code for the other
the vessel script is what is working just fine
the charcoal script is doing most of what it is supposed to except it turns itself into fire when it shouldn't
Basically you place log in ground then light it on fire then place another #minecraft:dirt block on top then after some time it turns into charcoal except it turns itself into fire when in the ground but turns itself into charcoal if no block is above it
And the vessel script works essentially identical to the pit kiln in TFC and it functions just fine
If I remove the vessel script the charcoal script works as intended
You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes
```js :arrow_left:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
``` :arrow_left:
This example will look like this:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
Please send your KubeJS startup log. It can be found at /minecraft/logs/kubejs/startup.log.
If you are on 1.18 or 1.16 it will be called startup.txt.
Please send the file directly, without links or snippets.
if the script is really long you can also just send the actual .js files here so people can open it up with gnome
Paste version of vesselcooking.js, charcoalmaking.js from @carmine island
okay my bad
^
mainly what im after, if theres an error itll be there
Paste version of startup.log from @carmine island