#Codec help

1 messages · Page 1 of 1 (latest)

waxen garnet
#

how would I create the codecs for IntProperty and the int array here java public FlowerCrop(Settings settings, IntProperty ageProperty, LightRequirement lightRequirement, int... ageIndices)??

halcyon maple
#

Codec.INT and Codec.INT.listOf()

waxen garnet
little orbit
#

Why would you want a codec that encodes an IntProperty?
Do you actually want a codec for a BlockState that encodes the value of an IntProperty?

waxen garnet
#

and I need the codec to match the constructor

little orbit
#

What's the codec for?
Codecs shouldn't create new block instances

waxen garnet
#

idek what a codec does

#

its just required

little orbit
#

Does it need to be a Codec<FlowerBlock>? (or MapCodec<FlowerBlock> or smth, I forget)?

waxen garnet
#

MapCodec

little orbit
#

huh it looks like vanilla does use constructors, weird
but also it's strange for your block class to take an IntProperty in the constructor
does you have flowers with different age ranges?

little orbit
# waxen garnet yeah

I'd make FlowerCrop abstract and create a subclass for each age range
and what are ageIndices for?

waxen garnet
#

its also used by my datagen for which model to use at which age within the blockstate

little orbit
#

ok so you can do basically the same thing with subclasses
I assume one age range always uses the same indices? (so you won't have tons of combinations)