@author Gregorius Techneticies
| 58 | * @author Gregorius Techneticies |
| 59 | */ |
| 60 | public class BlockBaseFluid extends BlockFluidFinite implements IBlock, IItemGT, IBlockOnHeadInside { |
| 61 | public static int FLUID_UPDATE_FLAGS = 2; |
| 62 | |
| 63 | public final String mNameInternal; |
| 64 | public final int mFlammability, mAmountPerQuanta, mDensityDir; |
| 65 | public final Fluid mFluid; |
| 66 | public final FluidStack mQuanta; |
| 67 | |
| 68 | public BlockBaseFluid(String aNameInternal, FL aFluid, int aFlammability) { |
| 69 | this(aNameInternal, aFluid.fluid(), aFlammability); |
| 70 | } |
| 71 | public BlockBaseFluid(String aNameInternal, FL aFluid, int aFlammability, Material aMaterial) { |
| 72 | this(aNameInternal, aFluid.fluid(), aFlammability, aMaterial); |
| 73 | } |
| 74 | public BlockBaseFluid(String aNameInternal, Fluid aFluid, int aFlammability) { |
| 75 | this(aNameInternal, aFluid, aFlammability, aFluid.isGaseous()?MaterialGas.instance:aFluid.getTemperature()>500?Material.lava:Material.water); |
| 76 | } |
| 77 | public BlockBaseFluid(String aNameInternal, Fluid aFluid, int aFlammability, Material aMaterial) { |
| 78 | this(aNameInternal, aFluid, 125, aFlammability, aMaterial); |
| 79 | } |
| 80 | public BlockBaseFluid(String aNameInternal, Fluid aFluid, int aAmountPerQuanta, int aFlammability, Material aMaterial) { |
| 81 | super(aFluid, aMaterial); |
| 82 | mFluid = aFluid; |
| 83 | mAmountPerQuanta = aAmountPerQuanta; |
| 84 | mQuanta = FL.make(mFluid, mAmountPerQuanta); |
| 85 | mDensityDir = densityDir; |
| 86 | mFlammability = aFlammability; |
| 87 | setBlockName(mNameInternal = aNameInternal); |
| 88 | setResistance(FL.gas(mFluid) ? 1 : 30); |
| 89 | ST.register(this, mNameInternal, ItemBlock.class); |
| 90 | FL.BLOCKS.put(mFluid.getName(), this); |
| 91 | displacements.put(this, F); |
| 92 | LanguageHandler.set(getLocalizedName(), getLocalizedName()); // WAILA is retarded... |
| 93 | // Speaking of retarded, only allowing one type of Block per Fluid is retarded too! So I guess I gotta override all pre-existing Fluids with my Version to make sure shit works. |
| 94 | UT.Reflection.setField(Fluid.class, aFluid, "block", this); |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public FluidStack drain(World aWorld, int aX, int aY, int aZ, boolean aDoDrain) { |
| 99 | // Forge royally fucked up again. You check for MetaData FIRST and do the set Block to Air SECOND, like I demonstrate here!!! |
| 100 | FluidStack rFluid = FL.mul(mQuanta, WD.meta(aWorld, aX, aY, aZ)+1); |
| 101 | if (aDoDrain) { |
| 102 | WD.set(aWorld, aX, aY, aZ, NB, 0, 3); |
| 103 | updateFluidBlocks(aWorld, aX, aY, aZ, T); |
| 104 | } |
| 105 | return rFluid; |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aUselessBlock) { |
| 110 | // Do the update in a few ticks. |
| 111 | aWorld.scheduleBlockUpdate(aX, aY, aZ, this, tickRate); |
| 112 | // Remove Flowing Water/Lava from adjacent Blocks! |
| 113 | for (byte tSide : ALL_SIDES_VALID) { |
| 114 | Block tBlock = WD.block(aWorld, aX, aY, aZ, tSide, F); |
| 115 | // Check for broken Fluids of the same Material as this Fluid. |
| 116 | if (tBlock.getMaterial() == getMaterial() && WD.liquid_borken(tBlock)) { |
| 117 | // Get rid of Flowing Water/Lava adjacent to my Fluids, because Forge is fucked up. |
nothing calls this directly
no outgoing calls
no test coverage detected