2018-09-12 01:29:49 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.item.ItemApple;
|
2018-09-16 00:45:44 +02:00
|
|
|
import com.minelittlepony.unicopia.item.ItemCloud;
|
2018-09-20 22:49:10 +02:00
|
|
|
import com.minelittlepony.unicopia.item.ItemCurse;
|
2018-09-19 09:07:39 +02:00
|
|
|
import com.minelittlepony.unicopia.item.ItemOfHolding;
|
2018-09-20 22:49:10 +02:00
|
|
|
import com.minelittlepony.unicopia.item.ItemSpell;
|
2018-09-16 00:45:44 +02:00
|
|
|
import com.minelittlepony.unicopia.item.UItemBlock;
|
|
|
|
import com.minelittlepony.unicopia.item.UItemMultiTexture;
|
|
|
|
import com.minelittlepony.unicopia.item.UItemSlab;
|
2018-09-20 22:49:10 +02:00
|
|
|
import com.minelittlepony.unicopia.spell.SpellRegistry;
|
2018-09-12 01:29:49 +02:00
|
|
|
|
|
|
|
import come.minelittlepony.unicopia.forgebullshit.RegistryLockSpinner;
|
2018-09-20 22:49:10 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
2018-09-20 22:49:10 +02:00
|
|
|
import net.minecraft.client.renderer.color.ItemColors;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2018-09-19 09:07:39 +02:00
|
|
|
import net.minecraft.init.Enchantments;
|
2018-09-12 22:37:06 +02:00
|
|
|
import net.minecraft.init.Items;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraft.item.Item;
|
2018-09-19 09:07:39 +02:00
|
|
|
import net.minecraft.item.ItemDoor;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
2018-09-19 09:07:39 +02:00
|
|
|
import net.minecraft.item.crafting.IRecipe;
|
|
|
|
import net.minecraft.item.crafting.Ingredient;
|
|
|
|
import net.minecraft.item.crafting.ShapedRecipes;
|
|
|
|
import net.minecraft.util.NonNullList;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraftforge.registries.IForgeRegistry;
|
|
|
|
|
|
|
|
import static com.minelittlepony.unicopia.Predicates.*;
|
2018-09-12 01:29:49 +02:00
|
|
|
|
|
|
|
public class UItems {
|
|
|
|
public static final ItemApple apple = new ItemApple()
|
|
|
|
.setSubTypes("apple", "green", "sweet", "rotten", "zap", "zap_cooked")
|
|
|
|
.setTypeRarities(10, 20, 10, 30);
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
public static final Item cloud_matter = new Item()
|
|
|
|
.setCreativeTab(CreativeTabs.MATERIALS)
|
|
|
|
.setTranslationKey("cloud_matter")
|
|
|
|
.setRegistryName(Unicopia.MODID, "cloud_matter");
|
|
|
|
|
|
|
|
public static final Item dew_drop = new Item()
|
|
|
|
.setCreativeTab(CreativeTabs.MATERIALS)
|
|
|
|
.setTranslationKey("dew_drop")
|
|
|
|
.setRegistryName(Unicopia.MODID, "dew_drop");
|
|
|
|
|
|
|
|
public static final ItemCloud cloud_spawner = new ItemCloud(Unicopia.MODID, "cloud");
|
|
|
|
|
|
|
|
public static final Item cloud_block = new UItemMultiTexture(UBlocks.cloud, stack -> {
|
|
|
|
return CloudType.byMetadata(stack.getMetadata()).getTranslationKey();
|
2018-09-19 09:07:39 +02:00
|
|
|
}, INTERACT_WITH_CLOUDS)
|
|
|
|
.setRegistryName(Unicopia.MODID, "cloud_block");
|
2018-09-16 00:45:44 +02:00
|
|
|
|
|
|
|
public static final Item cloud_stairs = new UItemBlock(UBlocks.stairsCloud, INTERACT_WITH_CLOUDS)
|
|
|
|
.setTranslationKey("cloud_stairs")
|
|
|
|
.setRegistryName(Unicopia.MODID, "cloud_stairs");
|
|
|
|
|
2018-09-19 09:07:39 +02:00
|
|
|
|
|
|
|
public static final Item anvil = new UItemBlock(UBlocks.anvil, INTERACT_WITH_CLOUDS)
|
|
|
|
.setTranslationKey("cloud_anvil")
|
|
|
|
.setRegistryName(Unicopia.MODID, "anvil");
|
|
|
|
|
|
|
|
public static final Item mist_door = new ItemDoor(UBlocks.mist_door)
|
|
|
|
.setTranslationKey("mist_door")
|
|
|
|
.setRegistryName(Unicopia.MODID, "mist_door");
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
public static final Item cloud_slab = new UItemSlab(UBlocks.cloud_slab, UBlocks.cloud_slab, UBlocks.cloud_double_slab, INTERACT_WITH_CLOUDS)
|
|
|
|
.setTranslationKey("cloud_slab")
|
|
|
|
.setRegistryName(Unicopia.MODID, "cloud_slab");
|
|
|
|
|
2018-09-20 22:49:10 +02:00
|
|
|
public static final ItemSpell spell = new ItemSpell(Unicopia.MODID, "gem");
|
|
|
|
public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem");
|
2018-09-19 09:07:39 +02:00
|
|
|
|
|
|
|
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
static void registerItems(IForgeRegistry<Item> registry) {
|
2018-09-12 01:29:49 +02:00
|
|
|
RegistryLockSpinner.unlock(Item.REGISTRY);
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
Item.REGISTRY.register(Item.getIdFromItem(Items.APPLE), new ResourceLocation("apple"), apple);
|
2018-09-12 22:37:06 +02:00
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
RegistryLockSpinner.lock(Item.REGISTRY);
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2018-09-19 09:07:39 +02:00
|
|
|
registry.registerAll(cloud_spawner, dew_drop, cloud_matter, cloud_block,
|
|
|
|
cloud_stairs, cloud_slab, mist_door, anvil,
|
2018-09-20 22:49:10 +02:00
|
|
|
bag_of_holding, spell, curse);
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
if (UClient.isClientSide()) {
|
|
|
|
registerAllVariants(apple, apple.getVariants());
|
|
|
|
registerAllVariants(cloud_spawner, "cloud_small", "cloud_medium", "cloud_large");
|
|
|
|
registerAllVariants(dew_drop, "dew_drop");
|
|
|
|
registerAllVariants(cloud_matter, "cloud_matter");
|
|
|
|
registerAllVariants(cloud_stairs, "cloud_stairs");
|
|
|
|
registerAllVariants(cloud_slab, CloudType.getVariants("_cloud_slab"));
|
|
|
|
registerAllVariants(cloud_block, CloudType.getVariants("_cloud_block"));
|
2018-09-19 09:07:39 +02:00
|
|
|
registerAllVariants(mist_door, "mist_door");
|
|
|
|
registerAllVariants(anvil, "anvil");
|
|
|
|
registerAllVariants(bag_of_holding, "bag_of_holding");
|
2018-09-20 22:49:10 +02:00
|
|
|
registerAllVariants(spell, "gem");
|
|
|
|
registerAllVariants(curse, "corrupted_gem");
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|
2018-09-19 09:07:39 +02:00
|
|
|
|
|
|
|
registerFuels();
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
private static void registerAllVariants(Item item, String... variants) {
|
|
|
|
for (int i = 0; i < variants.length; i++) {
|
|
|
|
ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation("unicopia:" + variants[i]));
|
|
|
|
}
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void registerFuels() {
|
|
|
|
int zap = apple.getZapAppleMetadata();
|
|
|
|
FurnaceRecipes.instance().addSmeltingRecipe(
|
|
|
|
new ItemStack(UItems.apple, 1, zap),
|
|
|
|
new ItemStack(UItems.apple, 1, zap + 1), 0.1F);
|
|
|
|
}
|
2018-09-19 09:07:39 +02:00
|
|
|
|
|
|
|
static void registerRecipes(IForgeRegistry<IRecipe> registry) {
|
|
|
|
Ingredient dewdrop = Ingredient.fromItem(dew_drop);
|
|
|
|
Ingredient cloud = Ingredient.fromStacks(new ItemStack(cloud_block, 1, 0));
|
|
|
|
|
|
|
|
ItemStack bookStack = new ItemStack(Items.ENCHANTED_BOOK, 1);
|
|
|
|
bookStack.addEnchantment(Enchantments.FEATHER_FALLING, 1);
|
|
|
|
|
|
|
|
Ingredient book = Ingredient.fromStacks(bookStack);
|
|
|
|
|
|
|
|
registry.register(new ShapedRecipes("", 3, 3, NonNullList.from(Ingredient.EMPTY,
|
|
|
|
dewdrop, dewdrop, dewdrop,
|
|
|
|
cloud, book, cloud,
|
|
|
|
cloud, cloud, cloud
|
|
|
|
), new ItemStack(cloud_block, 1, 2)).setRegistryName(Unicopia.MODID, "id_dont_care_just_use_it"));
|
|
|
|
}
|
2018-09-20 22:49:10 +02:00
|
|
|
|
|
|
|
static void registerColors(ItemColors registry) {
|
|
|
|
registry.registerItemColorHandler((stack, tint) -> {
|
|
|
|
if (Predicates.MAGI.test(Minecraft.getMinecraft().player)) {
|
|
|
|
return SpellRegistry.instance().getSpellTintFromStack(stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0xffffff;
|
|
|
|
}, spell, curse);
|
|
|
|
}
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|