crwdns151789:0crwdne151789:0
crwdns151791:0crwdne151791:0
crwdns151793:0:javadoc:crwdnd151793:0:javadoc:crwdnd151793:0:javadoc:crwdne151793:0
import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; public void setToSponge(Location<World> blockLoc, Object myPluginInstance) { blockLoc.setBlockType(BlockTypes.SPONGE, Cause.source(myPluginInstance).build()); }
crwdns151795:0:javadoc:crwdne151795:0
crwdns151797:0crwdne151797:0
crwdns151799:0:javadoc:crwdnd151799:0:javadoc:crwdnd151799:0:javadoc:crwdne151799:0
import org.spongepowered.api.Sponge; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.data.manipulator.mutable.WetData; public void setToWetSponge(Location<World> blockLoc, Object myPluginInstance) { BlockState state = BlockTypes.SPONGE.getDefaultState(); WetData wetness = Sponge.getDataManager(). getManipulatorBuilder(WetData.class).get().create(); wetness.set(wetness.wet().set(true)); BlockState newState = state.with(wetness.asImmutable()).get(); blockLoc.setBlock(newState, Cause.source(myPluginInstance).build()); }
crwdns151801:0:javadoc:crwdnd151801:0:javadoc:crwdne151801:0
crwdns151803:0crwdne151803:0
import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.data.manipulator.immutable.block.ImmutableDirtData; import org.spongepowered.api.data.manipulator.mutable.block.DirtData; import org.spongepowered.api.data.type.DirtTypes; public void dirtToPodzol(Location<World> blockLoc, Object myPluginInstance) { BlockState state = blockLoc.getBlock(); Optional<ImmutableDirtData> dirtDataOpt = state.get(ImmutableDirtData.class); if (dirtDataOpt.isPresent()) { DirtData dirtData = dirtDataOpt.get().asMutable(); dirtData.set(Keys.DIRT_TYPE, DirtTypes.PODZOL); BlockState dirtState = state.with(dirtData.asImmutable()).get(); blockLoc.setBlock(dirtState, Cause.source(myPluginInstance).build()); } }
crwdns151805:0:javadoc:crwdne151805:0
crwdns151807:0:javadoc:crwdne151807:0
import org.spongepowered.api.data.manipulator.immutable.block.ImmutableWetData; public void dry(Location<World> blockLoc, Object myPluginInstance) { BlockState wetState = blockLoc.getBlock(); Optional<BlockState> dryState = wetState.without(ImmutableWetData.class); if (dryState.isPresent()) { blockLoc.setBlock(dryState.get(), Cause.source(myPluginInstance).build()); } }
crwdns151809:0:javadoc:crwdne151809:0
crwdns151811:0crwdne151811:0
crwdns151813:0:javadoc:crwdnd151813:0:javadoc:crwdne151813:0
import org.spongepowered.api.block.BlockSnapshot; public void copyBlock(Location<World> from, Location<World> to, Object myPluginInstance) { BlockSnapshot snapshot = from.createSnapshot(); to.setBlock(snapshot.getState(), Cause.source(myPluginInstance).build()); }