mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 04:09:40 +00:00
Reverting "Fix some block breaking problems".
This commit is contained in:
1 parent
c43bbf10a5
commit
ea634c139f
7 files changed
+570
-164
No files matched your search
@@ -7,7 +7,6 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -248,26 +247,56 @@ public class Battleaxe extends HarvestTool
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
World world = player.worldObj;
|
||||
final Block wood = world.getBlock(x, y, z);
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
for (int yPos = y + 1; yPos < y + 9; yPos++)
|
||||
{
|
||||
EntityPlayerMP mplayer = (EntityPlayerMP)player;
|
||||
World world = player.worldObj;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey("AOEBreaking") || !tags.getBoolean("AOEBreaking"))
|
||||
Block block = world.getBlock(x, yPos, z);
|
||||
if (!(tags.getBoolean("Broken")) && block != null && block.getMaterial() == Material.wood)
|
||||
{
|
||||
tags.setBoolean("AOEBreaking", true);
|
||||
for (int yPos = y + 1; yPos < y + 9; yPos++)
|
||||
Block localblock = world.getBlock(x, yPos, z);
|
||||
int localMeta = world.getBlockMetadata(x, yPos, z);
|
||||
int hlvl = block.getHarvestLevel(meta);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
Block block = world.getBlock(x, yPos, z);
|
||||
if (block != null && block.getMaterial() == Material.wood
|
||||
&& block.getPlayerRelativeBlockHardness(mplayer, world, x, yPos, z) > 0)
|
||||
mplayer.theItemInWorldManager.tryHarvestBlock(x, yPos, z);
|
||||
else
|
||||
break;
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, yPos, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && block.getMaterial() == Material.wood)
|
||||
{
|
||||
localMeta = world.getBlockMetadata(x, yPos, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (block.removedByPlayer(world, player, x, yPos, z))
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, x, yPos, z, localMeta);
|
||||
}
|
||||
block.harvestBlock(world, player, x, yPos, z, localMeta);
|
||||
block.onBlockHarvested(world, x, yPos, z, localMeta, player);
|
||||
onBlockDestroyed(stack, world, block, x, yPos, z, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, x, yPos, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tags.setBoolean("AOEBreaking", false);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(wood) + (meta << 12));
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
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;
|
||||
@@ -142,54 +141,107 @@ public class Excavator extends HarvestTool
|
||||
return false;
|
||||
|
||||
World world = player.worldObj;
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 5.0D);
|
||||
if (mop != null && player instanceof EntityPlayerMP)
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (block == null)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
boolean validStart = false;
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
EntityPlayerMP mplayer = (EntityPlayerMP) player;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey("AOEBreaking") || !tags.getBoolean("AOEBreaking"))
|
||||
if (materials[iter] == block.getMaterial())
|
||||
{
|
||||
tags.setBoolean("AOEBreaking", true);
|
||||
validStart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 5.0D);
|
||||
if (mop == null || !validStart)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
Block localblock = world.getBlock(xPos, yPos, zPos);
|
||||
block = localblock;
|
||||
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = block.getHarvestLevel(meta);
|
||||
float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
for (Material mat : this.materials)
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (block != null && mat == block.getMaterial()
|
||||
&& block.getPlayerRelativeBlockHardness(mplayer, world, x, yPos, z) > 0)
|
||||
mplayer.theItemInWorldManager.tryHarvestBlock(xPos, yPos, zPos);
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && !(localHardness < 0))
|
||||
{
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.getMaterial())
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (block.removedByPlayer(world, player, xPos, yPos, zPos))
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
|
||||
}
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
|
||||
block.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localblock, xPos, yPos, zPos, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tags.setBoolean("AOEBreaking", false);
|
||||
}
|
||||
}
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -236,67 +235,115 @@ public class Hammer extends HarvestTool
|
||||
return false;
|
||||
|
||||
World world = player.worldObj;
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 4.5D);
|
||||
if (mop != null && player instanceof EntityPlayerMP)
|
||||
final Block block = world.getBlock(x, y, z);
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (block == null)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
boolean validStart = false;
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
EntityPlayerMP mplayer = (EntityPlayerMP) player;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey("AOEBreaking") || !tags.getBoolean("AOEBreaking"))
|
||||
if (materials[iter] == block.getMaterial())
|
||||
{
|
||||
tags.setBoolean("AOEBreaking", true);
|
||||
int toolLevel = tags.getInteger("HarvestLevel");
|
||||
Block centerBlock = world.getBlock(x, y, z);
|
||||
float centerBlockHardness = centerBlock.getBlockHardness(world, x, y, z);
|
||||
validStart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
if (block == Blocks.monster_egg)
|
||||
validStart = true;
|
||||
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 4.5D);
|
||||
if (mop == null || !validStart)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int toolLevel = tags.getInteger("HarvestLevel");
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
int meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
float blockHardness = block.getBlockHardness(world, xPos, yPos, zPos);
|
||||
boolean isCenter = ((xPos == x) && (yPos == y) && (zPos == z));
|
||||
Block localBlock = world.getBlock(xPos, yPos, zPos);
|
||||
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = -1;
|
||||
if (localBlock.getHarvestTool(localMeta) != null && localBlock.getHarvestTool(localMeta).equals(this.getHarvestType()))
|
||||
hlvl = localBlock.getHarvestLevel(localMeta);
|
||||
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
|
||||
|
||||
if (!block.isToolEffective("pickaxe", meta) || (block.getHarvestLevel(meta)) > toolLevel || (tags.getBoolean("Broken") && !isCenter)
|
||||
|| (blockHardness - 1.5) > centerBlockHardness || (!centerBlock.isToolEffective("pickaxe", meta) && !isCenter))
|
||||
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
continue;
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
for (Material mat : this.materials)
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && mat == block.getMaterial()
|
||||
&& block.getPlayerRelativeBlockHardness(mplayer, world, x, yPos, z) > 0)
|
||||
mplayer.theItemInWorldManager.tryHarvestBlock(xPos, yPos, zPos);
|
||||
if (localBlock != null && !(localHardness < 0))
|
||||
{
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == localBlock.getMaterial() || localBlock == Blocks.monster_egg)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
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 (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tags.setBoolean("AOEBreaking", false);
|
||||
}
|
||||
}
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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;
|
||||
@@ -136,81 +135,150 @@ public class LumberAxe extends HarvestTool
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
World world = player.worldObj;
|
||||
final Block wood = world.getBlock(x, y, z);
|
||||
;
|
||||
if (wood == null)
|
||||
{
|
||||
EntityPlayerMP mplayer = (EntityPlayerMP) player;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey("AOEBreaking") || !tags.getBoolean("AOEBreaking"))
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge)
|
||||
{
|
||||
int height = y;
|
||||
boolean foundTop = false;
|
||||
do
|
||||
{
|
||||
tags.setBoolean("AOEBreaking", true);
|
||||
World world = player.worldObj;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block.isWood(world, x, y, z))
|
||||
height++;
|
||||
Block block = world.getBlock(x, height, z);
|
||||
if (block != wood)
|
||||
{
|
||||
int height = y;
|
||||
while (true)
|
||||
height--;
|
||||
foundTop = true;
|
||||
}
|
||||
} while (!foundTop);
|
||||
|
||||
int numLeaves = 0;
|
||||
if (height - y < 50)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int yPos = height - 1; yPos <= height + 1; yPos++)
|
||||
{
|
||||
height++;
|
||||
if (block != world.getBlock(x, height, z))
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
height--;
|
||||
break;
|
||||
Block leaves = world.getBlock(xPos, yPos, zPos);
|
||||
if (leaves != null && leaves.isLeaves(world, xPos, yPos, zPos))
|
||||
numLeaves++;
|
||||
}
|
||||
}
|
||||
|
||||
int numLeaves = 0;
|
||||
if (height - y < 50)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
for (int yPos = height - 1; yPos <= height + 1; yPos++)
|
||||
{
|
||||
Block leaf = world.getBlock(xPos, yPos, zPos);
|
||||
if (leaf != null && leaf.isLeaves(world, xPos, yPos, zPos))
|
||||
numLeaves++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (numLeaves > 3)
|
||||
breakTree(world, x, y, z, stack, tags, block, world.getBlockMetadata(x, y, z), mplayer);
|
||||
else
|
||||
destroyWood(world, x, y, z, stack, tags, mplayer);
|
||||
}
|
||||
else if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
destroyWood(world, x, y, z, stack, tags, mplayer);
|
||||
}
|
||||
tags.setBoolean("AOEBreaking", false);
|
||||
}
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (numLeaves > 3)
|
||||
breakTree(world, x, y, z, stack, tags, wood, meta, player);
|
||||
else
|
||||
destroyWood(world, x, y, z, stack, tags, player);
|
||||
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(wood) + (meta << 12));
|
||||
}
|
||||
else if (wood.getMaterial() == Material.wood)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
destroyWood(world, x, y, z, stack, tags, player);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(wood) + (meta << 12));
|
||||
}
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, Block bID, int meta, EntityPlayerMP player)
|
||||
void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, Block bID, int meta, EntityPlayer player)
|
||||
{
|
||||
Block block;
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int yPos = y; yPos <= y + 1; yPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
if (bID == block && world.getBlockMetadata(xPos, yPos, zPos) == meta)
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
if (block.getPlayerRelativeBlockHardness(player, world, x, yPos, z) > 0)
|
||||
player.theItemInWorldManager.tryHarvestBlock(x, yPos, z);
|
||||
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
|
||||
Block localblock = world.getBlock(xPos, yPos, zPos);
|
||||
if (bID == localblock)
|
||||
{
|
||||
block = localblock;
|
||||
meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = block.getHarvestLevel(meta);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (cancelHarvest)
|
||||
{
|
||||
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (localblock == bID && world.getBlockMetadata(xPos, yPos, zPos) % 4 == meta % 4)
|
||||
{
|
||||
/*
|
||||
* world.setBlock(xPos, yPos, zPos, 0,
|
||||
* 0, 3); if
|
||||
* (!player.capabilities.isCreativeMode)
|
||||
* {
|
||||
* Block.blocksList[bID].harvestBlock(world
|
||||
* , player, xPos, yPos, zPos, meta);
|
||||
* onBlockDestroyed(stack, world, bID,
|
||||
* xPos, yPos, zPos, player); }
|
||||
*/
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (block.removedByPlayer(world, player, xPos, yPos, zPos))
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta);
|
||||
}
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
|
||||
onBlockDestroyed(stack, world, localblock, xPos, yPos, zPos, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
|
||||
}
|
||||
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
|
||||
}
|
||||
/*
|
||||
* else { Block leaves =
|
||||
* Block.blocksList[localID]; if (leaves !=
|
||||
* null && leaves.isLeaves(world, xPos,
|
||||
* yPos, zPos)) {
|
||||
* WorldHelper.setBlockToAir(world, xPos,
|
||||
* yPos, zPos); if
|
||||
* (!player.capabilities.isCreativeMode) {
|
||||
* Block.blocksList[bID].harvestBlock(world,
|
||||
* player, xPos, yPos, zPos, meta);
|
||||
* onBlockDestroyed(stack, world, bID, xPos,
|
||||
* yPos, zPos, player); } } }
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void destroyWood (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, EntityPlayerMP player)
|
||||
void destroyWood (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, EntityPlayer player)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
@@ -218,10 +286,36 @@ public class LumberAxe extends HarvestTool
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
if (block != null && block.getMaterial() == Material.wood
|
||||
&& block.getPlayerRelativeBlockHardness(player, world, xPos, yPos, zPos) > 0)
|
||||
player.theItemInWorldManager.tryHarvestBlock(xPos, yPos, zPos);
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
int meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = block.getHarvestLevel(meta);
|
||||
|
||||
if (block != null && block.getMaterial() == Material.wood)
|
||||
{
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
// TODO harvestBlock
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||
onBlockDestroyed(stack, world, block, xPos, yPos, zPos, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,44 @@ public abstract class DualHarvestTool extends HarvestTool
|
||||
{
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
if (block == null || block == Blocks.air)
|
||||
return false;
|
||||
int hlvl = -1;
|
||||
int shlvl = -1;
|
||||
if (block.getHarvestTool(meta) == null || block.getHarvestTool(meta).equals(getHarvestType()))
|
||||
hlvl = block.getHarvestLevel(meta);
|
||||
if (block.getHarvestTool(meta) == null || block.getHarvestTool(meta).equals(getSecondHarvestType()))
|
||||
shlvl = block.getHarvestLevel(meta);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && shlvl <= tags.getInteger("HarvestLevel2"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
return cancelHarvest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, block, x, y, z, player);
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
|
||||
@@ -21,6 +21,96 @@ public abstract class HarvestTool extends ToolCore
|
||||
{
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
// Block block = Block.blocksList[bID];
|
||||
if (block == null || block == Blocks.air)
|
||||
return false;
|
||||
int hlvl = -1;
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
Block localBlock = world.getBlock(x, y, z);
|
||||
int localMeta = world.getBlockMetadata(x, y, z);
|
||||
if (block.getHarvestTool(meta) != null && block.getHarvestTool(meta).equals(this.getHarvestType()))
|
||||
hlvl = block.getHarvestLevel(meta);
|
||||
int toolLevel = tags.getInteger("HarvestLevel");
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z);
|
||||
|
||||
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (localBlock != null && !(localHardness < 0))
|
||||
{
|
||||
|
||||
boolean isEffective = false;
|
||||
|
||||
for (int iter = 0; iter < getEffectiveMaterials().length; iter++)
|
||||
{
|
||||
if (getEffectiveMaterials()[iter] == localBlock.getMaterial() || localBlock == Blocks.monster_egg)
|
||||
{
|
||||
isEffective = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (localBlock.getMaterial().isToolNotRequired())
|
||||
{
|
||||
isEffective = true;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (isEffective)
|
||||
{
|
||||
if (localBlock.removedByPlayer(world, player, x, y, z))
|
||||
{
|
||||
localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
|
||||
}
|
||||
localBlock.harvestBlock(world, player, x, y, z, localMeta);
|
||||
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localBlock, x, y, z, player);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
|
||||
Reference in new issue
Block a user