Skip to content

Commit

Permalink
Soils auto harvest when bonemealed or grown naturally - Resolves #281
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Dec 5, 2024
1 parent 8e03fb8 commit 5eb0532
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.direwolf20.justdirethings.common.blocks.soil;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;

public class GooSoilTier2 extends GooSoilBase {
Expand All @@ -21,4 +23,13 @@ public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Ran
}
autoHarvest(pLevel, pPos);
}

@Override
protected BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
if (facing == Direction.UP && level instanceof ServerLevel serverLevel) {
autoHarvest(serverLevel, currentPos);
}

return super.updateShape(state, facing, facingState, level, currentPos, facingPos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.direwolf20.justdirethings.common.blockentities.GooSoilBE;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -32,4 +34,13 @@ public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Ran
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new GooSoilBE(pos, state);
}

@Override
protected BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
if (facing == Direction.UP && level instanceof ServerLevel serverLevel) {
autoHarvest(serverLevel, currentPos);
}

return super.updateShape(state, facing, facingState, level, currentPos, facingPos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.direwolf20.justdirethings.common.blockentities.GooSoilBE;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -32,4 +34,13 @@ public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Ran
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new GooSoilBE(pos, state);
}

@Override
protected BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
if (facing == Direction.UP && level instanceof ServerLevel serverLevel) {
autoHarvest(serverLevel, currentPos);
}

return super.updateShape(state, facing, facingState, level, currentPos, facingPos);
}
}

0 comments on commit 5eb0532

Please sign in to comment.