Skip to content

Commit

Permalink
Added more detection for modded stone
Browse files Browse the repository at this point in the history
  • Loading branch information
iguanaman committed Dec 12, 2013
1 parent 405b2f0 commit b330e30
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/iguanaman/iguanatweakstconstruct/HarvestLevelTweaks.java
Expand Up @@ -23,7 +23,7 @@ public class HarvestLevelTweaks {

// HarvestLevels
public static String[][] oreDictLevels = {
{},
{"stone", "cobblestone"},
{"Copper", "Coal", "Tetrahedrite", "Aluminum", "Aluminium", "NaturalAluminum", "AluminumBrass", "Shard", "Bauxite", "Zinc"},
{"Iron", "Pyrite", "Lead", "Silver"},
{"Tin", "Cassiterite", "Gold", "Lapis", "Steel", "Galena", "Nickel", "Invar", "Electrum", "Sphalerite"},
Expand Down Expand Up @@ -177,6 +177,8 @@ public static void init()
if (i > 1) level += boostMod;

for (String materialName : oreDictLevels[i]) {
for (ItemStack oreStack : OreDictionary.getOres(materialName.toLowerCase())) SetHarvestLevel(oreStack, level);
for (ItemStack oreStack : OreDictionary.getOres(materialName.toLowerCase() + "Bricks")) SetHarvestLevel(oreStack, level);
for (ItemStack oreStack : OreDictionary.getOres("ore" + materialName)) SetHarvestLevel(oreStack, level);
for (ItemStack oreStack : OreDictionary.getOres("oreNether" + materialName)) SetHarvestLevel(oreStack, level);
for (ItemStack oreStack : OreDictionary.getOres("block" + materialName)) SetHarvestLevel(oreStack, level);
Expand Down
@@ -1,5 +1,8 @@
package iguanaman.iguanatweakstconstruct.modifiers;

import java.util.Arrays;
import java.util.List;

import iguanaman.iguanatweakstconstruct.IguanaLevelingLogic;
import iguanaman.iguanatweakstconstruct.IguanaLog;
import cpw.mods.fml.common.FMLLog;
Expand All @@ -10,6 +13,9 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
Expand Down Expand Up @@ -40,34 +46,67 @@ public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, i
{
if (!(entity instanceof EntityPlayer)) return false;

String[] toolTypes = IguanaLevelingLogic.getHarvestType(tool);
List<String> toolTypes = Arrays.asList(IguanaLevelingLogic.getHarvestType(tool));

if (toolTypes == null) return false;

NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
int bID = entity.worldObj.getBlockId(x, y, z);
Block block = Block.blocksList[bID];
if (block == null || bID < 1 || bID > 4095 || block instanceof BlockLeaves) return false;
int meta = entity.worldObj.getBlockMetadata(x, y, z);

//IguanaLog.log("checking allow");
boolean allow = false;
Block block = Block.blocksList[bID];
if (block == null || block instanceof BlockLeaves) return false;

for (String toolType : toolTypes)
{
//IguanaLog.log("checking if " + toolType + " allowed");
if (MinecraftForge.getBlockHarvestLevel(block, meta, toolType) >= 0)
{
//IguanaLog.log(toolType + "allowed");
allow = true;
break;
addBlockBreakXp(stack, entity);
return false;
}
}

if (toolTypes.contains("pickaxe"))
{
for (Block effectiveBlock : ItemPickaxe.blocksEffectiveAgainst)
{
if (block.getClass().isInstance(effectiveBlock))
{
addBlockBreakXp(stack, entity);
return false;
}
}
}

if (toolTypes.contains("axe"))
{
for (Block effectiveBlock : ItemAxe.blocksEffectiveAgainst)
{
if (block.getClass().isInstance(effectiveBlock))
{
addBlockBreakXp(stack, entity);
return false;
}
}
}

if (toolTypes.contains("shovel"))
{
for (Block effectiveBlock : ItemSpade.blocksEffectiveAgainst)
{
if (block.getClass().isInstance(effectiveBlock))
{
addBlockBreakXp(stack, entity);
return false;
}
}
}

// add the xp
if (allow) IguanaLevelingLogic.addXP(stack, (EntityPlayer)entity, 1L);

return false;
}

public void addBlockBreakXp(ItemStack stack, EntityLivingBase entity)
{
IguanaLevelingLogic.addXP(stack, (EntityPlayer)entity, 1L);
}
}

0 comments on commit b330e30

Please sign in to comment.