Skip to content

Commit

Permalink
Clean up some code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbegt committed Jan 10, 2018
1 parent e11b2ba commit e04c8cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Expand Up @@ -57,7 +57,9 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p
if (block != null && block.canSustainPlant(state, worldIn, pos, EnumFacing.UP, (IPlantable) this.crop) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.crop.getDefaultState());

itemstack.shrink(1);

return EnumActionResult.SUCCESS;
}
}
Expand All @@ -75,20 +77,19 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn)
{
addOptionalTooltip(stack, tooltip);

super.addInformation(stack, worldIn, tooltip, flagIn);
}

public static void addOptionalTooltip(ItemStack stack, List<String> tooltip)
{
if (I18n.canTranslate(stack.getUnlocalizedName() + ".tooltip"))
{
tooltip.addAll(LocUtils.getTooltips(TextFormatting.GRAY.toString() +
LocUtils.translateRecursive(stack.getUnlocalizedName() + ".tooltip")));
tooltip.addAll(LocUtils.getTooltips(TextFormatting.GRAY.toString() + LocUtils.translateRecursive(stack.getUnlocalizedName() + ".tooltip")));
}
else if (I18n.canTranslate(stack.getUnlocalizedName() + ".tooltip"))
{
tooltip.addAll(LocUtils.getTooltips(
TextFormatting.GRAY.toString() + LocUtils.translateRecursive(stack.getUnlocalizedName() + ".tooltip")));
tooltip.addAll(LocUtils.getTooltips(TextFormatting.GRAY.toString() + LocUtils.translateRecursive(stack.getUnlocalizedName() + ".tooltip")));
}
}

Expand Down
Expand Up @@ -66,7 +66,9 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p
if (block != null && block.canSustainPlant(state, worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.states.get(meta));

itemstack.shrink(1);

return EnumActionResult.SUCCESS;
}
}
Expand Down
Expand Up @@ -51,7 +51,9 @@ public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState s
if (entityarrow.isBurning())
{
this.explode(worldIn, pos, 1, entityarrow.shootingEntity instanceof EntityLiving ? (EntityLiving) entityarrow.shootingEntity : null);

worldIn.setBlockToAir(pos);

return;
}
}
Expand All @@ -74,7 +76,9 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,
if (state.getValue(BlockCloud.TYPE) == BlockCloud.CloudType.SULFUR && itemstack.getItem() != Items.AIR && itemstack.getItem() == Items.FLINT_AND_STEEL)
{
worldIn.setBlockToAir(pos);

this.explode(worldIn, pos, 1, playerIn);

return true;
}
}
Expand Down Expand Up @@ -129,6 +133,7 @@ public boolean isOpaqueCube(IBlockState state)
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
{
Material material = world.getBlockState(pos).getMaterial();

return material == this.blockMaterial ? false : super.isNormalCube(state, world, pos);
}

Expand Down

0 comments on commit e04c8cd

Please sign in to comment.