Created
August 27, 2016 08:58
-
-
Save Waterpicker/00f081dd96f1155a64201e5252e31e75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Listener | |
public void onChestBreak(ChangeBlockEvent.Break event) { | |
event.getTransactions().stream().filter(e -> e.getOriginal().getState().getType().equals(BlockTypes.CHEST)).forEach(chest -> { | |
Entity item = event.getTargetWorld().createEntity(EntityTypes.ITEM, chest.getOriginal().getPosition()).get(); | |
ItemStackSnapshot itemStack = ItemStack.builder().fromBlockSnapshot(chest.getOriginal()).build().createSnapshot(); | |
item.offer(Keys.REPRESENTED_ITEM, itemStack); | |
event.getTargetWorld().spawnEntity(item, Cause.source(EntitySpawnCause.builder().entity(item).type(SpawnTypes.PLUGIN).build()).build()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment