Permalink
Browse files

Update for cause refactor.

  • Loading branch information...
me4502 committed Sep 10, 2017
1 parent 6469dca commit ce31c038eabacfb397eb30506bc6a148edf93fc8
Showing with 135 additions and 196 deletions.
  1. +1 −6 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/CraftBookPlugin.java
  2. +4 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/Ammeter.java
  3. +1 −2 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/BetterPhysics.java
  4. +4 −6 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/BetterPlants.java
  5. +3 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/Bookshelf.java
  6. +3 −6 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/Chairs.java
  7. +1 −2 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/CommandSigns.java
  8. +6 −8 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/CookingPot.java
  9. +2 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/Elevator.java
  10. +10 −15 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/HeadDrops.java
  11. +7 −7 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/HiddenSwitch.java
  12. +3 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/LightStone.java
  13. +5 −6 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/LightSwitch.java
  14. +5 −7 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/Snow.java
  15. +2 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/Teleporter.java
  16. +4 −10 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/XPStorer.java
  17. +7 −10 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/area/Bridge.java
  18. +7 −10 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/area/Door.java
  19. +6 −9 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/area/Gate.java
  20. +4 −6 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/area/SimpleArea.java
  21. +3 −5 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/area/complex/ComplexArea.java
  22. +3 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/blockbags/EmbeddedBlockBag.java
  23. +1 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/boat/ExitRemover.java
  24. +1 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/ics/ICSocket.java
  25. +8 −8 ...ponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/ics/chips/world/block/BlockReplacer.java
  26. +2 −3 .../sk89q/craftbook/sponge/mechanics/ics/chips/world/miscellaneous/ProgrammableFireworksDisplay.java
  27. +1 −2 ...ge/src/main/java/com/sk89q/craftbook/sponge/mechanics/ics/chips/world/miscellaneous/ZeusBolt.java
  28. +4 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/ics/pinsets/PinSet.java
  29. +1 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/minecart/ExitRemover.java
  30. +2 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/minecart/MobBlocker.java
  31. +1 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/pipe/Pipes.java
  32. +1 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/powerable/GlowStone.java
  33. +1 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/powerable/JackOLantern.java
  34. +1 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/powerable/Netherrack.java
  35. +4 −2 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/signcopier/SignCopier.java
  36. +3 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/treelopper/TreeLopper.java
  37. +2 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/mechanics/types/SpongeSignMechanic.java
  38. +0 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/st/SpongeSelfTriggerManager.java
  39. +1 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/util/ItemUtil.java
  40. +0 −3 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/util/LocationUtil.java
  41. +2 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/util/Metrics.java
  42. +4 −4 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/util/data/CraftBookData.java
  43. +1 −1 ...ge/src/main/java/com/sk89q/craftbook/sponge/util/data/builder/BlockBagDataManipulatorBuilder.java
  44. +1 −1 ...ponge/src/main/java/com/sk89q/craftbook/sponge/util/data/builder/EmbeddedBlockBagDataBuilder.java
  45. +1 −1 craftbook-sponge/src/main/java/com/sk89q/craftbook/sponge/util/data/mutable/BlockBagData.java
  46. +1 −1 ...tbook-sponge/src/main/java/com/sk89q/craftbook/sponge/util/data/mutable/EmbeddedBlockBagData.java
@@ -47,7 +47,6 @@
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.config.DefaultConfig;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.game.GameReloadEvent;
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
@@ -148,7 +147,7 @@ public void onPreInitialization(GamePreInitializationEvent event) {
}
@Listener
public void onInitialization(GameStartedServerEvent event) throws IllegalAccessException {
public void onInitialization(GameStartedServerEvent event) {
if(config.dataOnlyMode.getValue()) {
logger.info("Halting CraftBook Initialization - Data Only Mode! Note: Nothing will work.");
return;
@@ -354,10 +353,6 @@ private void disableMechanics() {
moduleController.disableModules();
}
public Cause.Builder getCause() {
return Cause.source(this.container);
}
@Override
public Optional<SelfTriggerManager> getSelfTriggerManager() {
return Optional.ofNullable(this.selfTriggerManager);
@@ -35,8 +35,7 @@
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.filter.cause.Named;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.service.permission.PermissionDescription;
@@ -67,13 +66,14 @@ public void onInitialize() throws CraftBookException {
}
@Listener
public void onPlayerInteract(InteractBlockEvent.Secondary event, @Named(NamedCause.SOURCE) Player player) {
public void onPlayerInteract(InteractBlockEvent.Secondary event, @First Player player) {
event.getTargetBlock().getLocation().ifPresent((location) -> {
int powerLevel = BlockUtil.getDirectBlockPowerLevel(location).orElse(-1);
HandType hand = event instanceof InteractBlockEvent.Secondary.MainHand ? HandTypes.MAIN_HAND : HandTypes.OFF_HAND;
if (powerLevel >= 0 && permissionNode.hasPermission(player) && player.getItemInHand(hand).isPresent() && player.getItemInHand(hand).get().getItem() == ammeterItem.getValue().getItem()) {
if (powerLevel >= 0 && permissionNode.hasPermission(player) && player.getItemInHand(hand).isPresent()
&& player.getItemInHand(hand).get().getType() == ammeterItem.getValue().getType()) {
player.sendMessage(getCurrentLine(powerLevel));
event.setCancelled(true);
}
@@ -35,7 +35,6 @@
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.util.Direction;
import org.spongepowered.api.world.LocatableBlock;
@@ -131,7 +130,7 @@ public void run () {
FallingBlock fallingBlock = (FallingBlock) ladder.getExtent().createEntity(EntityTypes.FALLING_BLOCK, ladder.getPosition().add(0.5, 0, 0.5));
fallingBlock.offer(Keys.FALLING_BLOCK_STATE, ladder.getBlock());
fallingBlock.offer(Keys.CAN_PLACE_AS_BLOCK, true);
ladder.getExtent().spawnEntity(fallingBlock, Cause.source(CraftBookPlugin.spongeInst().getContainer()).build());
ladder.getExtent().spawnEntity(fallingBlock);
physics.checkForPhysics(ladder.getRelative(Direction.UP));
}
@@ -40,7 +40,6 @@
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.block.TickBlockEvent;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
@@ -74,8 +73,8 @@ public void onInitialize() throws CraftBookException {
public void onTick(TickBlockEvent.Random event) {
event.getTargetBlock().getLocation().ifPresent(worldLocation -> {
if (isValidFernFarming(worldLocation) && ThreadLocalRandom.current().nextInt(10) == 0) {
worldLocation.setBlock(BlockState.builder().blockType(BlockTypes.DOUBLE_PLANT).add(Keys.DOUBLE_PLANT_TYPE, DoublePlantTypes.FERN).add(Keys.PORTION_TYPE, PortionTypes.BOTTOM).build(), Cause.source(CraftBookPlugin.spongeInst().getContainer()).build());
worldLocation.getRelative(Direction.UP).setBlock(BlockState.builder().blockType(BlockTypes.DOUBLE_PLANT).add(Keys.DOUBLE_PLANT_TYPE, DoublePlantTypes.FERN).add(Keys.PORTION_TYPE, PortionTypes.TOP).build(), Cause.source(CraftBookPlugin.spongeInst().getContainer()).build());
worldLocation.setBlock(BlockState.builder().blockType(BlockTypes.DOUBLE_PLANT).add(Keys.DOUBLE_PLANT_TYPE, DoublePlantTypes.FERN).add(Keys.PORTION_TYPE, PortionTypes.BOTTOM).build());
worldLocation.getRelative(Direction.UP).setBlock(BlockState.builder().blockType(BlockTypes.DOUBLE_PLANT).add(Keys.DOUBLE_PLANT_TYPE, DoublePlantTypes.FERN).add(Keys.PORTION_TYPE, PortionTypes.TOP).build());
}
});
}
@@ -89,12 +88,11 @@ public void onBlockBreak(ChangeBlockEvent.Break event, @First Player player) {
.filter(snapshot -> snapshot.getState().get(Keys.PORTION_TYPE).orElse(PortionTypes.BOTTOM).equals(PortionTypes.TOP))
.forEach(snapshot -> Sponge.getScheduler().createTaskBuilder().execute(task -> {
snapshot.getLocation().get().getRelative(Direction.DOWN)
.setBlock(BlockState.builder().blockType(BlockTypes.TALLGRASS).add(Keys.SHRUB_TYPE, ShrubTypes.FERN).build(),
CraftBookPlugin.spongeInst().getCause().build());
.setBlock(BlockState.builder().blockType(BlockTypes.TALLGRASS).add(Keys.SHRUB_TYPE, ShrubTypes.FERN).build());
if (player.get(Keys.GAME_MODE).orElse(GameModes.SURVIVAL) != GameModes.CREATIVE) {
Item item = (Item) snapshot.getLocation().get().getExtent().createEntity(EntityTypes.ITEM, snapshot.getPosition());
item.offer(Keys.REPRESENTED_ITEM, ItemStack.builder().itemType(ItemTypes.TALLGRASS).add(Keys.SHRUB_TYPE, ShrubTypes.FERN).build().createSnapshot());
snapshot.getLocation().get().spawnEntity(item, CraftBookPlugin.spongeInst().getCause().build());
snapshot.getLocation().get().spawnEntity(item);
}
}).submit(CraftBookPlugin.spongeInst().getContainer()));
}
@@ -36,8 +36,7 @@
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.filter.cause.Named;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.service.permission.PermissionDescription;
import org.spongepowered.api.text.Text;
@@ -97,14 +96,14 @@ public void onInitialize() throws CraftBookException {
}
@Listener
public void onPlayerInteract(InteractBlockEvent.Secondary.MainHand event, @Named(NamedCause.SOURCE) Player player) {
public void onPlayerInteract(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
event.getTargetBlock().getLocation().filter((this::isValid)).ifPresent(location -> {
if (!sneakState.getValue().doesPass(player.get(Keys.IS_SNEAKING).orElse(false) || !usePermissions.hasPermission(player))) {
return; //Don't alert the player with this mechanic.
}
if (!readWhenHoldingBlock.getValue()) {
ItemStack stack = player.getItemInHand(HandTypes.MAIN_HAND).filter((itemStack -> itemStack.getItem().getBlock().isPresent())).orElse(null);
ItemStack stack = player.getItemInHand(HandTypes.MAIN_HAND).filter((itemStack -> itemStack.getType().getBlock().isPresent())).orElse(null);
if (stack != null)
return;
}
@@ -18,7 +18,6 @@
import static com.sk89q.craftbook.sponge.util.locale.TranslationsManager.USE_PERMISSIONS;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.collect.Lists;
import com.google.common.reflect.TypeToken;
import com.google.inject.Inject;
@@ -47,10 +46,6 @@
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause;
import org.spongepowered.api.event.cause.entity.spawn.SpawnTypes;
import org.spongepowered.api.event.entity.RideEntityEvent;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.service.permission.PermissionDescription;
@@ -167,7 +162,9 @@ private void addChair(Player player, Location<World> location) {
entity.offer(Keys.INVISIBLE, true);
entity.offer(Keys.HAS_GRAVITY, false);
location.getExtent().spawnEntity(entity, Cause.of(NamedCause.of("root", SpawnCause.builder().type(SpawnTypes.CUSTOM).build()), NamedCause.source(player)));
Sponge.getCauseStackManager().pushCause(player);
location.getExtent().spawnEntity(entity);
Sponge.getCauseStackManager().popCause();
Chair<?> chair = new Chair<>((ArmorStand) entity, location, player.getLocation());
@@ -38,7 +38,6 @@
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.service.permission.PermissionDescription;
import org.spongepowered.api.util.Direction;
@@ -83,7 +82,7 @@ public void onBlockUpdate(NotifyNeighborBlockEvent event, @First LocatableBlock
Location<World> block = source.getLocation();
if (isValid(block)) {
Player player = event.getCause().get(NamedCause.SOURCE, Player.class).orElse(null);
Player player = event.getCause().first(Player.class).orElse(null);
boolean isPowered = BlockUtil.getBlockPowerLevel(block).orElse(0) > 0;
boolean wasPowered = block.get(CraftBookKeys.LAST_POWER).orElse(0) > 0;
@@ -43,9 +43,7 @@
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.event.filter.cause.Named;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Inventory;
@@ -107,21 +105,21 @@ public boolean verifyLines(Location<World> location, List<Text> lines, @Nullable
}
@Listener
public void onPlayerInteract(InteractBlockEvent.Secondary event, @Named(NamedCause.SOURCE) Player player) {
public void onPlayerInteract(InteractBlockEvent.Secondary event, @First Player player) {
event.getTargetBlock().getLocation().ifPresent(location -> {
if (isValid(location)) {
location.getTileEntity().map(sign -> (Sign) sign).ifPresent(sign -> {
ItemStack itemStack = player.getItemInHand(event.getHandType()).filter(stack -> FuelSource.canCookWith(stack.getItem())).orElse(null);
ItemStack itemStack = player.getItemInHand(event.getHandType()).filter(stack -> FuelSource.canCookWith(stack.getType())).orElse(null);
if (itemStack != null) {
if (refuelPermissions.hasPermission(player)) {
int value = FuelSource.getFuelValue(itemStack.getItem());
int value = FuelSource.getFuelValue(itemStack.getType());
increaseMultiplier(sign, value);
if (itemStack.getQuantity() > 1) {
itemStack.setQuantity(itemStack.getQuantity() - 1);
player.setItemInHand(event.getHandType(), itemStack);
} else {
if (itemStack.getItem() == ItemTypes.LAVA_BUCKET) {
if (itemStack.getType() == ItemTypes.LAVA_BUCKET) {
player.setItemInHand(event.getHandType(), ItemStack.of(ItemTypes.BUCKET, 1));
} else {
player.setItemInHand(event.getHandType(), null);
@@ -133,7 +131,7 @@ public void onPlayerInteract(InteractBlockEvent.Secondary event, @Named(NamedCau
} else {
Location<?> chestBlock = SignUtil.getBackBlock(location).add(0, 2, 0);
chestBlock.getTileEntity().filter(tileEntity -> tileEntity instanceof Chest).map(tileEntity -> (Chest) tileEntity).ifPresent(chest ->
player.openInventory(chest.getInventory(), CraftBookPlugin.spongeInst().getCause().build()));
player.openInventory(chest.getInventory()));
}
});
}
@@ -150,7 +148,7 @@ public void onBlockUpdate(NotifyNeighborBlockEvent event, @First LocatableBlock
Sign sign = (Sign) block.getTileEntity().get();
if (isMechanicSign(sign)) {
Player player = event.getCause().get(NamedCause.SOURCE, Player.class).orElse(null);
Player player = event.getCause().first(Player.class).orElse(null);
if(player != null) {
if(!refuelPermissions.hasPermission(player)) {
player.sendMessage(Text.of("You don't have permission to refuel this mechanic!"));
@@ -38,9 +38,8 @@
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.entity.MoveEntityEvent;
import org.spongepowered.api.event.filter.cause.Named;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.service.permission.PermissionDescription;
import org.spongepowered.api.service.permission.Subject;
import org.spongepowered.api.text.Text;
@@ -90,7 +89,7 @@ public SpongePermissionNode getCreatePermission() {
}
@Listener
public void onPlayerInteract(InteractBlockEvent.Secondary.MainHand event, @Named(NamedCause.SOURCE) Player player) {
public void onPlayerInteract(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
event.getTargetBlock().getLocation().ifPresent((location) -> {
Location<World> signLocation = location;
@@ -52,13 +52,9 @@
import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource;
import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause;
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause;
import org.spongepowered.api.event.cause.entity.spawn.SpawnTypes;
import org.spongepowered.api.event.filter.cause.First;
import org.spongepowered.api.event.filter.cause.Named;
import org.spongepowered.api.event.item.inventory.DropItemEvent;
import org.spongepowered.api.item.Enchantments;
import org.spongepowered.api.item.ItemTypes;
@@ -205,7 +201,7 @@ public void onInitialize() throws CraftBookException {
}
@Listener
public void onItemDrops(DropItemEvent.Destruct event, @First EntitySpawnCause spawnCause) {
public void onItemDrops(DropItemEvent.Destruct event, @First Entity spawnCause) {
EntityDamageSource damageSource = event.getCause().first(EntityDamageSource.class).orElse(null);
Entity killer = null;
@@ -235,20 +231,20 @@ public void onItemDrops(DropItemEvent.Destruct event, @First EntitySpawnCause sp
}
GameProfile profile = null;
if (spawnCause.getEntity() instanceof Player) {
profile = ((Player) spawnCause.getEntity()).getProfile();
if (spawnCause instanceof Player) {
profile = ((Player) spawnCause).getProfile();
}
getStackForEntity(spawnCause.getEntity().getType(), profile).ifPresent(itemStack -> {
Vector3d location = spawnCause.getEntity().getLocation().getPosition();
Item item = (Item) spawnCause.getEntity().getWorld().createEntity(EntityTypes.ITEM, location);
getStackForEntity(spawnCause.getType(), profile).ifPresent(itemStack -> {
Vector3d location = spawnCause.getLocation().getPosition();
Item item = (Item) spawnCause.getWorld().createEntity(EntityTypes.ITEM, location);
item.offer(Keys.REPRESENTED_ITEM, itemStack.createSnapshot());
spawnCause.getEntity().getWorld().spawnEntity(item, Cause.of(NamedCause.of("root", spawnCause)));
spawnCause.getWorld().spawnEntity(item);
});
}
@Listener
public void onPlayerInteract(InteractBlockEvent.Secondary.MainHand event, @Named(NamedCause.SOURCE) Player player) {
public void onPlayerInteract(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
if (!showNameClick.getValue()) {
return;
}
@@ -292,12 +288,11 @@ public void onBlockBreak(ChangeBlockEvent.Break event) {
getStackForEntity(entityType, profile).ifPresent(itemStack -> {
Item item = (Item) location.getExtent().createEntity(EntityTypes.ITEM, location.getPosition().add(0.5, 0.5, 0.5));
item.offer(Keys.REPRESENTED_ITEM, itemStack.createSnapshot());
location.getExtent().spawnEntity(item, Cause.of(NamedCause.of("root",
SpawnCause.builder().type(SpawnTypes.DROPPED_ITEM).build())));
location.getExtent().spawnEntity(item);
event.setCancelled(true);
Sponge.getScheduler().createTaskBuilder().execute(() ->
location.setBlockType(BlockTypes.AIR, CraftBookPlugin.spongeInst().getCause().build())).submit(CraftBookPlugin.spongeInst().container);
location.setBlockType(BlockTypes.AIR)).submit(CraftBookPlugin.spongeInst().container);
});
}
}
Oops, something went wrong.

0 comments on commit ce31c03

Please sign in to comment.