mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Smelting now works with custom ores.
Also fixed exploit where smelting XP could be awarded for some non-smeltable materials.
This commit is contained in:
@ -1,14 +1,22 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Coal;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -514,7 +522,7 @@ public class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
return Config.getInstance().getBlockModsEnabled() && CustomBlockConfig.getInstance().isCustomOre(item.getData());
|
||||
}
|
||||
}
|
||||
|
||||
@ -525,6 +533,8 @@ public class ItemUtils {
|
||||
|
||||
switch (item.getType()) {
|
||||
case COAL:
|
||||
return ((Coal) item.getData()).getType() == CoalType.COAL;
|
||||
|
||||
case DIAMOND:
|
||||
case REDSTONE:
|
||||
case GOLD_INGOT:
|
||||
@ -537,6 +547,14 @@ public class ItemUtils {
|
||||
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
|
||||
|
||||
default:
|
||||
List<Recipe> recipeList = mcMMO.p.getServer().getRecipesFor(item);
|
||||
|
||||
for (Recipe recipe : recipeList) {
|
||||
if (recipe instanceof FurnaceRecipe) {
|
||||
return Config.getInstance().getBlockModsEnabled() && CustomBlockConfig.getInstance().isCustomOre(((FurnaceRecipe) recipe).getInput().getData());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,9 @@ import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
|
||||
public final class ModUtils {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
|
||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||
private static boolean customEntitiesEnabled = configInstance.getEntityModsEnabled();
|
||||
private static boolean customToolsEnabled = Config.getInstance().getToolModsEnabled();
|
||||
private static boolean customBlocksEnabled = Config.getInstance().getBlockModsEnabled();
|
||||
private static boolean customEntitiesEnabled = Config.getInstance().getEntityModsEnabled();
|
||||
|
||||
private ModUtils() {}
|
||||
|
||||
@ -57,6 +55,10 @@ public final class ModUtils {
|
||||
return CustomBlockConfig.getInstance().getCustomBlock(blockState.getData());
|
||||
}
|
||||
|
||||
public static CustomBlock getCustomSmeltingBlock(ItemStack smelting) {
|
||||
return CustomBlockConfig.getInstance().getCustomBlock(smelting.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a woodcutting block.
|
||||
*
|
||||
@ -137,6 +139,16 @@ public final class ModUtils {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomOre(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an ore block.
|
||||
*
|
||||
* @param item The ItemStack of the block to check
|
||||
* @return true if the block represents an ore, false otherwise
|
||||
*/
|
||||
public static boolean isCustomOreBlock(ItemStack item) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomOre(item.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
|
Reference in New Issue
Block a user