- private void flowFluidTo(int thisId, int x, int y, int nextStateId) {
- int thatId = id(x, y);
- if (fluidCanFlowThere(thisId, thatId)) {
- mGameWorld.setForeMap(x, y, nextStateId);
- } else if (isWater(thisId) && isLava(thatId)) {
- if (getBlockState(thatId) > 0) {
- mGameWorld.setForeMap(x, y, 4); //cobblestone
+ private boolean fluidCanFlowThere(Block.Fluid fluid, Block targetBlock) {
+ return targetBlock == mGameItemsHolder.getFallbackBlock() ||
+ (!targetBlock.getParams().getHasCollision() && !targetBlock.isFluid()) ||
+ (fluid.getClass() == targetBlock.getClass() && fluid.getState() < ((Block.Fluid)targetBlock).getState());
+ }
+
+ private void flowFluidTo(Block.Fluid currentFluid, int x, int y, Block.Fluid nextStateFluid) {
+ final Block targetBlock = mGameWorld.getForeMap(x, y);
+
+ if (fluidCanFlowThere(currentFluid, targetBlock)) {
+ mGameWorld.setForeMap(x, y, nextStateFluid);
+ } else if (currentFluid.isWater() && targetBlock.isLava()) {
+ if (((Block.Lava)targetBlock).getState() > 0) {
+ mGameWorld.setForeMap(x, y, mGameItemsHolder.getBlock("cobblestone"));