2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-07-23 12:54:53 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.item.TreeFertilizerItem;
|
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-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-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(
|
|
|
|
standardProperties().rarity(Rarity.UNCOMMON).setTEISR(() -> () -> withSpecialRenderer("wand")))),
|
|
|
|
PLACEMENT_HANDGUN(new BuilderGunItem(
|
|
|
|
new Properties().rarity(Rarity.UNCOMMON).setTEISR(() -> () -> withSpecialRenderer("gun")))),
|
|
|
|
|
|
|
|
ANDESITE_ALLOY_CUBE(new Item(standardProperties())), BLAZE_BRASS_CUBE(new Item(standardProperties())),
|
|
|
|
CHORUS_CHROME_CUBE(new Item(standardProperties().rarity(Rarity.UNCOMMON))),
|
|
|
|
|
2019-07-19 17:50:23 +02:00
|
|
|
TREE_FERTILIZER(new TreeFertilizerItem(standardProperties())),
|
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))),
|
|
|
|
BLUEPRINT(new BlueprintItem(standardProperties()));
|
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-07-15 12:10:57 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-07-28 10:08:49 +02:00
|
|
|
public static ItemStackTileEntityRenderer withSpecialRenderer(String renderer) {
|
|
|
|
if ("wand".equals(renderer))
|
|
|
|
return new SymmetryWandItemRenderer();
|
|
|
|
if ("gun".equals(renderer))
|
|
|
|
return new BuilderGunItemRenderer();
|
|
|
|
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
|
|
|
}
|