mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-04 01:01:29 +01:00
Destroy connected alfalfa blocks when destroyed by a player. Might help with floating plants
This commit is contained in:
parent
a3f12e4ea7
commit
c76be4a461
1 changed files with 8 additions and 2 deletions
|
@ -2,6 +2,8 @@ package com.minelittlepony.unicopia.block;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.UItems;
|
import com.minelittlepony.unicopia.UItems;
|
||||||
|
|
||||||
import net.minecraft.block.BlockCrops;
|
import net.minecraft.block.BlockCrops;
|
||||||
|
@ -169,19 +171,23 @@ public class BlockAlfalfa extends BlockCrops {
|
||||||
return getHalf(state) != Half.BOTTOM || super.canBlockStay(world, pos, state);
|
return getHalf(state) != Half.BOTTOM || super.canBlockStay(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPlayerDestroy(World worldIn, BlockPos pos, IBlockState state) {
|
||||||
|
breakConnectedBlocks(worldIn, pos, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {
|
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {
|
||||||
breakConnectedBlocks(worldIn, pos, player);
|
breakConnectedBlocks(worldIn, pos, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void breakConnectedBlocks(World worldIn, BlockPos pos, EntityPlayer player) {
|
protected void breakConnectedBlocks(World worldIn, BlockPos pos, @Nullable EntityPlayer player) {
|
||||||
IBlockState state = worldIn.getBlockState(pos);
|
IBlockState state = worldIn.getBlockState(pos);
|
||||||
|
|
||||||
if (state.getBlock() != this) {
|
if (state.getBlock() != this) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.capabilities.isCreativeMode) {
|
if (player != null && player.capabilities.isCreativeMode) {
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
} else {
|
} else {
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue