use of com.builtbroken.mc.api.explosive.IExplosiveHandler in project Engine by VoltzEngine-Project.
the class ExplosiveRegistryClient method getCornerIconFor.
/**
* Gets the corner icon for the explosive item. Defaults
* to using {@link ITexturedExplosiveHandler} if the explosive
* handler implements the interface. If it doesn't then
* the map will be searched for the item.
*
* @param stack
* @return item or missing icon
*/
public static IIcon getCornerIconFor(final ItemStack stack, int pass) {
ItemStack item = stack;
if (item.getItem() instanceof IExplosiveContainerItem) {
item = ((IExplosiveContainerItem) item.getItem()).getExplosiveStack(stack);
}
if (item != null) {
IExplosiveHandler handler = ExplosiveRegistry.get(item);
if (handler instanceof ITexturedExplosiveHandler) {
IIcon icon = ((ITexturedExplosiveHandler) handler).getBottomLeftCornerIcon(item, pass);
if (icon != null) {
return icon;
}
}
ItemStackWrapper wrapper = new ItemStackWrapper(item);
if (EX_CORNER_ICONS.containsKey(wrapper)) {
return EX_CORNER_ICONS.get(wrapper);
}
}
return missing_corner_icon;
}
use of com.builtbroken.mc.api.explosive.IExplosiveHandler in project Engine by VoltzEngine-Project.
the class ExplosiveItemUtility method getSubItems.
/**
* Used to generate a sub item per explosive type in the registry
*
* @param item - item to get sub items for
* @param list - list to add sub item too
*/
@Deprecated
public static void getSubItems(Item item, List list) {
//TODO link in with blacklist
for (IExplosiveHandler ex : ExplosiveRegistry.getExplosives()) {
ItemStack stack = new ItemStack(item);
ExplosiveItemUtility.setExplosive(stack, ex);
ExplosiveItemUtility.setSize(stack, 1);
list.add(stack);
}
}
use of com.builtbroken.mc.api.explosive.IExplosiveHandler in project Engine by VoltzEngine-Project.
the class ExplosiveRegistry method unregisterExplosiveItem.
/**
* Removes an item from the explosive item system. Normally
* only used for JUnit testing but still functions in any
* other condition.
*
* @param stack - item to remove
* @return true if the item was registered
*/
public static boolean unregisterExplosiveItem(ItemStack stack) {
ItemStackWrapper wrapper = new ItemStackWrapper(stack);
if (itemToExplosive.containsKey(wrapper)) {
IExplosiveHandler ex = itemToExplosive.get(wrapper);
itemToExplosive.remove(wrapper);
if (explosiveToItems.containsKey(ex)) {
List<ItemStackWrapper> list = explosiveToItems.get(ex);
if (list != null) {
if (list.contains(wrapper)) {
list.remove(wrapper);
}
explosiveToItems.put(ex, list);
}
}
if (itemToExplosiveSize.containsKey(wrapper)) {
itemToExplosiveSize.remove(stack);
}
return true;
}
return false;
}
use of com.builtbroken.mc.api.explosive.IExplosiveHandler in project Engine by VoltzEngine-Project.
the class TestExplosiveRegistry method testRegisterExplosiveItem.
@Test
public void testRegisterExplosiveItem() {
setUpForEntireClass();
IExplosiveHandler TNT = new ExplosiveHandlerGeneric("tnt", BlastBasic.class, 1);
ExplosiveRegistry.registerOrGetExplosive(References.DOMAIN, "TNT", TNT);
ExplosiveRegistry.registerExplosiveItem(new ItemStack(Blocks.tnt), ExplosiveRegistry.get("TNT"), 2);
assertTrue(ExplosiveRegistry.get("TNT") == TNT);
assertTrue(ExplosiveRegistry.get(new ItemStack(Blocks.tnt)) == TNT);
assertEquals(ExplosiveRegistry.getExplosiveSize(new ItemStack(Blocks.tnt)), 2.0);
assertTrue(ExplosiveRegistry.getItems(TNT).contains(new ItemStackWrapper(new ItemStack(Blocks.tnt))));
ItemStack stack = new ItemStack(explosive);
explosive.setExplosive(stack, TNT, 3, null);
ExplosiveRegistry.registerExplosiveItem(stack);
assertTrue(ExplosiveRegistry.get(stack) == TNT);
assertTrue(ExplosiveRegistry.getExplosiveSize(stack) == 3);
assertTrue(ExplosiveRegistry.getItems(TNT).contains(new ItemStackWrapper(stack)));
}
Aggregations