2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-08-31 08:37:57 +02:00
|
|
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltItem;
|
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-08-18 17:02:29 +02:00
|
|
|
import com.simibubi.create.modules.gardens.TreeFertilizerItem;
|
2019-08-27 17:35:34 +02:00
|
|
|
import com.simibubi.create.modules.logistics.item.FilterItem;
|
2019-07-23 12:54:53 +02:00
|
|
|
import com.simibubi.create.modules.schematics.item.BlueprintAndQuillItem;
|
|
|
|
import com.simibubi.create.modules.schematics.item.BlueprintItem;
|
|
|
|
import com.simibubi.create.modules.symmetry.SymmetryWandItem;
|
2019-07-28 10:08:49 +02:00
|
|
|
import com.simibubi.create.modules.symmetry.client.SymmetryWandItemRenderer;
|
|
|
|
import com.simibubi.create.modules.symmetry.client.SymmetryWandModel;
|
2019-07-11 09:03:08 +02:00
|
|
|
|
2019-08-27 17:35:34 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
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
|
|
|
|
|
|
|
SYMMETRY_WAND(new SymmetryWandItem(
|
2019-08-08 23:10:01 +02:00
|
|
|
standardProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.SYMMETRY_WAND)))),
|
|
|
|
|
|
|
|
PLACEMENT_HANDGUN(
|
|
|
|
new BuilderGunItem(new Properties().setTEISR(() -> () -> renderUsing(AllItemRenderers.BUILDER_GUN)))),
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-08-08 23:10:01 +02:00
|
|
|
ANDESITE_ALLOY_CUBE(new Item(standardProperties())),
|
|
|
|
BLAZE_BRASS_CUBE(new Item(standardProperties())),
|
2019-07-28 10:08:49 +02:00
|
|
|
CHORUS_CHROME_CUBE(new Item(standardProperties().rarity(Rarity.UNCOMMON))),
|
|
|
|
|
2019-07-19 17:50:23 +02:00
|
|
|
TREE_FERTILIZER(new TreeFertilizerItem(standardProperties())),
|
2019-08-08 23:10:01 +02:00
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
EMPTY_BLUEPRINT(new Item(standardProperties().maxStackSize(1))),
|
2019-07-19 17:50:23 +02:00
|
|
|
BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))),
|
2019-08-06 19:00:51 +02:00
|
|
|
BLUEPRINT(new BlueprintItem(standardProperties())),
|
2019-08-10 01:00:36 +02:00
|
|
|
BELT_CONNECTOR(new BeltItem(standardProperties())),
|
2019-08-27 17:35:34 +02:00
|
|
|
FILTER(new FilterItem(standardProperties())),
|
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-08-08 23:10:01 +02:00
|
|
|
// Common
|
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public Item item;
|
|
|
|
|
|
|
|
private AllItems(Item item) {
|
|
|
|
this.item = item;
|
|
|
|
this.item.setRegistryName(Create.ID, this.name().toLowerCase());
|
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public static Properties standardProperties() {
|
|
|
|
return new Properties().group(Create.creativeTab);
|
|
|
|
}
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-07-11 09:03:08 +02:00
|
|
|
public static void registerItems(IForgeRegistry<Item> iForgeRegistry) {
|
|
|
|
for (AllItems item : values()) {
|
|
|
|
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() {
|
|
|
|
Minecraft.getInstance().getItemColors().register(new FilterItem.Color(), FILTER.item);
|
|
|
|
}
|
|
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-08-08 23:10:01 +02:00
|
|
|
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
|
|
|
|
switch (renderer) {
|
|
|
|
|
|
|
|
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
|
|
|
}
|