1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-21 03:03:02 +01:00

Mod support - XP gain & double drops should now work for custom blocks

EXCEPT Woodcutting. Custom excavation blocks will also never drop
treasures.
This commit is contained in:
GJ
2012-05-17 00:24:33 -04:00
parent 6cbf87b52c
commit 5645bf7982
15 changed files with 395 additions and 45 deletions

View File

@@ -1,37 +1,19 @@
package com.gmail.nossr50.util;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.config.mods.LoadCustomArmor;
import com.gmail.nossr50.config.mods.LoadCustomTools;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.datatypes.mods.CustomTool;
public class ModChecks {
private static LoadCustomTools toolInstance = LoadCustomTools.getInstance();
private static LoadCustomArmor armorInstance = LoadCustomArmor.getInstance();
/**
* Check if this custom tool can use abilities.
*
* @param item The custom item to check
* @return true if the tool can use abilities, false otherwise
*/
public static boolean toolAbilityEnabled(ItemStack item) {
int id = item.getTypeId();
if (!toolInstance.customIDs.contains(id)) {
return false;
}
for (CustomItem tool : toolInstance.customItems) {
if (tool.getItemID() == id) {
return ((CustomTool) tool).isAbilityEnabled();
}
}
return false;
}
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
/**
* Get the custom armor associated with an item.
@@ -76,4 +58,24 @@ public class ModChecks {
return null;
}
/**
* Get the custom block associated with an block.
*
* @param block The block to check
* @return the armor if it exists, null otherwise
*/
public static CustomBlock getCustomBlock(Block block) {
if (!blocksInstance.customItems.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
return null;
}
for (CustomBlock b : blocksInstance.customBlocks) {
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
return b;
}
}
return null;
}
}