use of net.minecraft.enchantment.Enchantment in project pnc-repressurized by TeamPneumatic.
the class GuiSearcher method getSearchEntries.
/**
* Lazy cache.
* @return
*/
private Stream<SearchEntry> getSearchEntries() {
if (cachedSearchEntries == null) {
NonNullList<ItemStack> itemList = NonNullList.create();
for (Item item : Item.REGISTRY) {
if (item != null && item.getCreativeTab() != null) {
item.getSubItems(item.getCreativeTab(), itemList);
}
}
for (Enchantment enchantment : Enchantment.REGISTRY) {
if (enchantment != null && enchantment.type != null) {
getAllEnchantedBooks(enchantment, itemList);
}
}
cachedSearchEntries = itemList.stream().map(SearchEntry::new).collect(Collectors.toList());
}
return cachedSearchEntries.stream();
}
use of net.minecraft.enchantment.Enchantment in project GregTech by GregTechCE.
the class SolidMaterial method ctAddEnchantmentForTools.
@ZenMethod("addToolEnchantment")
@Method(modid = GTValues.MODID_CT)
public void ctAddEnchantmentForTools(IEnchantment enchantment) {
Enchantment enchantmentType = (Enchantment) enchantment.getDefinition().getInternal();
toolEnchantments.add(new EnchantmentData(enchantmentType, enchantment.getLevel()));
}
use of net.minecraft.enchantment.Enchantment in project SilentGems by SilentChaos512.
the class SilentGemsPlugin method registerItemSubtypes.
@Override
public void registerItemSubtypes(ISubtypeRegistry reg) {
// Tools
for (Item item : new Item[] { ModItems.sword, ModItems.katana, ModItems.scepter, ModItems.tomahawk, ModItems.pickaxe, ModItems.shovel, ModItems.axe, ModItems.paxel, ModItems.hoe, ModItems.sickle, ModItems.bow, ModItems.shield }) {
reg.registerSubtypeInterpreter(item, new ISubtypeInterpreter() {
@Override
public String getSubtypeInfo(ItemStack stack) {
ToolPart[] parts = ToolHelper.getConstructionParts(stack);
if (parts.length == 0)
return "unknown";
return parts[0].getKey();
}
});
}
// Enchantment tokens
reg.registerSubtypeInterpreter(ModItems.enchantmentToken, new ISubtypeInterpreter() {
@Override
public String getSubtypeInfo(ItemStack stack) {
Enchantment ench = ModItems.enchantmentToken.getSingleEnchantment(stack);
if (ench == null)
return "none";
return ench.getName();
}
});
// Chaos Runes
reg.registerSubtypeInterpreter(ModItems.chaosRune, new ISubtypeInterpreter() {
@Override
public String getSubtypeInfo(ItemStack stack) {
ChaosBuff buff = ModItems.chaosRune.getBuff(stack);
if (buff == null)
return "none";
return buff.getKey();
}
});
}
use of net.minecraft.enchantment.Enchantment in project SilentGems by SilentChaos512.
the class ItemEnchantmentToken method addEnchantment.
public ItemStack addEnchantment(ItemStack stack, Enchantment enchantment, int level) {
ItemStack result = StackHelper.safeCopy(stack);
try {
Map<Enchantment, Integer> map = getEnchantments(stack);
map.put(enchantment, level);
setEnchantments(result, map);
} catch (NullPointerException ex) {
String str = "Failed to construct an enchantment token! This will likely result in a broken recipe.\n";
str += "The following is a list of details on the enchantment at fault. Please direct your anger at:\n";
str += getEnchantmentDebugInfo(enchantment);
SilentGems.logHelper.warning(str);
}
return result;
}
use of net.minecraft.enchantment.Enchantment in project SilentGems by SilentChaos512.
the class ItemEnchantmentToken method clGetSubItems.
@Override
protected void clGetSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
List<ItemStack> tokens = Lists.newArrayList();
for (ResourceLocation key : Enchantment.REGISTRY.getKeys()) tokens.add(constructToken(Enchantment.REGISTRY.getObject(key)));
// Sort by type, then enchantment name.
tokens.sort(new Comparator<ItemStack>() {
@Override
public int compare(ItemStack o1, ItemStack o2) {
int k = -getModelKey(o1).compareTo(getModelKey(o2));
if (k == 0) {
Enchantment ench1 = getSingleEnchantment(o1);
Enchantment ench2 = getSingleEnchantment(o2);
if (ench1 == null || ench2 == null)
return 0;
return ench1.getTranslatedName(1).compareTo(ench2.getTranslatedName(1));
}
return k;
}
});
// Empty token first.
tokens.add(0, new ItemStack(this, 1, BLANK_META));
list.addAll(tokens);
}
Aggregations