use of net.glowstone.util.BlockMaterialValidator in project Glowstone by GlowstoneMC.
the class BlockSponge method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
// TODO: Move this to a new method when physics works and run this on neighbour change too.
MaterialData data = holding.getData();
if (!(data instanceof Sponge)) {
warnMaterialData(Sponge.class, data);
return;
}
Sponge sponge = (Sponge) data;
if (sponge.getType() == SpongeType.NORMAL) {
GlowBlock block = state.getBlock();
TaxicabBlockIterator iterator = new TaxicabBlockIterator(block);
iterator.setMaxDistance(7);
iterator.setMaxBlocks(66);
iterator.setValidator(new BlockMaterialValidator(WATER_MATERIALS));
if (iterator.hasNext()) {
sponge = sponge.clone();
sponge.setType(SpongeType.WET);
do {
iterator.next().setType(Material.AIR);
} while (iterator.hasNext());
}
}
state.setType(Material.SPONGE);
state.setData(sponge);
}
Aggregations