From 6e518935bb37f734a8eb0499b0a85941c1d595f4 Mon Sep 17 00:00:00 2001 From: Falkreon Date: Sun, 23 Apr 2017 21:28:59 -0500 Subject: [PATCH] Add circular crafting for block varieties --- .../github/elytra/engination/Engination.java | 32 ++++++++++++++++++- .../engination/block/BlockCosmetic.java | 11 +++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/elytra/engination/Engination.java b/src/main/java/io/github/elytra/engination/Engination.java index 7c4dd41..79679a5 100644 --- a/src/main/java/io/github/elytra/engination/Engination.java +++ b/src/main/java/io/github/elytra/engination/Engination.java @@ -56,6 +56,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraftforge.common.config.Configuration; @@ -280,7 +281,7 @@ public void onInit(FMLInitializationEvent e) { } else { GameRegistry.addRecipe(new ShapedOreRecipe( new ItemStack(EnginationBlocks.COSMETIC_PERIDOT, 16), - "GGG", "GlG", "GGG", + "SGS", "GlG", "SGS", 'G', "blockGlass", 'l', "dyeLime" )); @@ -292,6 +293,22 @@ public void onInit(FMLInitializationEvent e) { 'S', "stone", 'E', new ItemStack(Blocks.SOUL_SAND) )); + + + //Circular crafting for varieties + registerCraftingCircle(EnginationBlocks.COSMETIC_BAROQUE); + registerCraftingCircle(EnginationBlocks.COSMETIC_CELESTITE); + registerCraftingCircle(EnginationBlocks.COSMETIC_DOLOMITE); + registerCraftingCircle(EnginationBlocks.COSMETIC_LAMP); + registerCraftingCircle(EnginationBlocks.COSMETIC_LOOSESTONE); + registerCraftingCircle(EnginationBlocks.COSMETIC_ONEUP); + registerCraftingCircle(EnginationBlocks.COSMETIC_PERIDOT); + registerCraftingCircle(EnginationBlocks.COSMETIC_PRESIDENTIAL); + registerCraftingCircle(EnginationBlocks.COSMETIC_SANIC); + registerCraftingCircle(EnginationBlocks.COSMETIC_SCRAPMETAL); + registerCraftingCircle(EnginationBlocks.COSMETIC_TOURIAN); + registerCraftingCircle(EnginationBlocks.COSMETIC_WINGFORTRESS); + registerCraftingCircle(EnginationBlocks.COSMETIC_WOOD); } } @@ -334,6 +351,19 @@ public SoundEvent createSound(String loc) { return sound; } + public void registerCraftingCircle(BlockCosmetic block) { + NonNullList list = NonNullList.create(); + block.getVarieties(Item.getItemFromBlock(block), list); + if (list.size()<2) return; + ItemStack first = list.remove(0); + ItemStack previous = first; + for(ItemStack item : list) { + GameRegistry.addShapelessRecipe(item, previous); + previous = item; + } + GameRegistry.addShapelessRecipe(first, list.get(list.size()-1)); + } + public static Engination instance() { return instance; } diff --git a/src/main/java/io/github/elytra/engination/block/BlockCosmetic.java b/src/main/java/io/github/elytra/engination/block/BlockCosmetic.java index 2fc0ca1..d7b9e70 100755 --- a/src/main/java/io/github/elytra/engination/block/BlockCosmetic.java +++ b/src/main/java/io/github/elytra/engination/block/BlockCosmetic.java @@ -33,17 +33,15 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; -import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +@SuppressWarnings("deprecation") public class BlockCosmetic extends Block { public static PropertyInteger VARIANT = PropertyInteger.create("variant", 0, 15); private boolean showTip = false; @@ -71,6 +69,13 @@ protected BlockCosmetic(Material material, MapColor color) { @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemBlock, CreativeTabs tab, NonNullList list) { + getVarieties(itemBlock, list); + } + + /** + * Behaves like getSubBlocks, but is available on the server + */ + public void getVarieties(Item itemBlock, NonNullList list) { for(int i=0; i<16; i++) { list.add(new ItemStack(itemBlock, 1, i)); }