#Block that explodes when you mine it

119 messages · Page 1 of 1 (latest)

nimble monolith
#

Hi, I've seen some things that cube that kubeJS can do and I want to make some stuff for my minecraft server. How easy would a block that explodes when mined be to make? Where should i start? Any good tutorials?

light tapirBOT
#

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

uncut magnet
#

hmm

nimble monolith
#

I noticed the "adding new blocks" section in the documentation is marked legacy? what does this mean in this context

uncut magnet
#

workin on it

#

heres an example on creating the block with kubejs, this goes in you startup scripts, i also put in other examples just to show what else you could do with it ```js
StartupEvents.registry('block', event => {
// Register new items here
event.create('exploding_block').displayName('Exploding Block')
.material('dirt')
.hardness(0.8)
.tagBlock('minecraft:mineable/shovel') // Make it mine faster using a shovel in 1.18.2+
.requiresTool(false) // Make it require a tool to drop ay loot

event.create('charred_dirt').displayName('Charred Dirt')
.material('dirt')
   .hardness(0.8)
   .tagBlock('minecraft:mineable/shovel') // Make it mine faster using a shovel in 1.18.2+
     .requiresTool(false) // Make it require a tool to drop ay loot



event.create('charred_stone').displayName('Charred Stone')
.material('stone')
   .hardness(1)
   .tagBlock('minecraft:mineable/pickaxe') // Make it mine faster using a shovel in 1.18.2+
     .requiresTool(true) // Make it require a tool to drop ay loot



event.create('charred_earth').displayName('Charred Earth')
.material('dirt')
   .hardness(0.7)
   .tagBlock('minecraft:mineable/shovel') // Make it mine faster using a shovel in 1.18.2+
     .requiresTool(false) // Make it require a tool to drop ay loot

})```

#

as for exploding it on impact you can specify it and run an event when its broken

nimble monolith
#

are the rest of the blocks needed? (the charred varients)

#

oh wait

#

you say at the top that the rest are optional

#

sorry!

uncut magnet
#

nah those are just there as examples

#

you can delete those if you want or comment them out if you wanna save the reference

#

you can change the display name to whatever you want, you need the name of the event.create('name') to be the same as the one in your resource pack youll make, kubejs supports resource packs which youll find in the kubejs folder>assets

nimble monolith
#

does hardness determine the tool level required, the speed of mining, or both?

uncut magnet
#

i dont believe so

#

i think thats just how long it takes to mine

#

er hmm one sec ill have to reference that actually cause now im not sure

nimble monolith
#

StartupEvents.registry('block', event => { event.create('reactive_brick').displayName('Reactive Brick') .material('stone') .hardness(2.0) .tagBlock('minecraft:mineable/pickaxe') .requiresTool(true) })

uncut magnet
#

then this is what you put into your server scripts folder

BlockEvents.broken(event => {
    if (event.block.getId().toString() == ('kubejs:exploding_block')) {
        let explosion = event.block.createExplosion()
explosion.strength(10)
//explosion.exploder(event.player)
explosion.damagesTerrain(false)
explosion.explode()
    }
})```
#

you can specify how big you want the explosion to be

uncut magnet
#

if you want the player to not be damaged by the explosion then you can uncomment ```js
explosion.exploder(event.player)

nimble monolith
#

will they still be pushed back?

uncut magnet
#

hmm i think it works like a normal explosion, id have to mess around with it

#

also to determine which pickaxe to use you have to use the block tag to set it

uncut magnet
#

it does push you back but its weak cause 10 strength is apparently weak

#

lemme ramp it up a bit

#

youd have to mess around with it

nimble monolith
#

can i customize the damage indipentantly of blast strength?

uncut magnet
#

oh hmm maybe it doesnt cause knockback actually

#

i believe so

nimble monolith
#

maybe you could you use explosion.exploder(event.player) to make it not do damage, and then apply the damage manually?

#

to things that get hit by the blast?

uncut magnet
#

you could definately do that

#

also i put the strength to 200 and its still doing the same amount of damage so lemme figure it out

nimble monolith
#

its no biggie, i'll have it just be a regualar explosion

uncut magnet
#

OH OK so strength is what determines the explosion radius where it breaks blocks

nimble monolith
#

i know this much

uncut magnet
#

good luck my man

nimble monolith
#

ok

uncut magnet
#

lemme know if theres anything else i can help out with

nimble monolith
#

also what about textures?

#

i have them, how do i make them work?

uncut magnet
#

ok so the assets folder in the kubejs folder is the same as any other texture pack

#

youd create a kubejs folder (since the custom items namespace is kubejs (kubejs:reactive_block)) inside of the assets folder and put your files there the same you would any other texturepack

#

like assets>kubejs>textures

#

if youre curious on the folder structure then just look in any other texture pack to see what they did and just mimic them

nimble monolith
#

seems like it already generates one

#

how should the texture be saved? like whats the UV wrapping like

#

like this?

#

@uncut magnet

#

are you ok with me pinging you to ask for help?

uncut magnet
next magnetBOT
#

[Quote ➤](#1126797179898560542 message) you can add states, but its a little bit of a pain since you have to then also add placements for those states

nimble monolith
#

thats for direction blocks

#

anyway i figured this much out

#

i see i have to have multible textures for sides

#

also the explosion part works

uncut magnet
#

nice

nimble monolith
#

any idea about the names for the sides though?

#

right now i have reactive_brick.png

#

what would i name the sides so it automatical knows what sides which?

#

they name them like this in minecraft so i'll try this

green lynx
#

youll need to use a model file

#

one sec

#

thats the model file for chiseled sandstone

#

youll need to make one similiar to that

#

create kubejs\assets\kubejs\models\block\reactive_brick.json

nimble monolith
#

i see

green lynx
#

then in it put:

{
  "parent": "minecraft:block/cube_column",
  "textures": {
    "bottom": "kubejs:block/reactive_brick_bottom",
    "side": "kubejs:block/reactive_brick_side",
    "top": "kubejs:block/reactive_brick_top"
  }
}
#

i think that should work then

#

as usual use F3+T to reload

nimble monolith
green lynx
#

try "end" instead of "top" in the 6th line

nimble monolith
#

was about to say that

#

what about bottom?

green lynx
#

let me check

#

ah i see the problem

#

cube_column has same texture for top and bottom

nimble monolith
#

what should we use?

green lynx
#

actually revert the top to end change, then just change cube_column to cube_bottom_top

nimble monolith
#

done

green lynx
#

try now

nimble monolith
#

lets see if it worked

#

thats more like it

green lynx
#

very nice

nimble monolith
#

ok i really want some way to modfiy the explosion damage

#

it has a very wide radius but barely does any damage

green lynx
#

im pretty sure thats not possible

#

hm

nimble monolith
#

can i apply explosion type damage to the breaker of the block?

green lynx
#

yes you should be able to

nimble monolith
#

how should i go about doing that?

green lynx
#

hmmm.. im not seing any method to damage a player

#

oh wait i have an idea

#

oh wait there is

#

attack(source, hp damage)

green lynx
#

event.player.attack("idontknowtheidforexplosion",386427634)

#

add that somewhere

#

of course replace the id and damage with what you want it to be

nimble monolith
#

like this? BlockEvents.broken(event => { if (event.block.getId().toString() == ('kubejs:reactive_brick')) { let explosion = event.block.createExplosion() explosion.strength(6) explosion.damagesTerrain(false) explosion.explode() attack(INSERT_TNT_ID, 7.5) } })

#

i think the ID is explosion

#

do you know how i apply this attack to the player?

#

@green lynx?

green lynx
#

like this:

BlockEvents.broken(event => {
    if (event.block.getId().toString() == ('kubejs:reactive_brick')) {
        let explosion = event.block.createExplosion()
explosion.strength(6)
explosion.damagesTerrain(false)
explosion.explode()
event.player.attack('explosion.player', 7.5)
    }
})
uncut magnet
#

oh nvm i came late to the party it seems

#

also ignore my link, its wrong for this now that i think about it

nimble monolith