#OpenJDK something something
59 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
OpenJDK 64-bit server VM (java) 17 can be obtained here:
https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
Thus, a higher version would be here:
2ndly, is the version of fabric-api you're using the fabric version, or the forge version? Sinytra connector DOES let fabric mods run on forge, yes, but if a fabric mod has a mod dependancy, it's looking for the fabric version of that dependancy. So it's expecting the fabric version of fabric-api.
3rdly, none of this is a KubeJS issue.
sorry, but I also dunno any mc tech supports
Well, at least I'm in a good and helpful mood. But I would suggest maybe the Sinytra Connector's official support instead, next time.
fair 'nough
also I doubt the mod needs dependencies
https://modrinth.com/mod/slowcraft
I downloaded both links, but nothing changed
so fuck it, I have a new idea
any idea if it's possible to essentially recreate this mod through kubejs?
Before you give up, by having multiple java editions installed, you now have to select which one to launch minecraft with.
If you're using Prism launcher, for example, you can go to your pack settings, go to the java tab, click detect, and then select the java version you want to use.
Now, do I know if it's possible to recreate this mod...? Well:
//startup script
StartupEvents.registry("items", event => {
var max_steps_to_craft_fake = 5
event.create("fake_slowcraft:incomplete_diamond_pickaxe")
.unstackable()
.maxDamage(max_steps_to_craft_fake)
.use((itemstack,level,entity) => true)
.useAnimation("crossbow") // I only know of "bow" and "crossbow" for valid options here
.useDuration((itemstack) => 10) // in ticks. So this is half a second per step
.finishUsing((itemstack,level,entity) => {
if (itemstack.getDamageValue() == max_steps_to_craft_fake)
return Item.of("minecraft:diamond_pickaxe")
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
})
//server script
ServerEvents.recipes((event) => {
event.replaceOutput({output:"minecraft:diamond_pickaxe"},"minecraft:diamond_pickaxe",Item.of("fake_slowcraft:incomplete_diamond_pickaxe"))
})
Let me know how that works out.
holy shit
I had to change a little bit
but this works
//startup
StartupEvents.registry('item', event => {
var max_steps_to_craft_fake = 5
event.create("kubejs:incomplete_diamond_pickaxe")
.unstackable()
.maxDamage(max_steps_to_craft_fake)
.use((itemstack,level,entity) => true)
.useAnimation("crossbow") // I only know of "bow" and "crossbow" for valid options here
.useDuration((itemstack) => 10) // in ticks. So this is half a second per step
.finishUsing((itemstack,level,entity) => {
if (itemstack.getDamageValue() == max_steps_to_craft_fake)
return Item.of("minecraft:diamond_pickaxe")
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
)})
and
//server
ServerEvents.recipes((event) => {
event.replaceOutput({output:"minecraft:diamond_pickaxe"},"minecraft:diamond_pickaxe",Item.of("kubejs:incomplete_diamond_pickaxe"))
})
but this works flawlessly
thank you a thousand
one thing I'm trying to also figure out is how to implement audio
StartupEvents.registry('item', event => {
var max_steps_to_craft_fake = 30
event.create("kubejs:incomplete_diamond_pickaxe")
.unstackable()
.maxDamage(max_steps_to_craft_fake)
.use((itemstack,level,entity) => true)
SoundEvents.BLOCK_BAMBOO_HIT
.useAnimation("crossbow") // I only know of "bow" and "crossbow" for valid options here
.useDuration((itemstack) => 100) // in ticks. So this is half a second per step
.finishUsing((itemstack,level,entity) => {
if (itemstack.getDamageValue() == max_steps_to_craft_fake)
return Item.of("minecraft:diamond_pickaxe")
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
)})
but this doesn't work
Oh, yeah, I see where I missed a bracket or two.
So I see why inserting SoundEvents inside like that doesn't work. You're interupting the chain of .function().function() with a non ".", non-function. And then the .useAnimation() is now trying to run off the BLOCK_BAMBOO_HIT object. I've been struggling with sound myself, but it would probably go inside the .finishUsing() event block.
Ight bet, in like an hour ima try it out
no sadly it didn't work 🙁
Try it like this
StartupEvents.registry('item', event => {
var max_steps_to_craft_fake = 30
event.create("kubejs:incomplete_diamond_pickaxe")
.unstackable()
.maxDamage(max_steps_to_craft_fake)
.use((itemstack,level,entity) => true)
.useAnimation("crossbow") // I only know of "bow" and "crossbow" for valid options here
.useDuration((itemstack) => 100) // in ticks. So this is half a second per step
.finishUsing((itemstack,level,entity) => {
if (itemstack.getDamageValue() == max_steps_to_craft_fake)
return Item.of("minecraft:diamond_pickaxe")
level.runCommandSilent(`execute in ${level.dimension.toString()} run playsound minecraft:block.bamboo.hit player @a ${entity.x} ${entity.y} ${entity.z}`)
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
)})
Will try this shortly
Holy mother of fuck it works
Ticket re-opened!
I lied another problem has arrised
I'm tryna make em only have a percent chance to work sometimes
this what I came up with but doesn't work
StartupEvents.registry('item', event => {
var sifting_recipe = 28
event.create("kubejs:manual_dirt_sifting")
.unstackable()
.maxDamage(sifting_recipe)
.use((itemstack,level,entity) => true)
.useAnimation("brush")
.useDuration((itemstack) => 30)
.finishUsing((itemstack,level,entity) => {
if (itemstack.getDamageValue() == sifting_recipe)
return Item.of("kubejs:manual_sifter").withChance(0.4)
level.runCommandSilent(`execute in ${level.dimension.toString()} run playsound minecraft:block.gravel.break player @a ${entity.x} ${entity.y} ${entity.z}`)
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
)})
Bump
.withchance() only works with recipe outputs. This is not a recipe, it's a function of using it.
And you need to return the itemstack on failure.
So,
StartupEvents.registry('item', event => {
var sifting_recipe = 28
event.create("kubejs:manual_dirt_sifting")
.unstackable()
.maxDamage(sifting_recipe)
.use((itemstack,level,entity) => true)
.useAnimation("brush")
.useDuration((itemstack) => 30)
.finishUsing((itemstack,level,entity) => {
let rng = level.getRandom() // This is referencing Minecraft's seeded RNG, better to use than Math.random()
if (itemstack.getDamageValue() == sifting_recipe) {
if (rng.nextFloat() > 0.4) return itemstack //nextFloat() gets a number from 0-1, so here if a value is greater than the chance to finish, we return the original item.
// Alternatively, you could have it do
/*
{
level.runCommandSilent(`execute in ${level.dimension.toString()} run playsound minecraft:item.shield.break player @a ${entity.x} ${entity.y} ${entity.z}`)
return Item.of("minecraft:air");
}
*/
// after the `if (rng.nextFloat() > 0.4)` if you *want* it to break/fail.
return Item.of("kubejs:manual_sifter")
}
level.runCommandSilent(`execute in ${level.dimension.toString()} run playsound minecraft:block.gravel.break player @a ${entity.x} ${entity.y} ${entity.z}`)
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
)})```
I get an error
Sorry, I forgot a bracket or two, hence the latter half of the function being dimmed out. The error is probably letting you know that the 'conditional let' is out of scope, so I've edited my comment to fix that issue.
You tried to put a statement inside of a context that expected an expression.
Variable declarations, like:
let x = 5
are statements
if without braces:
if (condition) expression
accepts only expressions.
To fix, add braces:
if (condition) {
let x = 5;
}
Also important: let, const, and specifically in KJS' Rhino var, are block scoped. That means that these are only accessible within their block
Also, do you see the washed out colors at the bottom?
That means that VS Code (actually TypeScript) detected that the code below one of your return is unreachable
Ok lowkey this is still a 100% chance 😭
StartupEvents.registry('item', event => {
var sifting_recipe = 2 //28
event.create("kubejs:manual_dirt_sifting")
.unstackable()
.maxDamage(sifting_recipe)
.use((itemstack,level,entity) => true)
.useAnimation("brush")
.useDuration((itemstack) => 30)
.finishUsing((itemstack,level,entity) => {
let rng = level.getRandom()
if (itemstack.getDamageValue() == sifting_recipe) {
if (rng.nextFloat() > 0.4) return itemstack
return Item.of("kubejs:worm")
}
level.runCommandSilent(`execute in ${level.dimension.toString()} run playsound minecraft:block.gravel.break player @a ${entity.x} ${entity.y} ${entity.z}`)
itemstack.setDamageValue(itemstack.getDamageValue() +1)
return itemstack
}
)})
100% chance for what?
where do you recommend to put this?
below var sifting_recipe = 2 //28?
Wherever you have defined rng. In your proposed position, rng does not exist yet