Reverting "Fix some block breaking problems".

This commit is contained in:
Alexander Behrhof committed 2014-07-21 15:07:16 -04:00
1 parent c43bbf10a5
commit ea634c139f
7 files changed
+570 -164

No files matched your search

@@ -12,7 +12,6 @@ import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -163,33 +162,90 @@ public class Scythe extends Weapon
if (!stack.hasTagCompound())
return false;
if (player instanceof EntityPlayerMP)
World world = player.worldObj;
final Block blockB = world.getBlock(x, y, z);
final int meta = world.getBlockMetadata(x, y, z);
if (!stack.hasTagCompound())
return false;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
boolean butter = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0;
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
EntityPlayerMP mplayer = (EntityPlayerMP) player;
World world = player.worldObj;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey("AOEBreaking") || !tags.getBoolean("AOEBreaking"))
for (int yPos = y - 1; yPos <= y + 1; yPos++)
{
tags.setBoolean("AOEBreaking", true);
for (int xPos = x - 1; xPos <= x + 1; xPos++)
for (int zPos = z - 1; zPos <= z + 1; zPos++)
{
for (int yPos = y - 1; yPos <= y + 1; yPos++)
if (!(tags.getBoolean("Broken")))
{
for (int zPos = z - 1; zPos <= z + 1; zPos++)
boolean cancelHarvest = false;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
{
Block block = world.getBlock(xPos, yPos, zPos);
for (Material mat : this.materials)
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
cancelHarvest = true;
}
if (!cancelHarvest)
{
Block localBlock = world.getBlock(xPos, yPos, zPos);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
if (localBlock != null)// && (block.blockMaterial == Material.leaves || block.isLeaves(world, xPos, yPos, zPos)))
{
if (block != null && mat == block.getMaterial()
&& block.getPlayerRelativeBlockHardness(mplayer, world, x, yPos, z) > 0)
mplayer.theItemInWorldManager.tryHarvestBlock(xPos, yPos, zPos);
for (int iter = 0; iter < materials.length; iter++)
{
if (materials[iter] == localBlock.getMaterial())
{
if (!player.capabilities.isCreativeMode)
{
if (butter && localBlock instanceof IShearable && ((IShearable) localBlock).isShearable(stack, player.worldObj, x, y, z))
{
ArrayList<ItemStack> drops = ((IShearable) localBlock).onSheared(stack, player.worldObj, x, y, z,
EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack));
Random rand = new Random();
if (!world.isRemote)
for (ItemStack dropStack : drops)
{
float f = 0.7F;
double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(player.worldObj, (double) xPos + d, (double) yPos + d1, (double) zPos + d2, dropStack);
entityitem.delayBeforeCanPickup = 10;
player.worldObj.spawnEntityInWorld(entityitem);
}
if (localHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(localBlock)], 1);
world.setBlockToAir(xPos, yPos, zPos);
}
else
{
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos))
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
}
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (localHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
}
}
else
{
world.setBlockToAir(xPos, yPos, zPos);
}
}
}
}
}
}
}
tags.setBoolean("AOEBreaking", false);
}
}
if (!world.isRemote)
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockB) + (meta << 12));
return super.onBlockStartBreak(stack, x, y, z, player);
}