Created
August 25, 2016 00:01
-
-
Save Waterpicker/57d87a780bc2c9a94145e7e48d8b1f8e 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.filter(e -> !e.getTileEntity().filter(tile -> tile.equals(TileEntityTypes.CHEST)).isPresent()).forEach(chest -> { | |
Extent extent = chest.getOriginal().getLocation().get().getExtent(); | |
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); | |
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