2015-11-09 06:50:45 +00:00
--- ../src-base/minecraft/net/minecraft/block/BlockDoublePlant.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDoublePlant.java
2016-05-18 10:29:10 +00:00
@@ -26,7 +26,7 @@
2015-11-09 06:50:45 +00:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-public class BlockDoublePlant extends BlockBush implements IGrowable
+public class BlockDoublePlant extends BlockBush implements IGrowable, net.minecraftforge.common.IShearable
{
2015-11-22 05:46:26 +00:00
public static final PropertyEnum<BlockDoublePlant.EnumPlantType> field_176493_a = PropertyEnum.<BlockDoublePlant.EnumPlantType>func_177709_a("variant", BlockDoublePlant.EnumPlantType.class);
public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> field_176492_b = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>func_177709_a("half", BlockDoublePlant.EnumBlockHalf.class);
2016-05-18 10:29:10 +00:00
@@ -89,6 +89,8 @@
2015-11-22 05:46:26 +00:00
Block block = (Block)(flag ? this : p_176475_1_.func_180495_p(blockpos).func_177230_c());
Block block1 = (Block)(flag ? p_176475_1_.func_180495_p(blockpos1).func_177230_c() : this);
2015-11-09 06:50:45 +00:00
2015-11-22 05:46:26 +00:00
+ if (!flag) this.func_176226_b(p_176475_1_, p_176475_2_, p_176475_3_, 0); //Forge move above the setting to air.
2015-11-09 06:50:45 +00:00
+
if (block == this)
{
2015-11-22 05:46:26 +00:00
p_176475_1_.func_180501_a(blockpos, Blocks.field_150350_a.func_176223_P(), 2);
2016-05-18 10:29:10 +00:00
@@ -97,17 +99,13 @@
2015-11-09 06:50:45 +00:00
if (block1 == this)
{
2015-11-22 05:46:26 +00:00
p_176475_1_.func_180501_a(blockpos1, Blocks.field_150350_a.func_176223_P(), 3);
2015-11-09 06:50:45 +00:00
-
- if (!flag)
- {
2015-11-22 05:46:26 +00:00
- this.func_176226_b(p_176475_1_, blockpos1, p_176475_3_, 0);
2015-11-09 06:50:45 +00:00
- }
}
}
}
2015-11-22 05:46:26 +00:00
public boolean func_180671_f(World p_180671_1_, BlockPos p_180671_2_, IBlockState p_180671_3_)
2015-11-09 06:50:45 +00:00
{
2015-11-22 05:46:26 +00:00
+ if (p_180671_3_.func_177230_c() != this) return super.func_180671_f(p_180671_1_, p_180671_2_, p_180671_3_); //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check.
if (p_180671_3_.func_177229_b(field_176492_b) == BlockDoublePlant.EnumBlockHalf.UPPER)
2015-11-09 06:50:45 +00:00
{
2015-11-22 05:46:26 +00:00
return p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c() == this;
2016-11-13 22:09:54 +00:00
@@ -150,7 +148,6 @@
2015-11-09 06:50:45 +00:00
2016-11-13 22:09:54 +00:00
public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, @Nullable TileEntity p_180657_5_, ItemStack p_180657_6_)
2015-11-09 06:50:45 +00:00
{
2016-11-13 22:09:54 +00:00
- if (p_180657_1_.field_72995_K || p_180657_6_.func_77973_b() != Items.field_151097_aZ || p_180657_4_.func_177229_b(field_176492_b) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.func_176489_b(p_180657_1_, p_180657_3_, p_180657_4_, p_180657_2_))
2015-11-09 06:50:45 +00:00
{
2016-03-12 00:59:24 +00:00
super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_);
2015-11-09 06:50:45 +00:00
}
2016-11-13 22:09:54 +00:00
@@ -210,8 +207,6 @@
2015-11-09 06:50:45 +00:00
else
{
2016-03-12 00:59:24 +00:00
p_176489_4_.func_71029_a(StatList.func_188055_a(this));
2015-11-22 05:46:26 +00:00
- int i = (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? BlockTallGrass.EnumType.GRASS : BlockTallGrass.EnumType.FERN).func_177044_a();
- func_180635_a(p_176489_1_, p_176489_2_, new ItemStack(Blocks.field_150329_H, 2, i));
2015-11-09 06:50:45 +00:00
return true;
}
}
2016-11-13 22:09:54 +00:00
@@ -281,6 +276,33 @@
2015-11-09 06:50:45 +00:00
return Block.EnumOffsetType.XZ;
}
+ @Override
+ public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos)
+ {
2015-11-22 05:46:26 +00:00
+ IBlockState state = world.func_180495_p(pos);
+ EnumPlantType type = (EnumPlantType)state.func_177229_b(field_176493_a);
+ return state.func_177229_b(field_176492_b) == EnumBlockHalf.LOWER && (type == EnumPlantType.FERN || type == EnumPlantType.GRASS);
2015-11-09 06:50:45 +00:00
+ }
2016-03-12 00:59:24 +00:00
+
2015-11-09 06:50:45 +00:00
+ @Override
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
+ {
+ java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
2015-11-22 05:46:26 +00:00
+ EnumPlantType type = (EnumPlantType)world.func_180495_p(pos).func_177229_b(field_176493_a);
+ if (type == EnumPlantType.FERN) ret.add(new ItemStack(Blocks.field_150329_H, 2, BlockTallGrass.EnumType.FERN.func_177044_a()));
+ if (type == EnumPlantType.GRASS) ret.add(new ItemStack(Blocks.field_150329_H, 2, BlockTallGrass.EnumType.GRASS.func_177044_a()));
2015-11-09 06:50:45 +00:00
+ return ret;
+ }
2016-03-12 00:59:24 +00:00
+
2015-11-09 06:50:45 +00:00
+ @Override
2016-03-12 00:59:24 +00:00
+ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
2015-11-09 06:50:45 +00:00
+ {
+ //Forge: Break both parts on the client to prevent the top part flickering as default type for a few frames.
2015-11-22 05:46:26 +00:00
+ if (state.func_177230_c() == this && state.func_177229_b(field_176492_b) == EnumBlockHalf.LOWER && world.func_180495_p(pos.func_177984_a()).func_177230_c() == this)
+ world.func_175698_g(pos.func_177984_a());
+ return world.func_175698_g(pos);
2015-11-09 06:50:45 +00:00
+ }
+
public static enum EnumBlockHalf implements IStringSerializable
{
UPPER,