Skip to content

Instantly share code, notes, and snippets.

@ArtemBelz
Created January 13, 2019 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtemBelz/b75a8599d9018faa0c2ed94acfe6cd8f to your computer and use it in GitHub Desktop.
Save ArtemBelz/b75a8599d9018faa0c2ed94acfe6cd8f to your computer and use it in GitHub Desktop.
private UUID contentDetermineUUID = UUID.fromString("f680df9b-ac5c-4d3f-9bac-75bc0e316afa");
private String vacuumWolrd = AirshipModule.getInstance().getManager().getBase().getOptions().getVacuumWorld();
@Listener
public void onInteract(InteractBlockEvent.Secondary event) {
Player player = event.getCause().first(Player.class).get();
World world = Sponge.getGame().getServer().getWorld(vacuumWolrd).get();
BlockSnapshot targetBlock = event.getTargetBlock();
Vector3i pos = targetBlock.getPosition();
Location<World> loc = new Location<>(world, pos);
if(player.getItemInHand(HandTypes.MAIN_HAND).get().getType().equals(ItemTypes.APPLE)) {
player.sendMessage(Text.of(targetBlock.getCreator().get()));
BlockSnapshot blockSnapshot = BlockSnapshot.builder().from(loc)
.creator(contentDetermineUUID)
.build();
loc.restoreSnapshot(blockSnapshot, true, BlockChangeFlags.ALL);
player.sendMessage(Text.of(blockSnapshot.getCreator().get()));
} else if(player.getItemInHand(HandTypes.MAIN_HAND).get().getType().equals(ItemTypes.BONE)) {
player.sendMessage(Text.of(targetBlock.getCreator().get()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment