Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Zerthick/19058a7f264024698f456bbb69535d73 to your computer and use it in GitHub Desktop.
Save Zerthick/19058a7f264024698f456bbb69535d73 to your computer and use it in GitHub Desktop.
@Listener(order = Order.LATE)
@IsCancelled(value = Tristate.FALSE)
public void onBlockPlace(ChangeBlockEvent.Place event, @Getter("getCause") Cause cause) {
// Growing blocks with bonemeal
cause.getContext().get(EventContextKeys.USED_ITEM).ifPresent(itemStackSnapshot -> {
if (itemStackSnapshot.getType().equals(ItemTypes.DYE)) {
itemStackSnapshot.get(Keys.DYE_COLOR).ifPresent(dyeColor -> {
if (dyeColor.equals(DyeColors.WHITE)) {
event.getTransactions().forEach(trans -> trans.getFinal().getLocation()
.ifPresent(loc -> loc.getExtent().setCreator(loc.getBlockPosition(), null)));
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment