@Override public List<BlockTransaction> filter(Predicate<Location<World>> predicate) { Iterator<BlockTransaction> iterator = getTransactions().iterator(); while (iterator.hasNext()) { BlockTransaction transaction = iterator.next(); Location<World> location = transaction.getOriginal().getLocation().get(); if (!predicate.apply(location)) { transaction.setIsValid(false); } } return this.blockTransactions; }
@SuppressWarnings({"unchecked"}) @Override public void syncDataToForge(org.spongepowered.api.event.Event spongeEvent) { super.syncDataToForge(spongeEvent); ExplosionEvent.Detonate event = (ExplosionEvent.Detonate) spongeEvent; List<BlockPos> affectedBlocks = this.explosion.func_180343_e(); affectedBlocks.clear(); for (BlockTransaction blockTransaction : event.getTransactions()) { if (blockTransaction.isValid()) { affectedBlocks.add( VecHelper.toBlockPos(blockTransaction.getFinalReplacement().getPosition())); } } }
@SuppressWarnings("unchecked") @Override public void syncDataToSponge(net.minecraftforge.fml.common.eventhandler.Event forgeEvent) { super.syncDataToSponge(forgeEvent); net.minecraftforge.event.world.ExplosionEvent event = (net.minecraftforge.event.world.ExplosionEvent) forgeEvent; // TODO - handle this better List<BlockPos> affectedBlocks = event.explosion.func_180343_e(); for (BlockTransaction transaction : this.blockTransactions) { BlockPos pos = VecHelper.toBlockPos(transaction.getFinalReplacement().getPosition()); boolean match = false; for (BlockPos forgePos : affectedBlocks) { if (forgePos.getX() == pos.getX() && forgePos.getY() == pos.getY() && forgePos.getZ() == pos.getZ()) { match = true; } } if (!match) { transaction.setIsValid(false); } } }