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-03-28 23:20:25 +01:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
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;
|
2020-03-28 23:20:25 +01:00
|
|
|
import com.simibubi.create.foundation.utility.data.ITaggable;
|
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;
|
2020-04-05 18:02:46 +02:00
|
|
|
import com.simibubi.create.modules.contraptions.relays.belt.item.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;
|
2020-04-05 18:02:46 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
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()),
|
2020-03-28 23:20:25 +01:00
|
|
|
COPPER_NUGGET(new TaggedItem().withForgeTags("nuggets/copper")),
|
|
|
|
ZINC_NUGGET(new TaggedItem().withForgeTags("nuggets/zinc")),
|
|
|
|
BRASS_NUGGET(new TaggedItem().withForgeTags("nuggets/brass")),
|
|
|
|
IRON_SHEET(new TaggedItem().withForgeTags("plates/iron")),
|
|
|
|
GOLD_SHEET(new TaggedItem().withForgeTags("plates/gold")),
|
|
|
|
COPPER_SHEET(new TaggedItem().withForgeTags("plates/copper")),
|
|
|
|
BRASS_SHEET(new TaggedItem().withForgeTags("plates/brass")),
|
|
|
|
LAPIS_PLATE(new TaggedItem().withForgeTags("plates/lapis")),
|
2020-02-03 16:47:58 +01:00
|
|
|
|
|
|
|
CRUSHED_IRON,
|
|
|
|
CRUSHED_GOLD,
|
|
|
|
CRUSHED_COPPER,
|
|
|
|
CRUSHED_ZINC,
|
|
|
|
CRUSHED_BRASS,
|
|
|
|
|
|
|
|
ANDESITE_ALLOY,
|
2020-03-28 23:20:25 +01:00
|
|
|
COPPER_INGOT(new TaggedItem().withForgeTags("ingots/copper")),
|
|
|
|
ZINC_INGOT(new TaggedItem().withForgeTags("ingots/zinc")),
|
|
|
|
BRASS_INGOT(new TaggedItem().withForgeTags("ingots/brass")),
|
2020-02-03 16:47:58 +01:00
|
|
|
|
2020-04-16 20:46:15 +02:00
|
|
|
FLOUR,
|
|
|
|
DOUGH,
|
2020-02-03 16:47:58 +01:00
|
|
|
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,
|
|
|
|
|
|
|
|
__CONTRAPTIONS__(module()),
|
|
|
|
BELT_CONNECTOR(BeltConnectorItem::new),
|
|
|
|
VERTICAL_GEARBOX(VerticalGearboxItem::new),
|
|
|
|
PROPELLER,
|
|
|
|
WHISK,
|
|
|
|
BRASS_HAND,
|
2020-02-15 18:54:23 +01:00
|
|
|
SLOT_COVER,
|
2020-04-16 20:46:15 +02:00
|
|
|
SUPER_GLUE,
|
|
|
|
ANTIOXIDANT,
|
|
|
|
SAND_PAPER(SandPaperItem::new),
|
|
|
|
RED_SAND_PAPER(SandPaperItem::new),
|
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),
|
2020-04-16 20:46:15 +02:00
|
|
|
ZINC_HANDLE,
|
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
|
|
|
|
2020-04-16 20:46:15 +02:00
|
|
|
__SCHEMATICS__(module()),
|
|
|
|
EMPTY_BLUEPRINT(Item::new, stackSize(1)),
|
|
|
|
BLUEPRINT_AND_QUILL(SchematicAndQuillItem::new, stackSize(1)),
|
|
|
|
BLUEPRINT(SchematicItem::new),
|
|
|
|
|
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;
|
2020-03-28 23:20:25 +01:00
|
|
|
private TaggedItem taggedItem;
|
2020-02-03 16:47:58 +01:00
|
|
|
private Item item;
|
2019-09-12 10:00:15 +02:00
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
AllItems(int moduleMarker) {
|
|
|
|
CategoryTracker.currentModule = () -> Lang.asId(name()).replaceAll("__", "");
|
|
|
|
taggedItem = new TaggedItem(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
AllItems(Function<Properties, Item> itemSupplier) {
|
|
|
|
this(new TaggedItem(itemSupplier), Function.identity());
|
|
|
|
}
|
|
|
|
|
|
|
|
AllItems(Function<Properties, Item> itemSupplier, Function<Properties, Properties> specialProperties) {
|
|
|
|
this(new TaggedItem(itemSupplier), specialProperties);
|
2019-09-12 10:00:15 +02:00
|
|
|
}
|
2019-07-11 09:03:08 +02:00
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
AllItems() {
|
|
|
|
this(new TaggedItem(Item::new));
|
2020-02-03 16:47:58 +01:00
|
|
|
}
|
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
AllItems(TaggedItem taggedItemIn) {
|
|
|
|
this(taggedItemIn, Function.identity());
|
2019-12-19 22:35:45 +01:00
|
|
|
}
|
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
AllItems(TaggedItem taggedItemIn, Function<Properties, Properties> specialProperties) {
|
|
|
|
this.taggedItem = taggedItemIn;
|
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()) {
|
2020-03-28 23:20:25 +01:00
|
|
|
if (entry.taggedItem == null || entry.taggedItem.getItemSupplier() == null)
|
2019-09-12 10:00:15 +02:00
|
|
|
continue;
|
2020-02-03 16:47:58 +01:00
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
entry.item = entry.taggedItem.getItemSupplier().apply(new Properties());
|
2020-04-16 20:46:15 +02:00
|
|
|
entry.item =
|
|
|
|
entry.taggedItem.getItemSupplier().apply(entry.specialProperties.apply(defaultProperties(entry)));
|
2020-02-03 16:47:58 +01:00
|
|
|
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
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
public TaggedItem getTaggable() {
|
|
|
|
return taggedItem;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-03-28 23:20:25 +01:00
|
|
|
public static class TaggedItem implements ITaggable<TaggedItem> {
|
|
|
|
|
|
|
|
private Set<ResourceLocation> tagSetItem = new HashSet<>();
|
|
|
|
private Function<Properties, Item> itemSupplier;
|
|
|
|
|
2020-04-16 20:46:15 +02:00
|
|
|
public TaggedItem() {
|
2020-03-28 23:20:25 +01:00
|
|
|
this(Item::new);
|
|
|
|
}
|
|
|
|
|
2020-04-16 20:46:15 +02:00
|
|
|
public TaggedItem(Function<Properties, Item> itemSupplierIn) {
|
2020-03-28 23:20:25 +01:00
|
|
|
this.itemSupplier = itemSupplierIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Function<Properties, Item> getItemSupplier() {
|
|
|
|
return itemSupplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Set<ResourceLocation> getTagSet(TagType type) {
|
|
|
|
return tagSetItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|