2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-09-03 23:03:52 +02:00
|
|
|
import com.simibubi.create.foundation.item.IItemWithColorHandler;
|
2019-09-12 10:00:15 +02:00
|
|
|
import com.simibubi.create.modules.IModule;
|
2019-08-31 08:37:57 +02:00
|
|
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltItem;
|
2019-09-03 23:03:52 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.ChromaticCompoundCubeItem;
|
2019-07-28 10:08:49 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItem;
|
|
|
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItemRenderer;
|
|
|
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunModel;
|
2019-09-14 18:21:30 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.symmetry.SymmetryWandItem;
|
|
|
|
import com.simibubi.create.modules.curiosities.symmetry.client.SymmetryWandItemRenderer;
|
|
|
|
import com.simibubi.create.modules.curiosities.symmetry.client.SymmetryWandModel;
|
2019-08-18 17:02:29 +02:00
|
|
|
import com.simibubi.create.modules.gardens.TreeFertilizerItem;
|
2019-09-03 23:03:52 +02:00
|
|
|
import com.simibubi.create.modules.schematics.item.SchematicAndQuillItem;
|
|
|
|
import com.simibubi.create.modules.schematics.item.SchematicItem;
|
2019-07-11 09:03:08 +02:00
|
|
|
|
2019-08-27 17:35:34 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2019-09-03 23:03:52 +02:00
|
|
|
import net.minecraft.client.renderer.color.ItemColors;
|
2019-07-28 10:08:49 +02:00
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
|
|
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
|
|
|
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.Item.Properties;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2019-07-28 10:08:49 +02:00
|
|
|
import net.minecraft.item.Rarity;
|
2019-07-15 12:10:57 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-07-28 10:08:49 +02:00
|
|
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
|
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraftforge.registries.IForgeRegistry;
|
|
|
|
|
2019-07-28 10:08:49 +02:00
|
|
|
@EventBusSubscriber(value = Dist.CLIENT, bus = Bus.MOD)
|
2019-07-11 09:03:08 +02:00
|
|
|
public enum AllItems {
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
__CURIOSITIES__(),
|
2019-07-28 10:08:49 +02:00
|
|
|
SYMMETRY_WAND(new SymmetryWandItem(
|
2019-09-12 10:00:15 +02:00
|
|
|
standardItemProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.SYMMETRY_WAND)))),
|
2019-08-08 23:10:01 +02:00
|
|
|
PLACEMENT_HANDGUN(
|
|
|
|
new BuilderGunItem(new Properties().setTEISR(() -> () -> renderUsing(AllItemRenderers.BUILDER_GUN)))),
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
__MATERIALS__(),
|
2019-09-13 18:36:18 +02:00
|
|
|
IRON_SHEET(ingredient()),
|
2019-09-16 12:27:28 +02:00
|
|
|
GOLD_SHEET(ingredient()),
|
2019-09-13 18:36:18 +02:00
|
|
|
ANDESITE_ALLOY_CUBE(ingredient()),
|
|
|
|
BLAZE_BRASS_CUBE(ingredient()),
|
|
|
|
CHORUS_CHROME_CUBE(ingredient(Rarity.UNCOMMON)),
|
2019-09-18 11:16:57 +02:00
|
|
|
SHADOW_STEEL_CUBE(new Item(new Properties().rarity(Rarity.UNCOMMON))),
|
|
|
|
ROSE_QUARTZ(new Item(new Properties())),
|
|
|
|
REFINED_ROSE_QUARTZ(new Item(new Properties())),
|
|
|
|
CHROMATIC_COMPOUND_CUBE(new ChromaticCompoundCubeItem(new Properties().rarity(Rarity.UNCOMMON))),
|
|
|
|
REFINED_RADIANCE_CUBE(new Item(new Properties().rarity(Rarity.UNCOMMON))),
|
2019-09-05 02:16:44 +02:00
|
|
|
|
2019-09-09 18:18:32 +02:00
|
|
|
// BLAZING_PICKAXE(new BlazingToolItem(1, -2.8F, standardProperties(), PICKAXE)),
|
|
|
|
// BLAZING_SHOVEL(new BlazingToolItem(1.5F, -3.0F, standardProperties(), SHOVEL)),
|
|
|
|
// BLAZING_AXE(new BlazingToolItem(5.0F, -3.0F, standardProperties(), AXE)),
|
|
|
|
// BLAZING_SWORD(new BlazingToolItem(3, -2.4F, standardProperties(), SWORD)),
|
|
|
|
//
|
|
|
|
// ROSE_QUARTZ_PICKAXE(new RoseQuartzToolItem(1, -2.8F, standardProperties(), PICKAXE)),
|
|
|
|
// ROSE_QUARTZ_SHOVEL(new RoseQuartzToolItem(1.5F, -3.0F, standardProperties(), SHOVEL)),
|
|
|
|
// ROSE_QUARTZ_AXE(new RoseQuartzToolItem(5.0F, -3.0F, standardProperties(), AXE)),
|
|
|
|
// ROSE_QUARTZ_SWORD(new RoseQuartzToolItem(3, -2.4F, standardProperties(), SWORD)),
|
|
|
|
//
|
|
|
|
// SHADOW_STEEL_PICKAXE(new ShadowSteelToolItem(2.5F, -2.0F, standardProperties(), PICKAXE)),
|
|
|
|
// SHADOW_STEEL_MATTOCK(new ShadowSteelToolItem(2.5F, -1.5F, standardProperties(), SHOVEL, AXE, HOE)),
|
|
|
|
// SHADOW_STEEL_SWORD(new ShadowSteelToolItem(3, -2.0F, standardProperties(), SWORD)),
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
__GARDENS__(),
|
|
|
|
TREE_FERTILIZER(new TreeFertilizerItem(standardItemProperties())),
|
2019-09-03 23:03:52 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
__SCHEMATICS__(),
|
|
|
|
EMPTY_BLUEPRINT(new Item(standardItemProperties().maxStackSize(1))),
|
|
|
|
BLUEPRINT_AND_QUILL(new SchematicAndQuillItem(standardItemProperties().maxStackSize(1))),
|
|
|
|
BLUEPRINT(new SchematicItem(standardItemProperties())),
|
2019-09-13 18:36:18 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
__CONTRAPTIONS__(),
|
|
|
|
BELT_CONNECTOR(new BeltItem(standardItemProperties())),
|
2019-09-13 18:36:18 +02:00
|
|
|
FLOUR(ingredient()),
|
|
|
|
DOUGH(ingredient()),
|
|
|
|
PROPELLER(ingredient()),
|
2019-08-08 16:19:16 +02:00
|
|
|
|
2019-08-06 19:00:51 +02:00
|
|
|
;
|
2019-07-11 09:03:08 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
private static class CategoryTracker {
|
|
|
|
static IModule currentModule;
|
|
|
|
}
|
|
|
|
|
2019-08-08 23:10:01 +02:00
|
|
|
// Common
|
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public Item item;
|
2019-09-12 10:00:15 +02:00
|
|
|
public IModule module;
|
|
|
|
|
|
|
|
private AllItems() {
|
|
|
|
CategoryTracker.currentModule = new IModule() {
|
|
|
|
@Override
|
|
|
|
public String getModuleName() {
|
|
|
|
return name().toLowerCase().replaceAll("__", "");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2019-07-11 09:03:08 +02:00
|
|
|
|
|
|
|
private AllItems(Item item) {
|
|
|
|
this.item = item;
|
|
|
|
this.item.setRegistryName(Create.ID, this.name().toLowerCase());
|
2019-09-12 10:00:15 +02:00
|
|
|
this.module = CategoryTracker.currentModule;
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-09-12 10:00:15 +02:00
|
|
|
public static Properties standardItemProperties() {
|
2019-07-11 09:03:08 +02:00
|
|
|
return new Properties().group(Create.creativeTab);
|
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-09-13 18:36:18 +02:00
|
|
|
private static Item ingredient() {
|
|
|
|
return ingredient(Rarity.COMMON);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Item ingredient(Rarity rarity) {
|
|
|
|
return new Item(standardItemProperties().rarity(rarity));
|
|
|
|
}
|
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public static void registerItems(IForgeRegistry<Item> iForgeRegistry) {
|
|
|
|
for (AllItems item : values()) {
|
2019-09-12 10:00:15 +02:00
|
|
|
if (item.get() == null)
|
|
|
|
continue;
|
2019-07-11 09:03:08 +02:00
|
|
|
iForgeRegistry.register(item.get());
|
|
|
|
}
|
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public Item get() {
|
|
|
|
return item;
|
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public boolean typeOf(ItemStack stack) {
|
|
|
|
return stack.getItem() == item;
|
|
|
|
}
|
|
|
|
|
2019-08-08 23:10:01 +02:00
|
|
|
// Client
|
|
|
|
|
|
|
|
private enum AllItemRenderers {
|
|
|
|
SYMMETRY_WAND, BUILDER_GUN,;
|
|
|
|
}
|
|
|
|
|
2019-07-15 12:10:57 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-08-27 17:35:34 +02:00
|
|
|
public static void registerColorHandlers() {
|
2019-09-03 23:03:52 +02:00
|
|
|
ItemColors itemColors = Minecraft.getInstance().getItemColors();
|
|
|
|
for (AllItems item : values()) {
|
|
|
|
if (item.item instanceof IItemWithColorHandler) {
|
|
|
|
itemColors.register(((IItemWithColorHandler) item.item).getColorHandler(), item.item);
|
|
|
|
}
|
|
|
|
}
|
2019-08-27 17:35:34 +02:00
|
|
|
}
|
2019-09-03 23:03:52 +02:00
|
|
|
|
2019-08-27 17:35:34 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-08-08 23:10:01 +02:00
|
|
|
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
|
|
|
|
switch (renderer) {
|
2019-09-03 23:03:52 +02:00
|
|
|
|
2019-08-08 23:10:01 +02:00
|
|
|
case SYMMETRY_WAND:
|
2019-07-28 10:08:49 +02:00
|
|
|
return new SymmetryWandItemRenderer();
|
2019-08-08 23:10:01 +02:00
|
|
|
case BUILDER_GUN:
|
2019-07-28 10:08:49 +02:00
|
|
|
return new BuilderGunItemRenderer();
|
2019-08-08 23:10:01 +02:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public static void onModelBake(ModelBakeEvent event) {
|
|
|
|
|
|
|
|
ModelResourceLocation wandLocation = getModelLocation(SYMMETRY_WAND);
|
|
|
|
IBakedModel template = event.getModelRegistry().get(wandLocation);
|
|
|
|
event.getModelRegistry().put(wandLocation, new SymmetryWandModel(template).loadPartials(event));
|
|
|
|
|
|
|
|
ModelResourceLocation handgunLocation = getModelLocation(PLACEMENT_HANDGUN);
|
|
|
|
template = event.getModelRegistry().get(handgunLocation);
|
|
|
|
event.getModelRegistry().put(handgunLocation, new BuilderGunModel(template).loadPartials(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static ModelResourceLocation getModelLocation(AllItems item) {
|
|
|
|
return new ModelResourceLocation(item.item.getRegistryName(), "inventory");
|
|
|
|
}
|
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|