Smashing, Thaumcrafting, and Fixing

Fixes #4
This commit is contained in:
Jeremy Diamond committed 2015-07-27 16:56:52 -07:00
1 parent 9a6b46add2
commit 50d3ba4636
6 files changed
+76 -21

No files matched your search

@@ -10,6 +10,7 @@ package fox.spiteful.avaritia.items.tools;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
@@ -17,19 +18,23 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.Random;
public class ToolHelper {
public static Material[] materialsPick = new Material[]{ Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil };
public static Material[] materialsShovel = new Material[]{ Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
public static Material[] materialsAxe = new Material[]{ Material.coral, Material.leaves, Material.plants, Material.wood };
private static Random randy = new Random();
public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int xs, int ys, int zs, int xe, int ye, int ze, Block block, Material[] materialsListing, boolean silk, int fortune, boolean dispose) {
float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z);
for(int x1 = xs; x1 < xe; x1++)
for(int y1 = ys; y1 < ye; y1++)
for(int z1 = zs; z1 < ze; z1++)
removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, x, y, z, block, materialsListing, silk, fortune, blockHardness, dispose);
removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, block, materialsListing, silk, fortune, blockHardness, dispose);
}
public static boolean isRightMaterial(Material material, Material[] materialsListing) {
@@ -40,11 +45,7 @@ public class ToolHelper {
return false;
}
public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int bx, int by, int bz, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose) {
removeBlockWithDrops(player, stack, world, x, y, z, bx, by, bz, block, materialsListing, silk, fortune, blockHardness, dispose, true);
}
public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int bx, int by, int bz, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose, boolean particles) {
public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose) {
if(!world.blockExists(x, y, z))
return;
@@ -66,13 +67,20 @@ public class ToolHelper {
if(blk.removedByPlayer(world, player, x, y, z, true)) {
blk.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
if(!dispose)
if(!dispose) {
if(blk.getPlayerRelativeBlockHardness(player, world, x, y, z) < 0 && blk.quantityDropped(randy) == 0){
ItemStack drop = blk.getPickBlock(raytraceFromEntity(world, player, true, 10), world, x, y, z, player);
if(drop == null)
drop = new ItemStack(blk, 1, meta);
dropItem(drop, world, x, y, z);
}
blk.harvestBlock(world, player, x, y, z, localMeta);
}
}
} else world.setBlockToAir(x, y, z);
if(particles && !world.isRemote /*&& ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool*/)
if(!world.isRemote /*&& ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool*/)
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12));
}
}
@@ -80,7 +88,7 @@ public class ToolHelper {
/**
* @author mDiyo
*/
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) {
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean wut, double range) {
float f = 1.0F;
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
@@ -98,6 +106,16 @@ public class ToolHelper {
float f8 = f3 * f5;
double d3 = range;
Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
return world.rayTraceBlocks(vec3, vec31, par3);
return world.rayTraceBlocks(vec3, vec31, wut);
}
private static void dropItem(ItemStack drop, World world, int x, int y, int z){
float f = 0.7F;
double d0 = (double)(randy.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d1 = (double)(randy.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d2 = (double)(randy.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double)x + d0, (double)y + d1, (double)z + d2, drop);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
}