#Block that explodes when you mine it
119 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
hmm
I noticed the "adding new blocks" section in the documentation is marked legacy? what does this mean in this context
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
are the rest of the blocks needed? (the charred varients)
oh wait
you say at the top that the rest are optional
sorry!
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
does hardness determine the tool level required, the speed of mining, or both?
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
StartupEvents.registry('block', event => { event.create('reactive_brick').displayName('Reactive Brick') .material('stone') .hardness(2.0) .tagBlock('minecraft:mineable/pickaxe') .requiresTool(true) })
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
that looks good, also since its a startup script changes wont take place unless you restart the full game
if you want the player to not be damaged by the explosion then you can uncomment ```js
explosion.exploder(event.player)
will they still be pushed back?
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
i would asume not
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
can i customize the damage indipentantly of blast strength?
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?
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
its no biggie, i'll have it just be a regualar explosion
OH OK so strength is what determines the explosion radius where it breaks blocks
i know this much
good luck my man
ok
lemme know if theres anything else i can help out with
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
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?
thats fine, also im not quite sure how to texture a multi faced block though i can look through to see if theres an example for you
@nimble monolith heres someone who asked a similar question #1126797179898560542 message
[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
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
nice
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
nope
youll need to use a model file
one sec
take a look at this
thats the model file for chiseled sandstone
youll need to make one similiar to that
create kubejs\assets\kubejs\models\block\reactive_brick.json
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
almost
try "end" instead of "top" in the 6th line
what should we use?
actually revert the top to end change, then just change cube_column to cube_bottom_top
done
try now
very nice
ok i really want some way to modfiy the explosion damage
it has a very wide radius but barely does any damage
can i apply explosion type damage to the breaker of the block?
yes you should be able to
how should i go about doing that?
hmmm.. im not seing any method to damage a player
oh wait i have an idea
oh wait there is
attack(source, hp damage)
in your block breaking event
event.player.attack("idontknowtheidforexplosion",386427634)
add that somewhere
of course replace the id and damage with what you want it to be
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?
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)
}
})
The Interactive Video Game Wiki. Find collectibles, items, bosses, achievements and more.
oh nvm i came late to the party it seems
also ignore my link, its wrong for this now that i think about it