-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
33 changed files
with
377 additions
and
36 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
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
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
64 changes: 64 additions & 0 deletions
64
src/main/java/net/cr24/primeval/block/plant/PrimevalWaterPlantBlock.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,64 @@ | ||
package net.cr24.primeval.block.plant; | ||
|
||
import net.cr24.primeval.block.PrimevalBlockTags; | ||
import net.cr24.primeval.block.PrimevalBlocks; | ||
import net.minecraft.block.*; | ||
import net.minecraft.fluid.Fluid; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.tag.FluidTags; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.WorldAccess; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class PrimevalWaterPlantBlock extends PlantBlock implements FluidFillable { | ||
|
||
protected static final VoxelShape SHAPE = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 8.0, 14.0); | ||
|
||
public PrimevalWaterPlantBlock(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { | ||
return SHAPE; | ||
} | ||
|
||
@Override | ||
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { | ||
return floor.isIn(PrimevalBlockTags.MEDIUM_SOIL) || floor.isIn(PrimevalBlockTags.LIGHT_SOIL) || floor.isOf(PrimevalBlocks.STONE); | ||
} | ||
|
||
@Nullable | ||
public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); | ||
return fluidState.isIn(FluidTags.WATER) && fluidState.getLevel() == 8 ? super.getPlacementState(ctx) : null; | ||
} | ||
|
||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { | ||
BlockState blockState = super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); | ||
if (!blockState.isAir()) { | ||
world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); | ||
} | ||
|
||
return blockState; | ||
} | ||
|
||
public FluidState getFluidState(BlockState state) { | ||
return Fluids.WATER.getStill(false); | ||
} | ||
|
||
@Override | ||
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.