#OpenJDK something something

59 messages · Page 1 of 1 (latest)

grand fern
#

I downloaded fabric api, that problem is solved. But OpenJDK... that's where shit gets funny. Where can I download that, and how do I implement this? The mod in question that is causing this issue is "slowcraft", a Fabric 1.21.1 mod. But I changed the mod version to 1.20.1, and am using "Sinytra Connector"

quaint glenBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

sand junco
#

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.

grand fern
sand junco
#

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.

grand fern
#

fair 'nough

grand fern
#

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?

sand junco
#

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.

grand fern
#

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

sand junco
#

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.

grand fern
#

Ight bet, in like an hour ima try it out

grand fern
#

no sadly it didn't work 🙁

sand junco
#

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
    }
)})
grand fern
#

Will try this shortly

grand fern
#

Holy mother of fuck it works

grand fern
#

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
    }

    )})
grand fern
#

Bump

sand junco
#

.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
    }

    )})```
grand fern
#

I get an error

sand junco
#

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.

mystic hare
#

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

grand fern
#

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
    }

    )})
mystic hare
#

100% chance for what?

grand fern
#

the worms come in at a 100% instead of 40%

#

"kubejs:worm"

#

to be specific

mystic hare
#

I wonder whether the return value of finishUsing is memoized.

#

It doesn't seem to be

mystic hare
#

You could also debug the value of rng

#

Like, do level.server.tell(rng)

grand fern
#

below var sifting_recipe = 2 //28?

mystic hare