I have an event in my plugin that is fired up when a block is placed into the world. In that event I check if the block has a Key in it’s properties, by doing this
public void onBlockPlaced(ChangeBlockEvent.Place event) {
if (!event.getTransactions().isEmpty()) {
BlockSnapshot block = event.getTransactions().get(0).getFinal();
if(block.get(Keys.EXTENDED).isPresent()) {
//do stuff
}
}
}
However, when I do a /setblock
command for a DynamicTreesBOP block I get an error. Specifically I’m trying to place a dynamictreesbop:leaves_flowering
via setblock
command (I can’t /give
that block to manually place it). When the block is placed the event fires up and than this error is shown in the console
java.lang.IllegalArgumentException:
Cannot get property
PropertyBool{name=decayable,
clazz=class java.lang.Boolean,
values=[true, false]} as it does not
exist in
BlockStateContainer{block=dynamictre
sbop:leaves_flowering,
properties=[can_flower, fast_leaves,
flowering, hydro, tree]}
net.minecraft.block.state.BlockStateContainer$StateImplementation.func_177229_b(BlockStateContainer.java:201)
net.minecraft.block.BlockLeaves.impl$getIsDecayableFor(BlockLeaves.java:647)
net.minecraft.block.BlockLeaves.bridge$getManipulators(BlockLeaves.java:709)
net.minecraft.block.state.BlockStateContainer$StateImplementation.lazyLoadManipulatorsAndKeys(BlockStateContainer.java:726)
net.minecraft.block.state.BlockStateContainer$StateImplementation.getValues(BlockStateContainer.java:919)
org.spongepowered.common.block.SpongeBlockSnapshot.getKeyValueMap(SpongeBlockSnapshot.java:429)
org.spongepowered.common.block.SpongeBlockSnapshot.get(SpongeBlockSnapshot.java:420
So basically is saying that it can’t get the decayable
property from the block as is does not exist, which is true. However I’m not asking for that key anywhere, so why bother me that the key does not exist? Is there something wrong in how I get or try to read a key value from a block?