![JAR search and dependency download from the Maven repository](/logo.png)
cn.nukkit.dispenser.BucketDispenseBehavior Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.dispenser;
import cn.nukkit.block.*;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemBucket;
import cn.nukkit.item.MinecraftItemID;
import cn.nukkit.math.BlockFace;
/**
* @author CreeperFace
*/
public class BucketDispenseBehavior extends DefaultDispenseBehavior {
@Override
public Item dispense(BlockDispenser block, BlockFace face, Item item) {
if (!(item instanceof ItemBucket)) {
return super.dispense(block, face, item);
}
ItemBucket bucket = (ItemBucket) item;
Block target = block.getSide(face);
if (!bucket.isEmpty()) {
if (target.canBeFlowedInto() || target.getId() == BlockID.NETHER_PORTAL) {
Block replace = bucket.getTargetBlock();
if (replace instanceof BlockLiquid) {
if (target.getId() == BlockID.NETHER_PORTAL) {
target.onBreak(null);
}
block.level.setBlock(target, replace);
return MinecraftItemID.BUCKET.get(1, bucket.getCompoundTag());
}
}
} else if (target instanceof BlockWater && target.getDamage() == 0) {
target.level.setBlock(target, Block.get(BlockID.AIR));
return MinecraftItemID.WATER_BUCKET.get(1, bucket.getCompoundTag());
} else if (target instanceof BlockLava && target.getDamage() == 0) {
target.level.setBlock(target, Block.get(BlockID.AIR));
return MinecraftItemID.LAVA_BUCKET.get(1, bucket.getCompoundTag());
}
return super.dispense(block, face, item);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy