#I wanna restrict items in my server

165 messages · Page 1 of 1 (latest)

strong mauve
#

Help please I beg

plain plankBOT
#

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

leaden whale
#

we're gonna need a better explaination than that, what do you want to restrict? how do you plan on unlocking the restricted item?

strong mauve
#

I want to make these items uncraftable

#

and

#

its two items from

#

irons spellbooks mods

#

actually its a couple other items but at the bare minimum two

leaden whale
#

i see

#

ill tell you right now that theres a better way of restricting iron n spellbooks scrolls and books than prevent crafting(not sure if its even possible to restrict crafting of them) and that is with nbt

#

luckily i recently worked with someone on a script to do exactly this, sec

#

the real question is what is going to unlock them?

strong mauve
#

I was gonna restrict them like peramently because I wanna make them sorta dev items

#

since they kinda

leaden whale
#

ohhhh

strong mauve
#

unbalanace the combat

leaden whale
#

thats easy then, sec

#

what level and what element are they

strong mauve
#

uhhhhhhhhhhhhhhhhhhhhhhhhh... im not sure im all very new to kubejs

#

I know the exact items

leaden whale
#

go for it

#

it says the level and element on the scroll/book

#

unless they arent spells youre trying to lock?

strong mauve
#

Nah i w as tryna lock the arcane anvil from being crafted inscription table from being crafted and the scroll forge from being crafted

leaden whale
#

oh

#

well that changes things

strong mauve
#

is that harder?

leaden whale
#

i had thought it was some spell

#

nah it just changes what i need to do

strong mauve
#

ooooh

leaden whale
#

we'll remove the recipes with a recipe event

#

sec

strong mauve
#

yeah cuz tbh theres alto f spells that work and dont work and i was like if i just restrict people from being able to do anything besides randomly find them then it restricts them enough

#

so all of them are just one time use

leaden whale
blissful sonnetBOT
#

Paste version of removerecipe.js from @leaden whale

leaden whale
#

this is an example script where you can remove items by name

#

in the example it removes bonemeal recipe ids but you can delete those

#

youll want to follow the format though, this goes in kubejs>server_scripts folder

#

you would put the 'modid:itemname' in the output brackets

strong mauve
#

does it make them uncraftable or just like remove them entirely?

leaden whale
#

like so js [ 'minecraft:diamond', 'minecraft:gold_ingot' ].forEach((itemID) => event.remove({output: itemID}));

#

removes the recipe entirely

#

which is the same thing

strong mauve
#

bet but i can still get them thru creative or give right?

leaden whale
#

yep

strong mauve
#

okay so let me get the specifc item ids real fast and you tell me if im like

#

putting this in right

leaden whale
#

kk

strong mauve
#

thank you so far tho btw i was frustrated tryna solve this

leaden whale
#

np lol

#

if you get any errors then post your server scripts found in logs>kubejs>server_scripts

strong mauve
#

irons_spellbooks:arcane_anvil irons_spellbooks:inscription_table irons_spellbooks:scroll_forge

#

ok so

#

these are the item like scripts i have to add right?

leaden whale
#

oh god

#

??codeblock

blissful sonnetBOT
# leaden whale ??codeblock

You can write your code in a codeblock by typing it between the codeblock delimiters:

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

As an example, :arrow_up: will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
leaden whale
#
irons_spellbooks:arcane_anvil   irons_spellbooks:inscription_table  irons_spellbooks:scroll_forge```
#

wheres the rest of the script?

strong mauve
#

oh my bad i was just saying is this the format to list the items

#

[
'irons_spellbooks:arcane_anvil,
'irons_spellbooks:inscription_table
irons_spellbooks:scroll_forge'
].forEach((itemID) => event.remove({output: itemID})); so like this

leaden whale
#

close

#
[
'irons_spellbooks:arcane_anvil',
'irons_spellbooks:inscription_table',
'irons_spellbooks:scroll_forge'
    ].forEach((itemID) => event.remove({output: itemID})); ```
#

they need '' around them

#

as well as a comma after the '

strong mauve
#

so thats it?

leaden whale
#

well you need the other part of the script but yeah

#

so itd be like ```js
ServerEvents.recipes(event => {
//Remove by recipe ID
[

].forEach((recipeID) => event.remove({id: recipeID}));

//Remove all recipes an item is related to. For example putting 'minecraft:bonemeal' here would remove the recipe for bone blocks as well.
[

].forEach((ingredientID) => event.remove({input: ingredientID}));

//Remove by item ID
[

'irons_spellbooks:arcane_anvil',
'irons_spellbooks:inscription_table',
'irons_spellbooks:scroll_forge'
].forEach((itemID) => event.remove({output: itemID}));

})```

strong mauve
#

ServerEvents.recipes(event => {
//Remove by recipe ID
[
'minecraft:bone_meal',
'ars_nouveau:horn_to_bonemeal'

].forEach((recipeID) => event.remove({id: recipeID}));

//Remove all recipes an item is related to. For example putting 'minecraft:bonemeal' here would remove the recipe for bone blocks as well.
[

].forEach((ingredientID) => event.remove({input: ingredientID}));

//Remove by item ID
[

'irons_spellbooks:arcane_anvil',
'irons_spellbooks:inscription_table',
'irons_spellbooks:scroll_forge'
].forEach((itemID) => event.remove({output: itemID}));

}) so this in a scrit would restrict the items?

#

script*

leaden whale
#

and that would be a .js file in the kubejs>server_scripts folder

#

do something for me

#

type this
111js
code111

#

111js
code111

#

just once is fine

strong mauve
#

111js
code111

leaden whale
#

ok now replace the 1s with `

strong mauve
#

111 code111 111
code111

leaden whale
#

close

#

just once is fine

#

like '''js
code''' but with ` instead of '

#

dont type the 1s

#

replace them

#

like type 3 `

strong mauve
#

3 `

leaden whale
#

no no

strong mauve
#

3`

leaden whale
#

3 of `

strong mauve
#

Oh like this

leaden whale
#

yes

#

but put js in front of it

#

and press enter after js

strong mauve
#

```js Code````

#

`hold on i saw it

leaden whale
#

close

strong mauve
#

js wa js

leaden whale
#

like js test

#

now replace that with this ```js
ServerEvents.recipes(event => {
//Remove by recipe ID
[
'minecraft:bone_meal',
'ars_nouveau:horn_to_bonemeal'

].forEach((recipeID) => event.remove({id: recipeID}));

//Remove all recipes an item is related to. For example putting 'minecraft:bonemeal' here would remove the recipe for bone blocks as well.
[

].forEach((ingredientID) => event.remove({input: ingredientID}));

//Remove by item ID
[

'irons_spellbooks:arcane_anvil',
'irons_spellbooks:inscription_table',
'irons_spellbooks:scroll_forge'
].forEach((itemID) => event.remove({output: itemID}));

})```

strong mauve
#
    //Remove by recipe ID
    [
      'minecraft:bone_meal',
      'ars_nouveau:horn_to_bonemeal'

    ].forEach((recipeID) => event.remove({id: recipeID}));

    //Remove all recipes an item is related to. For example putting 'minecraft:bonemeal' here would remove the recipe for bone blocks as well.
    [

    ].forEach((ingredientID) => event.remove({input: ingredientID}));

    //Remove by item ID
    [
'irons_spellbooks:arcane_anvil',
'irons_spellbooks:inscription_table',
'irons_spellbooks:scroll_forge'
    ].forEach((itemID) => event.remove({output: itemID})); 

})```
leaden whale
#

close

#

you wanna press enter after the js

#

mb if i said before js

strong mauve
#

ooooooh

leaden whale
#

like '''js
test'''

#

ye

#

??codeblock

blissful sonnetBOT
# leaden whale ??codeblock

You can write your code in a codeblock by typing it between the codeblock delimiters:

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

As an example, :arrow_up: will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
strong mauve
#
ServerEvents.recipes(event => {
    //Remove by recipe ID
    [
      'minecraft:bone_meal',
      'ars_nouveau:horn_to_bonemeal'

    ].forEach((recipeID) => event.remove({id: recipeID}));

    //Remove all recipes an item is related to. For example putting 'minecraft:bonemeal' here would remove the recipe for bone blocks as well.
    [

    ].forEach((ingredientID) => event.remove({input: ingredientID}));

    //Remove by item ID
    [
'irons_spellbooks:arcane_anvil',
'irons_spellbooks:inscription_table',
'irons_spellbooks:scroll_forge'
    ].forEach((itemID) => event.remove({output: itemID})); 

})```
leaden whale
#

my man is enlightened

strong mauve
#

LOL i was like hold onl...

leaden whale
#

its just a lot easier to read for future tickets XD

#

well anyways lemme know if that script works

strong mauve
#

i got u

#

so this works?

#

like

#

as a script*

leaden whale
#

??tryitandsee

blissful sonnetBOT
leaden whale
#

yeah just stick it in the kubejs>server_scripts folder

strong mauve
#

LOL my bad so should I put it in a notepad?

leaden whale
#

as a .js file

strong mauve
#

got u

leaden whale
#

yup

strong mauve
#

thanks so much man

leaden whale
#

i recommend downloading visual studio code, it makes code look like the '''js and its super helpful

#

np man gl with your pack

strong mauve
blissful sonnetBOT
#

Paste version of Restrict.js from @strong mauve

strong mauve
#

it didnt work

#

oh wait

#

BRUH

#

ididnt save it

#

i just solved my own issue

#

and thanks i did

leaden whale
#

haha good

#

dont forget to /reload

strong mauve
#

whats that do? it seems to be

#

overritign what i do

leaden whale
#

wym

#

doing /reload?

#

/reload reloads the game files, its needed if you ever edit recipe events in-game

#

for changes to take effect anyways

#

pretty much just reloads kubejs scripts

strong mauve
#

should i put it in the server

#

or startup

#

file

leaden whale
#

server script

#
console.info('Hello, World! (Loaded server scripts)```
#

if youre ever curious which events go where theres a list of all events on the wiki page

#

??kjswiki

blissful sonnetBOT
# leaden whale ??kjswiki

You can add, remove, and modify recipes with KubeJS. The wiki has a page on that!
If you want to learn how to add recipes to any mod, click the Custom button.

leaden whale
#

wait wrong one

#

full list of all the events and it tells you which script folder to put them in

strong mauve
#

works perfect.

#

I might be back later to keep learning scripting thanks so much man made my day

leaden whale
#

nice

#

dont forget to close ticket

#

??closeticket

blissful sonnetBOT
# leaden whale ??closeticket

Please close your ticket (with /ticket close or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.

strong mauve
#

??closeticket

blissful sonnetBOT
# strong mauve ??closeticket

Please close your ticket (with /ticket close or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.