mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-21 12:42:13 +00:00
1 parent
9a6b46add2
commit
50d3ba4636
6 files changed
+76
-21
No files matched your search
@@ -3,7 +3,9 @@ package fox.spiteful.avaritia;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import fox.spiteful.avaritia.items.ItemArmorInfinity;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import fox.spiteful.avaritia.items.tools.ItemPickaxeInfinity;
|
||||
import fox.spiteful.avaritia.items.tools.ItemSwordInfinity;
|
||||
import fox.spiteful.avaritia.items.tools.ToolHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -35,16 +37,31 @@ public class LudicrousEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerMine(PlayerInteractEvent event) {
|
||||
//Lumberjack.log(Level.INFO, event.block.getLocalizedName());
|
||||
if(event.face == -1 || event.world.isRemote || event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK || event.entityPlayer.getHeldItem() == null)
|
||||
if(event.face == -1 || event.world.isRemote || event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK || event.entityPlayer.getHeldItem() == null || event.entityPlayer.capabilities.isCreativeMode)
|
||||
return;
|
||||
Block block = event.world.getBlock(event.x, event.y, event.z);
|
||||
int meta = event.world.getBlockMetadata(event.x, event.y, event.z);
|
||||
if(block.getBlockHardness(event.entityPlayer.worldObj, event.x, event.y, event.z) <= -1 &&
|
||||
event.entityPlayer.getHeldItem().getItem() == LudicrousItems.infinity_pickaxe &&
|
||||
(block.getMaterial() == Material.rock || block.getMaterial() == Material.iron)){
|
||||
dropItem(new ItemStack(block, 1, event.world.getBlockMetadata(event.x, event.y, event.z)), event.entityPlayer.worldObj, event.x, event.y, event.z);
|
||||
event.entityPlayer.worldObj.setBlockToAir(event.x, event.y, event.z);
|
||||
event.world.playSoundEffect(event.x, event.y, event.z, block.stepSound.getBreakSound(), block.stepSound.getVolume(), block.stepSound.getPitch());
|
||||
|
||||
if(event.entityPlayer.getHeldItem().getTagCompound() != null && event.entityPlayer.getHeldItem().getTagCompound().getBoolean("hammer")) {
|
||||
LudicrousItems.infinity_pickaxe.onBlockStartBreak(event.entityPlayer.getHeldItem(), event.x, event.y, event.z, event.entityPlayer);
|
||||
}
|
||||
else {
|
||||
|
||||
if(block.quantityDropped(randy) == 0) {
|
||||
ItemStack drop = block.getPickBlock(ToolHelper.raytraceFromEntity(event.world, event.entityPlayer, true, 10),
|
||||
event.world, event.x, event.y, event.z, event.entityPlayer);
|
||||
if(drop == null)
|
||||
drop = new ItemStack(block, 1, meta);
|
||||
dropItem(drop, event.entityPlayer.worldObj, event.x, event.y, event.z);
|
||||
}
|
||||
else
|
||||
block.harvestBlock(event.world, event.entityPlayer, event.x, event.y, event.z, meta);
|
||||
event.entityPlayer.worldObj.setBlockToAir(event.x, event.y, event.z);
|
||||
event.world.playAuxSFX(2001, event.x, event.y, event.z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ public class Compat {
|
||||
|
||||
if(mfr){
|
||||
try {
|
||||
Item ponk = getItem("MineFactoryReloaded", "mfr.pinkslime");
|
||||
Item ponk = getItem("MineFactoryReloaded", "pinkslime");
|
||||
ItemStack pank = new ItemStack(ponk, 1, 1);
|
||||
Grinder.catalyst.getInput().add(pank);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Mincer {
|
||||
// here's where all the food magic goes on
|
||||
private static String[] sacredCropNames = new String[]{"cropWheat", "cropCarrot", "cropPotato", "cropApple", "cropMelon", "cropPumpkin", "cropCactus", "cropMushroomRed", "cropMushroomBrown"};
|
||||
private static String[] forbiddenCropNames = new String[] {"cropEdibleroot", "cropWhitemushroom", "cropBeet", "cropCotton"};
|
||||
private static String[] knownMeatEntries = new String[]{"nuggetMeat", "ingotMeat", "dustMeat", "rawMutton"};
|
||||
private static String[] knownMeatEntries = new String[]{"ingotMeatRaw", "dustMeat", "rawMutton"};
|
||||
private static List<ItemStack> knownMeats = new ArrayList<ItemStack>();
|
||||
|
||||
static {
|
||||
@@ -117,7 +117,7 @@ public class Mincer {
|
||||
return b.count > a.count ? 1 : -1;
|
||||
}
|
||||
|
||||
return randy.nextBoolean() ? 1 : -1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -24,12 +24,18 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import thaumcraft.api.IGoggles;
|
||||
import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.nodes.IRevealer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@Optional.Interface(iface = "thaumcraft.api.IGoggles", modid="Thaumcraft")
|
||||
public class ItemArmorInfinity extends ItemArmor implements IGoggles {
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "thaumcraft.api.IGoggles", modid = "Thaumcraft"),
|
||||
@Optional.Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft")
|
||||
})
|
||||
public class ItemArmorInfinity extends ItemArmor implements IGoggles, IRevealer, IVisDiscountGear {
|
||||
|
||||
public static final ArmorMaterial infinite_armor = EnumHelper.addArmorMaterial("infinity", 9999, new int[]{6, 16, 12, 6}, 1000);
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -126,4 +132,18 @@ public class ItemArmorInfinity extends ItemArmor implements IGoggles {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
@Override
|
||||
public boolean showNodes(ItemStack itemStack, EntityLivingBase entityLivingBase){
|
||||
if(armorType == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
@Override
|
||||
public int getVisDiscount(ItemStack itemStack, EntityPlayer entityPlayer, Aspect aspect){
|
||||
return 100;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class ItemPickaxeInfinity extends ItemPickaxe {
|
||||
private static final ToolMaterial opPickaxe = EnumHelper.addToolMaterial("INFINITY_PICKAXE", 32, 9999, 9999F, 5.0F, 200);
|
||||
private IIcon hammer;
|
||||
|
||||
private static final Material[] MATERIALS = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
|
||||
public static final Material[] MATERIALS = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
|
||||
|
||||
public ItemPickaxeInfinity(){
|
||||
super(opPickaxe);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user