-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec07d13
commit ac721ec
Showing
10 changed files
with
183 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
package name.minedustry; | ||
|
||
import name.minedustry.fluid.Fluids; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; | ||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; | ||
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler; | ||
import net.minecraft.client.render.RenderLayer; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class MinedustryClient implements ClientModInitializer { | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
|
||
FluidRenderHandlerRegistry.INSTANCE.register(Fluids.STILL_CRYOFLUID, Fluids.FLOWING_CRYOFLUID, | ||
new SimpleFluidRenderHandler( | ||
Identifier.of("minedustry", "block/cryofluid_still"), | ||
Identifier.of("minedustry", "block/cryofluid_flow"), | ||
0x66ccff | ||
) | ||
); | ||
BlockRenderLayerMap.INSTANCE.putFluids(RenderLayer.getTranslucent(), Fluids.STILL_CRYOFLUID, Fluids.FLOWING_CRYOFLUID); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package name.minedustry.fluid; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.FluidBlock; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.fluid.FlowableFluid; | ||
import net.minecraft.fluid.Fluid; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldAccess; | ||
import net.minecraft.world.WorldView; | ||
|
||
import static name.minedustry.block.MinedustryBlocks.CRYOFLUID; | ||
import static name.minedustry.item.MinedustryItems.CRYOFLUID_BUCKET; | ||
|
||
public abstract class CryoFluid extends FlowableFluid { | ||
@Override | ||
public Fluid getFlowing() { | ||
return Fluids.FLOWING_CRYOFLUID; | ||
} | ||
|
||
@Override | ||
public Fluid getStill() { | ||
return Fluids.STILL_CRYOFLUID; | ||
} | ||
|
||
@Override | ||
public Item getBucketItem() { | ||
return CRYOFLUID_BUCKET; | ||
} | ||
|
||
@Override | ||
protected boolean isInfinite(World world) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void beforeBreakingBlock(WorldAccess world, BlockPos pos, BlockState state) { | ||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null; | ||
Block.dropStacks(state, world, pos, blockEntity); | ||
} | ||
|
||
@Override | ||
public int getMaxFlowDistance(WorldView world) { | ||
return 4; | ||
} | ||
|
||
@Override | ||
public BlockState toBlockState(FluidState state) { | ||
return CRYOFLUID.getDefaultState().with(FluidBlock.LEVEL, getBlockStateLevel(state)); | ||
} | ||
|
||
@Override | ||
public boolean matchesType(Fluid fluid) { | ||
return fluid == getFlowing() || fluid == getStill(); | ||
} | ||
|
||
@Override | ||
protected int getLevelDecreasePerBlock(WorldView world) { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getTickRate(WorldView world) { | ||
return 5; | ||
} | ||
|
||
@Override | ||
public boolean canBeReplacedWith(FluidState state, BlockView world, BlockPos pos, Fluid fluid, Direction direction) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected float getBlastResistance() { | ||
return 100.0F; | ||
} | ||
|
||
public static class Flowing extends CryoFluid { | ||
@Override | ||
protected void appendProperties(StateManager.Builder<Fluid, FluidState> builder) { | ||
super.appendProperties(builder); | ||
builder.add(LEVEL); | ||
} | ||
|
||
@Override | ||
public int getLevel(FluidState state) { | ||
return state.get(LEVEL); | ||
} | ||
|
||
@Override | ||
public boolean isStill(FluidState state) { | ||
return false; | ||
} | ||
} | ||
|
||
public static class Still extends CryoFluid { | ||
@Override | ||
public int getLevel(FluidState state) { | ||
return 8; | ||
} | ||
|
||
@Override | ||
public boolean isStill(FluidState state) { | ||
return true; | ||
} | ||
} | ||
} |
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,15 @@ | ||
package name.minedustry.fluid; | ||
|
||
import net.minecraft.fluid.FlowableFluid; | ||
import net.minecraft.fluid.Fluid; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
|
||
public class Fluids { | ||
public static final FlowableFluid FLOWING_CRYOFLUID = register("cryofluid", new CryoFluid.Flowing()); | ||
public static final FlowableFluid STILL_CRYOFLUID = register("cryofluid", new CryoFluid.Still()); | ||
|
||
private static <T extends Fluid> T register(String id, T value) { | ||
return Registry.register(Registries.FLUID, id, value); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/minedustry/blockstates/cryofluid.json
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,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "minedustry:block/cryofluid" | ||
} | ||
} | ||
} |
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
Binary file added
BIN
+6.54 KB
src/main/resources/assets/minedustry/textures/block/cryofluid_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.31 KB
src/main/resources/assets/minedustry/textures/block/cryofluid_still.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.