buckets fillin' good

This commit is contained in:
khj xiaogu 2021-10-24 18:59:02 +08:00
parent bc169e60d6
commit f67aa333b9
No known key found for this signature in database
GPG key ID: DEA172814EAFF426

View file

@ -4,9 +4,12 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ILiquidContainer;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
@ -15,10 +18,38 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
public abstract class BoilerBlock extends Block {
public BoilerBlock(Properties properties) {
public abstract class BoilerBlock extends Block implements ILiquidContainer{
@Override
public boolean canPlaceLiquid(IBlockReader w, BlockPos p, BlockState s,Fluid f) {
TileEntity te=w.getBlockEntity(p);
if(te instanceof BoilerTileEntity) {
BoilerTileEntity boiler=(BoilerTileEntity)te;
if(boiler.input.fill(new FluidStack(f,1000),FluidAction.SIMULATE)==1000)
return true;
}
return false;
}
@Override
public boolean placeLiquid(IWorld w, BlockPos p, BlockState s,
FluidState f){
TileEntity te=w.getBlockEntity(p);
if(te instanceof BoilerTileEntity) {
BoilerTileEntity boiler=(BoilerTileEntity)te;
if(boiler.input.fill(new FluidStack(f.getType(),1000),FluidAction.SIMULATE)==1000) {
boiler.input.fill(new FluidStack(f.getType(),1000),FluidAction.EXECUTE);
return true;
}
}
return false;
}
public BoilerBlock(Properties properties) {
super(properties);
}