-
Notifications
You must be signed in to change notification settings - Fork 5
/
ModItemsTemplate.java
119 lines (86 loc) · 4.08 KB
/
ModItemsTemplate.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package heroicarmory.init;
import heroicarmory.Reference;
import heroicarmory.items.ItemBasic;
import heroicarmory.items.Sword;
import heroicarmory.ModConfig;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.util.ResourceLocation;
import net.minecraft.init.Items;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootEntry;
import net.minecraft.world.storage.loot.LootEntryTable;
import net.minecraft.world.storage.loot.LootEntryItem;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraft.world.storage.loot.RandomValueRange;
import net.minecraft.world.storage.loot.conditions.KilledByPlayer;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraft.world.storage.loot.functions.LootFunction;
import net.minecraft.world.storage.loot.functions.SetCount;
import net.minecraft.world.storage.loot.functions.SetDamage;
import net.minecraftforge.event.LootTableLoadEvent;
import java.util.ArrayList;
import static java.lang.Math.ceil;
@Mod.EventBusSubscriber(modid=Reference.MODID)
public class ModItems {
//ITEM VARIABLES====================================================================================================
/*{{ITEMVARIABLES}}*/
//MATERIAL VARIABLES================================================================================================
/*{{MATERIALVARIABLES}}*/
//creative tab
static final CreativeTabs tabHeroicArmory = new CreativeTabs("tabHeroicArmory") {
@Override
public ItemStack getTabIconItem() {
return new ItemStack(lotrNarsil);
}
};
public static void init() {
//CREATE ITEMS==================================================================================================
/*{{CREATEITEMS}}*/
//ASSIGN CREATIVE TAB===========================================================================================
/*{{CREATIVETAB}}*/
//Loot Tables
LootTableList.register(new ResourceLocation("heroicarmory", "loot"));
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
//REGISTER ITEMS================================================================================================
/*{{REGISTERITEMS}}*/
}
@SubscribeEvent
public static void registerRenders(ModelRegistryEvent event) {
//REGISTER RENDERS==============================================================================================
/*{{REGISTERRENDERS}}*/
}
private static void registerRender(Item item) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
//loot tables
@SubscribeEvent
public static void lootLoad(LootTableLoadEvent evt) {
String name = evt.getName().toString();
if (name.contains("chest")) {
//return if not a minecraft chest
if (ModConfig.includeModChests == false && name.contains("minecraft:") == false) {
System.out.println("skipping loot table '" + name + "' because mod chests are disabled in config");
return;
}
System.out.println("added loot to loot table '" + name + "'");
ArrayList<LootEntryItem> entries = new ArrayList<LootEntryItem>();
/*{{LOOTTABLEMAIN}}*/
LootEntry[] entriesArray = entries.toArray(new LootEntry[entries.size()]);
LootPool pool = new LootPool(entriesArray, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(1), "heroicarmorypool");
evt.getTable().addPool(pool);
}
}
}