Atomic Disassembler Grass Path Block Tweak (#5471)

* implement #4464

* fix some changed language files

Just fix accidentally uploading old versions of some lang files

* implment a suggested change
This commit is contained in:
ToMe25 authored and Richard Freimer committed 2019-05-13 11:49:21 -04:00
1 parent 80b07bc4b3
commit aa1050352b
1 file changed
+40 -2
@@ -171,7 +171,7 @@ public class ItemAtomicDisassembler extends ItemEnergized {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
Block block = world.getBlockState(pos).getBlock();
if (!player.isSneaking() && (block == Blocks.DIRT || block == Blocks.GRASS || block == Blocks.GRASS_PATH)) {
if (!player.isSneaking() && (block == Blocks.DIRT || block == Blocks.GRASS_PATH)) {
if (useHoe(stack, player, world, pos, side) == EnumActionResult.FAIL) {
return EnumActionResult.FAIL;
}
@@ -193,10 +193,31 @@ public class ItemAtomicDisassembler extends ItemEnergized {
}
return EnumActionResult.SUCCESS;
}
else if (!player.isSneaking() && block == Blocks.GRASS) {
if (useShovel(stack, player, world, pos, side) == EnumActionResult.FAIL) {
return EnumActionResult.FAIL;
}
switch (getEfficiency(stack)) {
case 20:
for (int x1 = -1; x1 <= +1; x1++) {
for (int z1 = -1; z1 <= +1; z1++) {
useShovel(stack, player, world, pos.add(x1, 0, z1), side);
}
}
break;
case 128:
for (int x1 = -2; x1 <= +2; x1++) {
for (int z1 = -2; z1 <= +2; z1++) {
useShovel(stack, player, world, pos.add(x1, 0, z1), side);
}
}
break;
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
@SuppressWarnings("incomplete-switch")
private EnumActionResult useHoe(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing) {
if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) {
return EnumActionResult.FAIL;
@@ -221,11 +242,28 @@ public class ItemAtomicDisassembler extends ItemEnergized {
setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState()
.withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
return EnumActionResult.SUCCESS;
default:
return EnumActionResult.PASS;
}
}
}
return EnumActionResult.PASS;
}
private EnumActionResult useShovel(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing) {
if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) {
return EnumActionResult.FAIL;
}
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) {
if (block == Blocks.GRASS) {
setBlock(stack, playerIn, worldIn, pos, Blocks.GRASS_PATH.getDefaultState());
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) {
worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);