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:
GJ
2013-10-31 13:25:06 -04:00
parent 1785bab504
commit de3c4f8fd7
10 changed files with 65 additions and 24 deletions

View File

@ -22,15 +22,10 @@ public class Mining {
*/
protected static int getBlockXp(BlockState blockState) {
Material blockType = blockState.getType();
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType);
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
if (xp == 0) {
if (blockType == Material.GLOWING_REDSTONE_ORE) {
xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
}
else if (ModUtils.isCustomMiningBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
}
if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
}
return xp;

View File

@ -1,10 +1,12 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.ModUtils;
public class Smelting {
// The order of the values is extremely important, a few methods depend on it to work properly
@ -46,11 +48,13 @@ public class Smelting {
public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel();
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
protected static int getResourceXp(Material resourceType) {
int xp = ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType);
protected static int getResourceXp(ItemStack smelting) {
Material resourceType = smelting.getType();
if (resourceType == Material.GLOWING_REDSTONE_ORE) {
xp = ExperienceConfig.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE);
int xp = ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
if (xp == 0 && ModUtils.isCustomOreBlock(smelting)) {
xp = ModUtils.getCustomSmeltingBlock(smelting).getSmeltingXpGain();
}
return xp;

View File

@ -81,10 +81,10 @@ public class SmeltingManager extends SkillManager {
return (int) (burnTime * burnModifier);
}
public ItemStack smeltProcessing(Material resourceType, ItemStack result) {
public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) {
Player player = getPlayer();
applyXpGain(Smelting.getResourceXp(resourceType));
applyXpGain(Smelting.getResourceXp(smelting));
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
ItemStack newResult = result.clone();