Skip to content

Commit

Permalink
Add circular crafting for block varieties
Browse files Browse the repository at this point in the history
  • Loading branch information
falkreon committed Apr 24, 2017
1 parent 3a30d1f commit 6e51893
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
32 changes: 31 additions & 1 deletion src/main/java/io/github/elytra/engination/Engination.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"
));
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -334,6 +351,19 @@ public SoundEvent createSound(String loc) {
return sound;
}

public void registerCraftingCircle(BlockCosmetic block) {
NonNullList<ItemStack> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,6 +69,13 @@ protected BlockCosmetic(Material material, MapColor color) {
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemBlock, CreativeTabs tab, NonNullList<ItemStack> list) {
getVarieties(itemBlock, list);
}

/**
* Behaves like getSubBlocks, but is available on the server
*/
public void getVarieties(Item itemBlock, NonNullList<ItemStack> list) {
for(int i=0; i<16; i++) {
list.add(new ItemStack(itemBlock, 1, i));
}
Expand Down

0 comments on commit 6e51893

Please sign in to comment.