forked from FiniteReality/embeddium
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid patching IFluidBlock onto vanilla liquids
- Loading branch information
Showing
5 changed files
with
94 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/me/jellysquid/mods/sodium/client/world/VanillaFluidBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.jellysquid.mods.sodium.client.world; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockLiquid; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fluids.Fluid; | ||
import net.minecraftforge.fluids.FluidRegistry; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.IFluidBlock; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public interface VanillaFluidBlock { | ||
IFluidBlock getFakeFluidBlock(); | ||
|
||
class Implementation implements IFluidBlock { | ||
private final Block block; | ||
private Fluid sodium$forgeFluid; | ||
|
||
public Implementation(Block block) { | ||
this.block = block; | ||
} | ||
|
||
@Override | ||
public Fluid getFluid() { | ||
Fluid fluid = sodium$forgeFluid; | ||
if(fluid == null) { | ||
sodium$forgeFluid = fluid = block.getDefaultState().getMaterial() == Material.WATER ? FluidRegistry.WATER : FluidRegistry.LAVA; | ||
} | ||
return fluid; | ||
} | ||
|
||
@Override | ||
public int place(World world, BlockPos pos, @Nonnull FluidStack fluidStack, boolean doPlace) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public FluidStack drain(World world, BlockPos pos, boolean doDrain) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public boolean canDrain(World world, BlockPos pos) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public float getFilledPercentage(World world, BlockPos pos) { | ||
IBlockState blockState = world.getBlockState(pos); | ||
return getFluid() == null ? 0 : 1 - BlockLiquid.getLiquidHeightPercent(blockState.getValue(BlockLiquid.LEVEL)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters