@author Gregorius Techneticies
| 57 | * @author Gregorius Techneticies |
| 58 | */ |
| 59 | public abstract class BlockWaterlike extends BlockFluidClassic implements IBlock, IItemGT, IBlockOnHeadInside { |
| 60 | public static int WATER_UPDATE_FLAGS = 0; |
| 61 | |
| 62 | public final Fluid mFluid; |
| 63 | |
| 64 | public BlockWaterlike(String aName, Fluid aFluid, boolean aFlowsOut, boolean aHide) { |
| 65 | super(aFluid, Material.water); |
| 66 | mFluid = aFluid; |
| 67 | quantaPerBlock = (aFlowsOut ? 8 : 3); |
| 68 | quantaPerBlockFloat = quantaPerBlock; |
| 69 | setResistance(30); |
| 70 | setBlockName(aName); |
| 71 | setLightOpacity(LIGHT_OPACITY_WATER); |
| 72 | ST.register(this, aName, ItemBlock.class); |
| 73 | LH.add(getUnlocalizedName(), getLocalizedName()); |
| 74 | LanguageHandler.set(getLocalizedName(), getLocalizedName()); // WAILA is retarded... |
| 75 | setFluidStack(FL.make(aFluid, 1000)); |
| 76 | if (aHide) ST.hide(this); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public FluidStack drain(World aWorld, int aX, int aY, int aZ, boolean aDoDrain) { |
| 81 | if (aDoDrain) aWorld.setBlock(aX, aY, aZ, NB, 0, 2); |
| 82 | return FL.make(getFluid(), 1000); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public boolean canDrain(World aWorld, int aX, int aY, int aZ) { |
| 87 | return WD.meta(aWorld, aX, aY, aZ) == 0; |
| 88 | } |
| 89 | |
| 90 | public void updateFlow(World aWorld, int aX, int aY, int aZ, Random aRandom) { |
| 91 | int quantaRemaining = quantaPerBlock - WD.meta(aWorld, aX, aY, aZ); |
| 92 | int expQuanta = -101; |
| 93 | // check adjacent block levels if non-source |
| 94 | if (quantaRemaining < quantaPerBlock) { |
| 95 | if (aWorld.getBlock(aX , aY-densityDir, aZ ) instanceof BlockWaterlike || |
| 96 | aWorld.getBlock(aX-1, aY-densityDir, aZ ) instanceof BlockWaterlike || |
| 97 | aWorld.getBlock(aX+1, aY-densityDir, aZ ) instanceof BlockWaterlike || |
| 98 | aWorld.getBlock(aX , aY-densityDir, aZ-1) instanceof BlockWaterlike || |
| 99 | aWorld.getBlock(aX , aY-densityDir, aZ+1) instanceof BlockWaterlike) { |
| 100 | expQuanta = quantaPerBlock - 1; |
| 101 | } else { |
| 102 | int maxQuanta = -100; |
| 103 | maxQuanta = getLargerQuanta(aWorld, aX-1, aY, aZ , maxQuanta); |
| 104 | maxQuanta = getLargerQuanta(aWorld, aX+1, aY, aZ , maxQuanta); |
| 105 | maxQuanta = getLargerQuanta(aWorld, aX , aY, aZ-1, maxQuanta); |
| 106 | maxQuanta = getLargerQuanta(aWorld, aX , aY, aZ+1, maxQuanta); |
| 107 | expQuanta = maxQuanta - 1; |
| 108 | } |
| 109 | if (expQuanta != quantaRemaining) { |
| 110 | quantaRemaining = expQuanta; |
| 111 | if (expQuanta <= 0) { |
| 112 | aWorld.setBlockToAir(aX, aY, aZ); |
| 113 | } else { |
| 114 | aWorld.setBlockMetadataWithNotify(aX, aY, aZ, quantaPerBlock - expQuanta, 3); |
| 115 | aWorld.scheduleBlockUpdate(aX, aY, aZ, this, tickRate); |
| 116 | aWorld.notifyBlocksOfNeighborChange(aX, aY, aZ, this); |
nothing calls this directly
no outgoing calls
no test coverage detected