Fix some block breaking problems.

- Bibliocraft locks are respected.
- Fixes Thaumcraft node drops.
- Fixes strange auto-smelt drops sometimes.
- Probably fixes sync issues somewhere.
This commit is contained in:
blue42u committed 2014-06-14 09:31:39 -05:00
1 parent 01ac924123
commit b16b79a823
11 files changed
+216 -668

No files matched your search

@@ -12,6 +12,7 @@ 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;
@@ -162,90 +163,33 @@ public class Scythe extends Weapon
if (!stack.hasTagCompound())
return false;
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++)
if (player instanceof EntityPlayerMP)
{
for (int yPos = y - 1; yPos <= y + 1; yPos++)
EntityPlayerMP mplayer = (EntityPlayerMP) player;
World world = player.worldObj;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey("AOEBreaking") || !tags.getBoolean("AOEBreaking"))
{
for (int zPos = z - 1; zPos <= z + 1; zPos++)
tags.setBoolean("AOEBreaking", true);
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
if (!(tags.getBoolean("Broken")))
for (int yPos = y - 1; yPos <= y + 1; yPos++)
{
boolean cancelHarvest = false;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
for (int zPos = z - 1; zPos <= z + 1; zPos++)
{
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)))
Block block = world.getBlock(xPos, yPos, zPos);
for (Material mat : this.materials)
{
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);
}
}
}
if (block != null && mat == block.getMaterial()
&& block.getPlayerRelativeBlockHardness(mplayer, world, x, yPos, z) > 0)
mplayer.theItemInWorldManager.tryHarvestBlock(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);
}