Created
August 27, 2016 07:59
-
-
Save Waterpicker/82207c9e1c24194658558f3ddcda8d95 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.getFinal().getState().getType().equals(BlockTypes.CHEST)).map(i-> i.getFinal().withContainer(i.toContainer())).forEach(chest -> { | |
Extent extent = chest.getLocation().get().getExtent(); | |
Entity item = event.getTargetWorld().createEntity(EntityTypes.ITEM, chest.getPosition()).get(); | |
ItemStackSnapshot itemStack = ItemStack.builder().fromBlockSnapshot(chest).build().createSnapshot(); | |
item.offer(Keys.REPRESENTED_ITEM, itemStack); | |
extent.spawnEntity(item, Cause.source(EntitySpawnCause.builder().entity(item).type(SpawnTypes.DROPPED_ITEM).build()).build()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment