Create/src/main/java/com/simibubi/create/AllItems.java

275 lines
9.5 KiB
Java
Raw Normal View History

package com.simibubi.create;
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;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
import com.simibubi.create.foundation.item.IItemWithColorHandler;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.data.ITaggable;
import com.simibubi.create.modules.Sections;
import com.simibubi.create.modules.contraptions.GogglesItem;
import com.simibubi.create.modules.contraptions.WrenchItem;
import com.simibubi.create.modules.contraptions.components.contraptions.glue.SuperGlueItem;
import com.simibubi.create.modules.contraptions.components.contraptions.mounted.MinecartContraptionItem;
import com.simibubi.create.modules.contraptions.relays.belt.item.BeltConnectorItem;
import com.simibubi.create.modules.contraptions.relays.gearbox.VerticalGearboxItem;
import com.simibubi.create.modules.curiosities.ChromaticCompoundCubeItem;
import com.simibubi.create.modules.curiosities.RefinedRadianceItem;
import com.simibubi.create.modules.curiosities.ShadowSteelItem;
import com.simibubi.create.modules.curiosities.TreeFertilizerItem;
import com.simibubi.create.modules.curiosities.deforester.DeforesterItem;
import com.simibubi.create.modules.curiosities.symmetry.SymmetryWandItem;
import com.simibubi.create.modules.curiosities.tools.AllToolTiers;
import com.simibubi.create.modules.curiosities.tools.BlazingSwordItem;
import com.simibubi.create.modules.curiosities.tools.BlazingToolItem;
import com.simibubi.create.modules.curiosities.tools.RoseQuartzToolItem;
import com.simibubi.create.modules.curiosities.tools.SandPaperItem;
import com.simibubi.create.modules.curiosities.tools.ShadowSteelToolItem;
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem;
import com.simibubi.create.modules.curiosities.zapper.terrainzapper.TerrainzapperItem;
import com.simibubi.create.modules.logistics.item.filter.FilterItem;
import com.simibubi.create.modules.schematics.item.SchematicAndQuillItem;
import com.simibubi.create.modules.schematics.item.SchematicItem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity.Type;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Properties;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.item.SwordItem;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.IForgeRegistry;
@EventBusSubscriber(value = Dist.CLIENT, bus = Bus.MOD)
public enum AllItems {
_1_(Sections.MATERIALS),
COPPER_NUGGET((TaggedItem) new TaggedItem().withForgeTags("nuggets/copper")),
ZINC_NUGGET((TaggedItem) new TaggedItem().withForgeTags("nuggets/zinc")),
BRASS_NUGGET((TaggedItem) new TaggedItem().withForgeTags("nuggets/brass")),
IRON_SHEET((TaggedItem) new TaggedItem().withForgeTags("plates/iron")),
GOLD_SHEET((TaggedItem) new TaggedItem().withForgeTags("plates/gold")),
COPPER_SHEET((TaggedItem) new TaggedItem().withForgeTags("plates/copper")),
BRASS_SHEET((TaggedItem) new TaggedItem().withForgeTags("plates/brass")),
LAPIS_PLATE((TaggedItem) new TaggedItem().withForgeTags("plates/lapis")),
CRUSHED_IRON,
CRUSHED_GOLD,
CRUSHED_COPPER,
CRUSHED_ZINC,
CRUSHED_BRASS,
ANDESITE_ALLOY,
COPPER_INGOT((TaggedItem) new TaggedItem().withForgeTags("ingots/copper")),
ZINC_INGOT((TaggedItem) new TaggedItem().withForgeTags("ingots/zinc")),
BRASS_INGOT((TaggedItem) new TaggedItem().withForgeTags("ingots/brass")),
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
FLOUR,
DOUGH,
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,
_2_(Sections.KINETICS),
BELT_CONNECTOR(BeltConnectorItem::new),
VERTICAL_GEARBOX(VerticalGearboxItem::new),
PROPELLER,
WHISK,
BRASS_HAND,
SLOT_COVER,
SUPER_GLUE(SuperGlueItem::new),
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
SAND_PAPER(SandPaperItem::new),
RED_SAND_PAPER(SandPaperItem::new),
WRENCH(WrenchItem::new),
GOGGLES(GogglesItem::new),
MINECART_CONTRAPTION(p -> new MinecartContraptionItem(Type.RIDEABLE, p)),
FURNACE_MINECART_CONTRAPTION(p -> new MinecartContraptionItem(Type.FURNACE, p)),
_3_(Sections.LOGISTICS),
FILTER(FilterItem::new),
PROPERTY_FILTER(FilterItem::new),
_4_(Sections.CURIOSITIES),
TREE_FERTILIZER(TreeFertilizerItem::new),
PLACEMENT_HANDGUN(BlockzapperItem::new),
TERRAIN_ZAPPER(TerrainzapperItem::new),
DEFORESTER(DeforesterItem::new),
SYMMETRY_WAND(SymmetryWandItem::new),
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
ZINC_HANDLE,
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)),
BLAZING_SWORD(p -> new BlazingSwordItem(AllToolTiers.BLAZING, 3, -2.4F, p)),
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)),
ROSE_QUARTZ_SWORD(p -> new SwordItem(AllToolTiers.ROSE_QUARTZ, 3, -2.4F, p)),
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)),
SHADOW_STEEL_SWORD(p -> new SwordItem(AllToolTiers.SHADOW_STEEL, 3, -2.0F, p)),
_5_(Sections.SCHEMATICS),
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
EMPTY_BLUEPRINT(Item::new, stackSize(1)),
BLUEPRINT_AND_QUILL(SchematicAndQuillItem::new, stackSize(1)),
BLUEPRINT(SchematicItem::new),
;
private static class SectionTracker {
static Sections currentSection;
}
// Common
public Sections section;
private Function<Properties, Properties> specialProperties;
private TaggedItem taggedItem;
private Item item;
AllItems(Sections section) {
SectionTracker.currentSection = section;
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);
}
AllItems() {
this(new TaggedItem(Item::new));
}
AllItems(TaggedItem taggedItemIn) {
this(taggedItemIn, Function.identity());
}
AllItems(TaggedItem taggedItemIn, Function<Properties, Properties> specialProperties) {
this.taggedItem = taggedItemIn;
this.section = SectionTracker.currentSection;
this.specialProperties = specialProperties;
}
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) {
2020-03-29 04:10:23 +02:00
return includeInItemGroup().setISTER(() -> item::getRenderer);
}
public static Properties includeInItemGroup() {
return new Properties().group(Create.creativeTab);
}
public static void register(RegistryEvent.Register<Item> event) {
IForgeRegistry<Item> registry = event.getRegistry();
for (AllItems entry : values()) {
if (entry.taggedItem == null || entry.taggedItem.getItemSupplier() == null)
continue;
entry.item = entry.taggedItem.getItemSupplier().apply(new Properties());
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
entry.item =
entry.taggedItem.getItemSupplier().apply(entry.specialProperties.apply(defaultProperties(entry)));
entry.item.setRegistryName(Create.ID, Lang.asId(entry.name()));
registry.register(entry.item);
}
}
public Item get() {
return item;
}
public TaggedItem getTaggable() {
return taggedItem;
}
public boolean typeOf(ItemStack stack) {
return stack.getItem() == item;
}
public ItemStack asStack() {
return new ItemStack(item);
}
public static class TaggedItem extends ITaggable.Impl {
private Set<ResourceLocation> tagSetItem = new HashSet<>();
private Function<Properties, Item> itemSupplier;
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
public TaggedItem() {
this(Item::new);
}
Bugs & Refactors - Added new selection/outline particles for use in place of bounding box rendering - Refactored JEI categories - Slots for chance outputs now have a slighly different appearance in JEI - Redstone links no longer cause a redstone update when loaded in - Redstone links no longer mess up windmill bearings on chunk reload - Fixed redstone links not working properly after movement in a contraption - Filter output amounts can no longer be increased beyond the stack limit - Chassis range visualization now uses the new outline particle - Kinetic networks are now aware of movement, such as NBT-item placement, schematic placement and other means of tileentity movement and will reset/reconnect - Fixed pistons/bearings/etc not being movable by chassis - Fixed pistons/bearings/etc moving a clone of themselves when attached to the initial block - Fixed pistons/bearings/etc stopping or losing their structure when loaded incorrecly - Pulleys can now be moved while extended, moving attached ropes and their own attached structure with them - Brittle blocks such as ladders/torches/etc can no longer be moved unless their attached block is moved - Fixed mechanical pistons messing up their kinetic information when changing into a different extension state. - Fixed misplaced client code introduced by a ScreenOpener hotfix - Fixed inconsistent belt initialization when belts are placed by schematics or structures, causing them to break at random - Clutches and Gearshifts now await their turn to re-attach when changed, allowing multiple to be used in a network and swapped within one tick without causing components to break. - Fixed flexcrate interface crashing if the block gets removed while open - Some additions/modifications in texture assets - Pistons no longer get blocked by their push limit if the blocks pushed are attached to each other
2020-04-16 20:46:15 +02:00
public TaggedItem(Function<Properties, Item> itemSupplierIn) {
this.itemSupplier = itemSupplierIn;
}
public Function<Properties, Item> getItemSupplier() {
return itemSupplier;
}
@Override
public Set<ResourceLocation> getTagSet(TagType<?> type) {
return tagSetItem;
}
}
// Client
@OnlyIn(Dist.CLIENT)
public ItemStackTileEntityRenderer getRenderer() {
if (!(item instanceof IHaveCustomItemModel))
return null;
IHaveCustomItemModel specialItem = (IHaveCustomItemModel) item;
return specialItem.createModel(null).getRenderer();
}
@OnlyIn(Dist.CLIENT)
public static void registerColorHandlers() {
ItemColors itemColors = Minecraft.getInstance().getItemColors();
for (AllItems item : values()) {
if (item.item instanceof IItemWithColorHandler) {
itemColors.register(((IItemWithColorHandler) item.item).getColorHandler(), item.item);
}
}
}
}