#How to make it so a custom block is able to face towards the player on placement?

54 messages · Page 1 of 1 (latest)

stray aurora
#

Currently making a block but I want it to face the player when placed, as it is a decoration block. I've tried playing with blockProperties but I keep getting errors. How can I fix my issue?

mild vectorBOT
#

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

hardy streamBOT
#

Paste version of startup.log from @stray aurora

placid shore
#

version 1.20.1?

stray aurora
#

Yeah

placid shore
#

could i see a copy of the file?

stray aurora
#
    event.create("warden_trophy")
    .displayName("Warden Trophy")
    .material("wood")
    .hardness(2)
    .resistance(3)
    .tagBlock('minecraft:mineable/axe')
    .noCollision()
    .notSolid()
    .renderType('cutout')
    .property(BlockProperty.facing)
  })
placid shore
hardy streamBOT
#

Paste version of Test.js from @placid shore

placid shore
#

if that doesn't work, i'll look for a workaround but you'd probably have to set it up as a condition like holding shift

#

might need this as well

// Assuming BlockEvents is a valid object
BlockEvents.placed('warden_trophy', event => {
const player = event.player;
if (player) {
const playerFacing = player.getHorizontalFacing();
event.blockState = event.blockState.with('facing', playerFacing);
}
});

stray aurora
hardy streamBOT
#

Paste version of startup.log from @stray aurora

placid shore
#

// Assuming StartupEvents is a valid object
StartupEvents.registry('block', event => {
event.create('warden_trophy')
.displayName('Warden Trophy')
.soundType(SoundType.WOOD) // Replace SoundType.WOOD with the appropriate sound type
.mapColor(MapColor.WOOD_BROWN) // Replace MapColor.WOOD_BROWN with the appropriate map color
.hardness(2)
.resistance(3)
.tagBlock('minecraft:mineable/axe')
.noCollision()
.notSolid()
.renderType('cutout')
.property('facing') // Make the block face the player
});

#

this might work

stray aurora
#

This did not work

hardy streamBOT
#

Paste version of startup.log from @stray aurora

placid shore
#

this seems to be the problem "dev.latvian.mods.kubejs.block.BlockBuilder.property(string)."

stray aurora
#

but what can I do to solve it

placid shore
#

are you on version 6.4 of kube?

stray aurora
#

Yeah

#

I'm heading off to bed tho

#

Feel free to post anymore possible solutions and I'll check in the morning

placid shore
#

alright

static pilot
#

event.create('my_block', 'cardinal')

wise urchin
static pilot
#

it does blockstate, jsons, models and placment facing

#

it just doesnt exist in 1.18, which is why theres also the manual blockstate thing exists and is used for this

wise urchin
#

Ooh, cool. Does it do horizontal facing in the 4 horizontal directions or normal facing in all six directions?

hardy streamBOT
#
cardinal
1. noun

One of the officials appointed by the pope in the Roman Catholic Church, ranking only below the pope and the patriarchs, constituting the special college which elects the pope. (See Wikipedia article on Catholic cardinals.)

2. noun

Any of a genus of songbirds of the finch family, Cardinalis.

3. noun

Any of various related passerine birds of the family Cardinalidae (See Wikipedia article on cardinals) and other similar birds that were once considered to be related.

4. noun

(color) A deep red color, somewhat less vivid than scarlet, the traditional colour of a Catholic cardinal's cassock. (same as cardinal red)

5. noun

Short for cardinal number, a number indicating quantity, or the size of a set (e.g., zero, one, two, three). (See Wikipedia article on Cardinal number.)

6. noun

(grammar) Short for cardinal numeral, a word used to represent a cardinal number.

7. noun

Short for cardinal flower (Lobelia cardinalis), a flowering plant.

8. noun

Short for cardinal tetra (Paracheirodon axelrodi), a freshwater fish.

9. noun

(bow) A woman's short cloak with a hood, originally made of scarlet cloth.

10. noun

Mulled red wine.

11. adjective

Of fundamental importance; crucial, pivotal.

"A cardinal rule"

12. adjective

Of or relating to the cardinal directions (north, south, east and west).

"A cardinal mark"

13. adjective

Describing a "natural" number used to indicate quantity (e.g., zero, one, two, three), as opposed to an ordinal number indicating relative position.

14. adjective

Having a bright red color (from the color of a Catholic cardinal's cassock).

static pilot
#

wow.. it has a lot of definitions

#

number 12 is what i was looking for

wise urchin
#

Ok, so the four horizontal directions, funny enough If you Look at Definition 5 IT seems Like it's all six

static pilot
#

i had a very hard time naming it

#

vanilla calls them horizontal directional

#

which is a bit of a mourhful

#

but just facing or directional doesnt work cause theres 6 directions

#

(also i tried making a variant that does all 6 directions but doing shape rotation for that is basically impossible)

wise urchin
#

Yeah can Imagine that

#

So this should be the Code then

StartupEvents.registry('block', event => {
    event.create('warden_trophy', 'cardinal')
        .woodSoundType()
        .mapColor("wood")
        .hardness(2)
        .resistance(3)
        .tagBlock('minecraft:mineable/axe')
        .noCollision()
        .notSolid()
        .renderType('cutout')
})

Or something Like that

#

And you can remove your blockstates If you had one

static pilot
#

display name is unneeded, thats the default one for that id

wise urchin
#

Yup, that's true

#

Removed it

stray aurora
#

I got it to work

#

Thanks guys ^^

static pilot
#

fancy

stray aurora
#

Yeahh

mild vectorBOT
#

Ticket re-opened!

stray aurora
stray aurora
#

@wise urchin