2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2020-03-09 17:46:04 +01:00
|
|
|
import static com.simibubi.create.foundation.item.AllToolTypes.AXE;
|
|
|
|
import static com.simibubi.create.foundation.item.AllToolTypes.HOE;
|
|
|
|
import static com.simibubi.create.foundation.item.AllToolTypes.PICKAXE;
|
|
|
|
import static com.simibubi.create.foundation.item.AllToolTypes.SHOVEL;
|
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
|
2019-09-03 23:03:52 +02:00
|
|
|
import com.simibubi.create.foundation.item.IItemWithColorHandler;
|
2019-10-15 22:22:19 +02:00
|
|
|
import com.simibubi.create.foundation.utility.Lang;
|
2019-09-12 10:00:15 +02:00
|
|
|
import com.simibubi.create.modules.IModule;
|
2019-12-05 23:42:01 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.GogglesItem;
|
2019-10-29 19:02:20 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.WrenchItem;
|
2019-11-12 21:09:32 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltConnectorItem;
|
2019-12-12 10:56:34 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.relays.gearbox.VerticalGearboxItem;
|
2019-09-03 23:03:52 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.ChromaticCompoundCubeItem;
|
2020-01-27 14:57:21 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.RefinedRadianceItem;
|
|
|
|
import com.simibubi.create.modules.curiosities.ShadowSteelItem;
|
2019-10-30 02:05:26 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.deforester.DeforesterItem;
|
2019-09-14 18:21:30 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.symmetry.SymmetryWandItem;
|
2020-03-28 17:48:55 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.tools.AllToolTiers;
|
2020-03-09 17:46:04 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.tools.BlazingToolItem;
|
|
|
|
import com.simibubi.create.modules.curiosities.tools.RoseQuartzToolItem;
|
2020-01-26 23:58:55 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.tools.SandPaperItem;
|
2020-03-09 17:46:04 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.tools.ShadowSteelToolItem;
|
2020-03-04 14:06:34 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem;
|
2020-03-05 19:52:10 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.zapper.terrainzapper.TerrainzapperItem;
|
2019-08-18 17:02:29 +02:00
|
|
|
import com.simibubi.create.modules.gardens.TreeFertilizerItem;
|
2020-01-19 19:29:39 +01:00
|
|
|
import com.simibubi.create.modules.logistics.item.filter.FilterItem;
|
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.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;
|
2020-03-28 17:48:55 +01:00
|
|
|
import net.minecraft.item.SwordItem;
|
2019-07-15 12:10:57 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-12-05 23:42:01 +01:00
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
2019-07-28 10:08:49 +02:00
|
|
|
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
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
__MATERIALS__(module()),
|
|
|
|
COPPER_NUGGET,
|
|
|
|
ZINC_NUGGET,
|
|
|
|
BRASS_NUGGET,
|
|
|
|
IRON_SHEET,
|
|
|
|
GOLD_SHEET,
|
|
|
|
COPPER_SHEET,
|
|
|
|
BRASS_SHEET,
|
|
|
|
LAPIS_PLATE,
|
|
|
|
|
|
|
|
CRUSHED_IRON,
|
|
|
|
CRUSHED_GOLD,
|
|
|
|
CRUSHED_COPPER,
|
|
|
|
CRUSHED_ZINC,
|
|
|
|
CRUSHED_BRASS,
|
|
|
|
|
|
|
|
ANDESITE_ALLOY,
|
|
|
|
COPPER_INGOT,
|
|
|
|
ZINC_INGOT,
|
|
|
|
BRASS_INGOT,
|
|
|
|
|
|
|
|
SAND_PAPER(SandPaperItem::new),
|
|
|
|
RED_SAND_PAPER(SandPaperItem::new),
|
|
|
|
OBSIDIAN_DUST,
|
|
|
|
ROSE_QUARTZ,
|
|
|
|
POLISHED_ROSE_QUARTZ,
|
|
|
|
CHROMATIC_COMPOUND(ChromaticCompoundCubeItem::new, rarity(Rarity.UNCOMMON)),
|
|
|
|
SHADOW_STEEL(ShadowSteelItem::new, rarity(Rarity.UNCOMMON)),
|
|
|
|
REFINED_RADIANCE(RefinedRadianceItem::new, rarity(Rarity.UNCOMMON)),
|
|
|
|
ELECTRON_TUBE,
|
|
|
|
INTEGRATED_CIRCUIT,
|
|
|
|
|
|
|
|
__SCHEMATICS__(module()),
|
|
|
|
EMPTY_BLUEPRINT(Item::new, stackSize(1)),
|
|
|
|
BLUEPRINT_AND_QUILL(SchematicAndQuillItem::new, stackSize(1)),
|
|
|
|
BLUEPRINT(SchematicItem::new),
|
|
|
|
|
|
|
|
__CONTRAPTIONS__(module()),
|
|
|
|
BELT_CONNECTOR(BeltConnectorItem::new),
|
|
|
|
VERTICAL_GEARBOX(VerticalGearboxItem::new),
|
|
|
|
FLOUR,
|
|
|
|
DOUGH,
|
|
|
|
PROPELLER,
|
|
|
|
WHISK,
|
|
|
|
BRASS_HAND,
|
2020-02-15 18:54:23 +01:00
|
|
|
SLOT_COVER,
|
2020-03-09 17:46:04 +01:00
|
|
|
ZINC_HANDLE,
|
2020-02-03 16:47:58 +01:00
|
|
|
WRENCH(WrenchItem::new),
|
|
|
|
GOGGLES(GogglesItem::new),
|
|
|
|
|
|
|
|
__LOGISTICS__(module()),
|
|
|
|
FILTER(FilterItem::new),
|
|
|
|
PROPERTY_FILTER(FilterItem::new),
|
|
|
|
|
|
|
|
__CURIOSITIES__(module()),
|
|
|
|
TREE_FERTILIZER(TreeFertilizerItem::new),
|
|
|
|
PLACEMENT_HANDGUN(BlockzapperItem::new),
|
2020-03-05 19:52:10 +01:00
|
|
|
TERRAIN_ZAPPER(TerrainzapperItem::new),
|
2020-02-03 16:47:58 +01:00
|
|
|
DEFORESTER(DeforesterItem::new),
|
|
|
|
SYMMETRY_WAND(SymmetryWandItem::new),
|
2019-12-19 22:35:45 +01:00
|
|
|
|
2020-03-09 17:46:04 +01:00
|
|
|
BLAZING_PICKAXE(p -> new BlazingToolItem(1, -2.8F, p, PICKAXE)),
|
|
|
|
BLAZING_SHOVEL(p -> new BlazingToolItem(1.5F, -3.0F, p, SHOVEL)),
|
|
|
|
BLAZING_AXE(p -> new BlazingToolItem(5.0F, -3.0F, p, AXE)),
|
2020-03-28 17:48:55 +01:00
|
|
|
BLAZING_SWORD(p -> new SwordItem(AllToolTiers.BLAZING, 3, -2.4F, p)),
|
2020-03-09 17:46:04 +01:00
|
|
|
|
|
|
|
ROSE_QUARTZ_PICKAXE(p -> new RoseQuartzToolItem(1, -2.8F, p, PICKAXE)),
|
|
|
|
ROSE_QUARTZ_SHOVEL(p -> new RoseQuartzToolItem(1.5F, -3.0F, p, SHOVEL)),
|
|
|
|
ROSE_QUARTZ_AXE(p -> new RoseQuartzToolItem(5.0F, -3.0F, p, AXE)),
|
2020-03-28 17:48:55 +01:00
|
|
|
ROSE_QUARTZ_SWORD(p -> new SwordItem(AllToolTiers.ROSE_QUARTZ, 3, -2.4F, p)),
|
2020-03-09 17:46:04 +01:00
|
|
|
|
|
|
|
SHADOW_STEEL_PICKAXE(p -> new ShadowSteelToolItem(2.5F, -2.0F, p, PICKAXE)),
|
|
|
|
SHADOW_STEEL_MATTOCK(p -> new ShadowSteelToolItem(2.5F, -1.5F, p, SHOVEL, AXE, HOE)),
|
2020-03-28 17:48:55 +01:00
|
|
|
SHADOW_STEEL_SWORD(p -> new SwordItem(AllToolTiers.SHADOW_STEEL, 3, -2.0F, p)),
|
2020-03-09 17:46:04 +01: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-09-12 10:00:15 +02:00
|
|
|
public IModule module;
|
2020-02-03 16:47:58 +01:00
|
|
|
private Function<Properties, Properties> specialProperties;
|
|
|
|
private Function<Properties, Item> itemSupplier;
|
|
|
|
private Item item;
|
2019-09-12 10:00:15 +02:00
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
private AllItems(int moduleMarker) {
|
2019-09-12 10:00:15 +02:00
|
|
|
CategoryTracker.currentModule = new IModule() {
|
|
|
|
@Override
|
|
|
|
public String getModuleName() {
|
2019-10-15 22:22:19 +02:00
|
|
|
return Lang.asId(name()).replaceAll("__", "");
|
2019-09-12 10:00:15 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2019-07-11 09:03:08 +02:00
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
private AllItems() {
|
|
|
|
this(Item::new);
|
|
|
|
}
|
|
|
|
|
|
|
|
private AllItems(Function<Properties, Item> itemSupplier) {
|
|
|
|
this(itemSupplier, Function.identity());
|
2019-12-19 22:35:45 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
private AllItems(Function<Properties, Item> itemSupplier, Function<Properties, Properties> specialProperties) {
|
|
|
|
this.itemSupplier = itemSupplier;
|
2019-09-12 10:00:15 +02:00
|
|
|
this.module = CategoryTracker.currentModule;
|
2020-02-03 16:47:58 +01:00
|
|
|
this.specialProperties = specialProperties;
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
private static Function<Properties, Properties> rarity(Rarity rarity) {
|
|
|
|
return p -> p.rarity(rarity);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Function<Properties, Properties> stackSize(int stackSize) {
|
|
|
|
return p -> p.maxStackSize(stackSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Properties defaultProperties(AllItems item) {
|
|
|
|
return includeInItemGroup().setTEISR(() -> item::getRenderer);
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
private static int module() {
|
|
|
|
return 0;
|
2019-09-13 18:36:18 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
public static Properties includeInItemGroup() {
|
|
|
|
return new Properties().group(Create.creativeTab);
|
2019-09-13 18:36:18 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 23:42:01 +01:00
|
|
|
public static void register(RegistryEvent.Register<Item> event) {
|
|
|
|
IForgeRegistry<Item> registry = event.getRegistry();
|
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
for (AllItems entry : values()) {
|
|
|
|
if (entry.itemSupplier == null)
|
2019-09-12 10:00:15 +02:00
|
|
|
continue;
|
2020-02-03 16:47:58 +01:00
|
|
|
|
|
|
|
entry.item = entry.itemSupplier.apply(new Properties());
|
|
|
|
entry.item = entry.itemSupplier.apply(entry.specialProperties.apply(defaultProperties(entry)));
|
|
|
|
entry.item.setRegistryName(Create.ID, Lang.asId(entry.name()));
|
|
|
|
registry.register(entry.item);
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
2019-12-19 22:35:45 +01:00
|
|
|
|
2019-12-05 23:42:01 +01:00
|
|
|
AllBlocks.registerItemBlocks(registry);
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
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-10-30 02:05:26 +01:00
|
|
|
|
2019-10-05 19:00:43 +02:00
|
|
|
public ItemStack asStack() {
|
|
|
|
return new ItemStack(item);
|
|
|
|
}
|
2019-07-11 09:03:08 +02:00
|
|
|
|
2019-08-08 23:10:01 +02:00
|
|
|
// Client
|
|
|
|
|
2020-02-03 16:47:58 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public ItemStackTileEntityRenderer getRenderer() {
|
|
|
|
if (!(item instanceof IHaveCustomItemModel))
|
|
|
|
return null;
|
|
|
|
IHaveCustomItemModel specialItem = (IHaveCustomItemModel) item;
|
|
|
|
return specialItem.createModel(null).getRenderer();
|
2019-08-08 23:10:01 +02:00
|
|
|
}
|
|
|
|
|
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-07-11 09:03:08 +02:00
|
|
|
}
|