Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueGkoliver committed May 9, 2020
1 parent 99240cc commit 1d5e883
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.IGrowable;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
Expand All @@ -19,12 +24,14 @@
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;

public class FakeGrowableBlock extends Block {
public class FakeGrowableBlock extends Block implements IWaterLoggable {
int stages;
ECropTypes type;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final IntegerProperty AGE = BlockStateProperties.AGE_0_7;
//Stage block sizes
private static final VoxelShape[] CARROT_SHAPES = new VoxelShape[]{
Expand Down Expand Up @@ -91,6 +98,7 @@ public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos,
}
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
builder.add(AGE);
builder.add(WATERLOGGED);
}

@Override
Expand Down Expand Up @@ -120,4 +128,24 @@ public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockP
}
return ActionResultType.SUCCESS;
}

public IFluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
}

public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, IFluidState fluidStateIn) {
return IWaterLoggable.super.receiveFluid(worldIn, pos, state, fluidStateIn);
}

public boolean canContainFluid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
return IWaterLoggable.super.canContainFluid(worldIn, pos, state, fluidIn);
}
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
if (stateIn.get(WATERLOGGED)) {
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
}

return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,25 @@ protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(WATERLOGGED);
}
public IFluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
}

public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, IFluidState fluidStateIn) {
return IWaterLoggable.super.receiveFluid(worldIn, pos, state, fluidStateIn);
}

public boolean canContainFluid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
return IWaterLoggable.super.canContainFluid(worldIn, pos, state, fluidIn);
}
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
}

/**
* Update the provided state given the provided neighbor facing and neighbor state, returning a new state.
* For example, fences make their connections to the passed in state if possible, and wet concrete powder immediately
* returns its solidified counterpart.
* Note that this method should ideally consider only the specific face passed in.
*/
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
if (stateIn.get(WATERLOGGED)) {
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
}
public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, IFluidState fluidStateIn) {
return IWaterLoggable.super.receiveFluid(worldIn, pos, state, fluidStateIn);
}

return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public boolean canContainFluid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
return IWaterLoggable.super.canContainFluid(worldIn, pos, state, fluidIn);
}
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
if (stateIn.get(WATERLOGGED)) {
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
}

return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
boolean isSapling = (state.getBlock() == BlockRegistry.FAKE_OAK_SAPLING.get() ||
state.getBlock() == BlockRegistry.FAKE_BIRCH_SAPLING.get() ||
state.getBlock() == BlockRegistry.FAKE_SPRUCE_SAPLING.get() ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package com.gkoliver.nwis.common.block.vegitation.swex.pickelreedtype;

public class PickelreedDoubleBlock {
import net.minecraft.block.Block;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.Half;

public class PickelreedDoubleBlock extends Block implements IWaterLoggable {
public PickelreedDoubleBlock(Properties properties) {
super(properties);
}

public static final EnumProperty<Half> HALF = BlockStateProperties.HALF;
}

0 comments on commit 1d5e883

Please sign in to comment.