From d0026da88a82c811717c1362ff3cc386406f2c1e Mon Sep 17 00:00:00 2001 From: Mohammad-Ali Minaie Date: Sat, 15 Sep 2018 16:08:14 -0400 Subject: [PATCH] fuck JEI --- .../java/nmd/primal/forgecraft/ModInfo.java | 14 ++ .../nmd/primal/forgecraft/blocks/Breaker.java | 1 - .../forgecraft/blocks/CastingBlock.java | 1 - .../forgecraft/blocks/Crucibles/Crucible.java | 195 ----------------- .../blocks/Crucibles/CrucibleHot.java | 101 --------- .../blocks/Crucibles/NBTCrucible.java | 1 - .../compat/JEI/AbstractCategory.java | 31 +++ .../primal/forgecraft/compat/JEI/ModJEI.java | 144 +++++-------- .../JEI/crucible/CrucibleRecipeCategory.java | 103 +++++++++ .../JEI/crucible/CrucibleRecipeChecker.java | 20 ++ .../JEI/crucible/CrucibleRecipeHandler.java | 20 ++ .../JEI/crucible/CrucibleRecipeWrapper.java | 70 ++++++ .../forgecraft/crafting/AbstractCrafting.java | 70 ++++++ .../forgecraft/crafting/BloomeryCrafting.java | 138 ------------ .../forgecraft/crafting/CrucibleCrafting.java | 87 +++++++- .../nmd/primal/forgecraft/init/ModBlocks.java | 2 - .../primal/forgecraft/init/ModCrafting.java | 7 +- .../nmd/primal/forgecraft/init/ModTiles.java | 1 - .../init/recipes/CrucibleRecipes.java | 202 ++++++++++++++++++ .../forgecraft/items/BaseMultiItem.java | 1 - .../primal/forgecraft/items/SlottedTongs.java | 4 - .../forgecraft/tiles/TileBaseCrucible.java | 39 ---- .../primal/forgecraft/tiles/TileBloomery.java | 4 - .../forgecraft/tiles/TileNBTCrucible.java | 36 +++- .../primal/forgecraft/util/AnvilHandler.java | 2 - .../forgecraft/util/BreakerHandler.java | 7 - 26 files changed, 705 insertions(+), 596 deletions(-) delete mode 100644 kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/Crucible.java delete mode 100644 kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/CrucibleHot.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/AbstractCategory.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeCategory.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeChecker.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeHandler.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeWrapper.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/crafting/AbstractCrafting.java delete mode 100644 kfc/src/main/java/nmd/primal/forgecraft/crafting/BloomeryCrafting.java create mode 100644 kfc/src/main/java/nmd/primal/forgecraft/init/recipes/CrucibleRecipes.java delete mode 100644 kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseCrucible.java diff --git a/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java b/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java index 12144b62..a6c04e4a 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java @@ -2,8 +2,11 @@ package nmd.primal.forgecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.registries.IForgeRegistry; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; import nmd.primal.forgecraft.init.ModItems; //import nmd.primal.forgecraft.Item.ModItems; @@ -37,4 +40,15 @@ public class ModInfo { return new ItemStack(ModItems.forgehammer); } }; + + // ***************************************************************************** // + // PrimalAPI.Registries + // ***************************************************************************** // + public static class Registries + { + // In-World Recipes + public static final IForgeRegistry CRUCIBLE_CRAFTINGS = GameRegistry.findRegistry(CrucibleCrafting.class); + + } + } \ No newline at end of file diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java index 6da4d15f..e1626956 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java @@ -20,7 +20,6 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import nmd.primal.core.api.PrimalAPI; import nmd.primal.core.common.items.tools.Gallagher; -import nmd.primal.core.common.recipes.inworld.GallagherRecipe; import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.tiles.TileBreaker; import nmd.primal.forgecraft.util.BreakerHandler; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/CastingBlock.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/CastingBlock.java index 486421f2..f564b01a 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/CastingBlock.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/CastingBlock.java @@ -27,7 +27,6 @@ import nmd.primal.forgecraft.items.SlottedTongs; import nmd.primal.forgecraft.items.casting.CastingPart; import nmd.primal.forgecraft.tiles.TileCastingBlock; -import javax.annotation.Nullable; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/Crucible.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/Crucible.java deleted file mode 100644 index 77a954f8..00000000 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/Crucible.java +++ /dev/null @@ -1,195 +0,0 @@ -package nmd.primal.forgecraft.blocks.Crucibles; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import nmd.primal.core.api.PrimalAPI; -import nmd.primal.forgecraft.CommonUtils; -import nmd.primal.forgecraft.ModInfo; -import nmd.primal.forgecraft.init.ModBlocks; -import org.apache.commons.lang3.StringUtils; - -import java.util.Random; - -import static nmd.primal.forgecraft.CommonUtils.spawnItemEntityFromWorld; - -/** - * Created by mminaie on 1/24/17. - */ -public class Crucible extends Block { - - protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D); - - //public static final PropertyInteger SIZE = PropertyInteger.create("size", 0, 3); - - public Crucible(Material material, String registryName) { - super(material); - setUnlocalizedName(registryName); - setRegistryName(registryName); - setCreativeTab(ModInfo.TAB_FORGECRAFT); - setHardness(3.0f); - //this.blockState.getBaseState().withProperty(SIZE, Integer.valueOf(0)); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - - if (!world.isRemote) { - ItemStack pItem = player.inventory.getCurrentItem(); - if(pItem.isEmpty()){ - CommonUtils.spawnItemEntity(world, player, new ItemStack(this, 1)); - world.setBlockToAir(pos); - return true; - } - if(Block.getBlockFromItem(pItem.getItem()) == this){ - CommonUtils.spawnItemEntity(world, player, new ItemStack(this, 1)); - world.setBlockToAir(pos); - return true; - } - } - - return false; - } - - /*@Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){ - List ret = new java.util.ArrayList(); - ret.add(0, new ItemStack(ModBlocks.emptycrucible, 1)); - if(this.getUnlocalizedName()=="tile.coolironcrucible"){ - ret.add(1, new ItemStack(Items.IRON_INGOT, 1)); - } - - return ret; - }*/ - - public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) - { - - /*if(!world.isRemote){ - if(this.getUnlocalizedName().equals("tile.emptycruciblecracked")){} else spawnItemEntityFromWorld(world, pos, new ItemStack(ModBlocks.emptycrucible, 1)); - - if(StringUtils.isEmpty(this.getUnlocalizedName()) == false) { - if(checkDrops(this.getUnlocalizedName()) != null) { - if (checkDrops(this.getUnlocalizedName()).equals(this.getUnlocalizedName())) { - spawnItemEntityFromWorld(world, pos, new ItemStack(getItemFromName(this.getUnlocalizedName()), 1)); - } - } - } - }*/ - } - - private String checkDrops(String name){ - String string = null; - - if(name.equals("tile.coolironcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.rawironcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.coolcleanironcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.rawcleanironcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.coolsteelcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.rawsteelcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.coolwootzcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.rawwootzcrucible")){ - string = this.getUnlocalizedName(); - } - if(name.equals("tile.emptycruciblecracked")){ - string = this.getUnlocalizedName(); - } - - return string; - } - - private Item getItemFromName(String name){ - if(name.equals("tile.coolironcrucible")){ - //return Item.getItemFromBlock(ModBlocks.ironball); - return null; - } else if (name.equals("tile.rawironcrucible")){ - return Item.getItemFromBlock(Blocks.IRON_ORE); - } else if (name.equals("tile.coolcleanironcrucible")){ - //return Item.getItemFromBlock(ModBlocks.ironcleanball); - return null; - } else if (name.equals("tile.rawcleanironcrucible")){ - return PrimalAPI.Items.IRON_DUST; - } else if (name.equals("tile.coolsteelcrucible")){ - //return Item.getItemFromBlock(ModBlocks.steelball); - return null; - } else if (name.equals("tile.rawsteelcrucible")){ - //return Item.getItemFromBlock(ModBlocks.ironcleanball); - return null; - } else if (name.equals("tile.coolwootzcrucible")){ - //return Item.getItemFromBlock(ModBlocks.wootzball); - return null; - } else if (name.equals("tile.rawcleanironcrucible")){ - return PrimalAPI.Items.IRON_DUST; - }else if (name.equals("tile.emptycruciblecracked")){ - return Items.CLAY_BALL; - } - else return Items.AIR; - } - - @Override - public int quantityDropped(Random random) - { - return 0; - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return boundBox; - } - - @Override - public boolean isFullCube(IBlockState state) - { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) - { - return true; - } - - @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { - return EnumBlockRenderType.MODEL; - } - - -} diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/CrucibleHot.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/CrucibleHot.java deleted file mode 100644 index bf4190d4..00000000 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/CrucibleHot.java +++ /dev/null @@ -1,101 +0,0 @@ -package nmd.primal.forgecraft.blocks.Crucibles; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDynamicLiquid; -import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import nmd.primal.forgecraft.ModInfo; -import nmd.primal.forgecraft.tiles.TileBaseCrucible; - -import java.util.Random; - -/** - * Created by mminaie on 2/4/17. - */ -public class CrucibleHot extends Block implements ITileEntityProvider { - - protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D); - - //public static final PropertyInteger SIZE = PropertyInteger.create("size", 0, 3); - - public CrucibleHot(Material material, String registryName) { - super(material); - setUnlocalizedName(registryName); - setRegistryName(registryName); - setCreativeTab(ModInfo.TAB_FORGECRAFT); - setHardness(3.0f); - //this.blockState.getBaseState().withProperty(SIZE, Integer.valueOf(0)); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - - return false; - } - - public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) - { - - if(!world.isRemote){ - world.setBlockState(pos, Blocks.FLOWING_LAVA.getDefaultState().withProperty(BlockDynamicLiquid.LEVEL, 1), 3); - } - } - - @Override - public int quantityDropped(Random random) - { - return 0; - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) - { - return new TileBaseCrucible(); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return boundBox; - } - - @Override - public boolean isFullCube(IBlockState state) - { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) - { - return true; - } - - @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { - return EnumBlockRenderType.MODEL; - } - - -} diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java index 221d420c..0fd735b4 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java @@ -10,7 +10,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/AbstractCategory.java b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/AbstractCategory.java new file mode 100644 index 00000000..f200e3c5 --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/AbstractCategory.java @@ -0,0 +1,31 @@ +package nmd.primal.forgecraft.compat.JEI; + +import com.google.common.collect.ImmutableList; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.IRecipeWrapper; +import nmd.primal.forgecraft.ModInfo; + +import java.util.List; + +/** + * Created by mminaie on 9/13/18. + */ +public abstract class AbstractCategory implements IRecipeCategory { + + @Override + public String getModName() { + return ModInfo.MOD_NAME; + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) { + return ImmutableList.of(); + } + + @Override + public IDrawable getIcon() { + // use the default icon + return null; + } +} \ No newline at end of file diff --git a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/ModJEI.java b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/ModJEI.java index 9f780ec9..130b22df 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/ModJEI.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/ModJEI.java @@ -3,59 +3,12 @@ package nmd.primal.forgecraft.compat.JEI; import mezz.jei.api.*; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.recipe.IRecipeCategoryRegistration; -import mezz.jei.api.recipe.VanillaRecipeCategoryUid; -import net.minecraft.init.Blocks; -import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.OreIngredient; -import nmd.primal.core.api.PrimalAPI; -import nmd.primal.core.api.interfaces.types.ITypeMud; -import nmd.primal.core.api.interfaces.types.ITypeWood; -import nmd.primal.core.common.compat.jei.CraftingTableTransfer; -import nmd.primal.core.common.compat.jei.cauldron.CauldronRecipeCategory; -import nmd.primal.core.common.compat.jei.cauldron.CauldronRecipeChecker; -import nmd.primal.core.common.compat.jei.cauldron.CauldronRecipeHandler; -import nmd.primal.core.common.compat.jei.drying.DryingRecipeCategory; -import nmd.primal.core.common.compat.jei.drying.DryingRecipeChecker; -import nmd.primal.core.common.compat.jei.drying.DryingRecipeHandler; -import nmd.primal.core.common.compat.jei.flake.FlakeRecipeCategory; -import nmd.primal.core.common.compat.jei.flake.FlakeRecipeChecker; -import nmd.primal.core.common.compat.jei.flake.FlakeRecipeHandler; -import nmd.primal.core.common.compat.jei.hibachi.HibachiRecipeCategory; -import nmd.primal.core.common.compat.jei.hibachi.HibachiRecipeChecker; -import nmd.primal.core.common.compat.jei.hibachi.HibachiRecipeHandler; -import nmd.primal.core.common.compat.jei.smelter.SmelterRecipeCategory; -import nmd.primal.core.common.compat.jei.smelter.SmelterRecipeChecker; -import nmd.primal.core.common.compat.jei.smelter.SmelterRecipeHandler; -import nmd.primal.core.common.compat.jei.tools.axe.AxeRecipeCategory; -import nmd.primal.core.common.compat.jei.tools.axe.AxeRecipeChecker; -import nmd.primal.core.common.compat.jei.tools.axe.AxeRecipeHandler; -import nmd.primal.core.common.compat.jei.tools.blade.BladeRecipeCategory; -import nmd.primal.core.common.compat.jei.tools.blade.BladeRecipeChecker; -import nmd.primal.core.common.compat.jei.tools.blade.BladeRecipeHandler; -import nmd.primal.core.common.compat.jei.tools.gallahger.GallagherRecipeCategory; -import nmd.primal.core.common.compat.jei.tools.gallahger.GallagherRecipeChecker; -import nmd.primal.core.common.compat.jei.tools.gallahger.GallagherRecipeHandler; -import nmd.primal.core.common.compat.jei.tools.hoe.HoeRecipeCategory; -import nmd.primal.core.common.compat.jei.tools.hoe.HoeRecipeChecker; -import nmd.primal.core.common.compat.jei.tools.hoe.HoeRecipeHandler; -import nmd.primal.core.common.compat.jei.tools.shovel.ShovelRecipeCategory; -import nmd.primal.core.common.compat.jei.tools.shovel.ShovelRecipeChecker; -import nmd.primal.core.common.compat.jei.tools.shovel.ShovelRecipeHandler; -import nmd.primal.core.common.helper.RecipeHelper; -import nmd.primal.core.common.items.tools.Gallagher; -import nmd.primal.core.common.items.tools.WorkBlade; -import nmd.primal.core.common.recipes.inworld.*; -import nmd.primal.core.common.recipes.tile.CauldronRecipe; -import nmd.primal.core.common.recipes.tile.DryingRecipe; -import nmd.primal.core.common.recipes.tile.HibachiRecipe; -import nmd.primal.core.common.recipes.tile.SmelterRecipe; +import nmd.primal.forgecraft.compat.JEI.crucible.CrucibleRecipeCategory; +import nmd.primal.forgecraft.compat.JEI.crucible.CrucibleRecipeChecker; +import nmd.primal.forgecraft.compat.JEI.crucible.CrucibleRecipeHandler; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; /** * Created by mminaie on 9/11/18. @@ -68,11 +21,11 @@ public class ModJEI implements IModPlugin { public static IGuiHelper guiHelper; private static final int craftOutputSlot = 0; private static final int craftInputSlot1 = 1; - private static List gallaghers = new ArrayList<>(); - private static List blades = new ArrayList<>(); - private static List axes = new ArrayList<>(); - private static List shovels = new ArrayList<>(); - private static List hoes = new ArrayList<>(); + //private static List gallaghers = new ArrayList<>(); + //private static List blades = new ArrayList<>(); + //private static List axes = new ArrayList<>(); + //private static List shovels = new ArrayList<>(); + //private static List hoes = new ArrayList<>(); @Override public void registerCategories(IRecipeCategoryRegistration registry) { @@ -82,20 +35,20 @@ public class ModJEI implements IModPlugin { // // In-World // - registry.addRecipeCategories(new FlakeRecipeCategory(guiHelper)); - registry.addRecipeCategories(new GallagherRecipeCategory(guiHelper)); - registry.addRecipeCategories(new BladeRecipeCategory(guiHelper)); - registry.addRecipeCategories(new AxeRecipeCategory(guiHelper)); - registry.addRecipeCategories(new ShovelRecipeCategory(guiHelper)); - registry.addRecipeCategories(new HoeRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new FlakeRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new GallagherRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new BladeRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new AxeRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new ShovelRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new HoeRecipeCategory(guiHelper)); // // Tiles // - registry.addRecipeCategories(new DryingRecipeCategory(guiHelper)); - registry.addRecipeCategories(new HibachiRecipeCategory(guiHelper)); - registry.addRecipeCategories(new SmelterRecipeCategory(guiHelper)); - registry.addRecipeCategories(new CauldronRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new DryingRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new HibachiRecipeCategory(guiHelper)); + //registry.addRecipeCategories(new SmelterRecipeCategory(guiHelper)); + registry.addRecipeCategories(new CrucibleRecipeCategory(guiHelper)); } @Override @@ -104,15 +57,15 @@ public class ModJEI implements IModPlugin { guiHelper = jeiHelper.getGuiHelper(); craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot1, craftOutputSlot); - this.buildToolLists(); + //this.buildToolLists(); // // Crafting Tables // //registry.handleRecipes(TableRecipe.class, new TableRecipeHandler(), VanillaRecipeCategoryUid.CRAFTING); - registry.getRecipeTransferRegistry().addRecipeTransferHandler(new CraftingTableTransfer()); - registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.WORKTABLE_SHELF, 1, OreDictionary.WILDCARD_VALUE), VanillaRecipeCategoryUid.CRAFTING); - registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.WORKTABLE_SLAB, 1, OreDictionary.WILDCARD_VALUE), VanillaRecipeCategoryUid.CRAFTING); + //registry.getRecipeTransferRegistry().addRecipeTransferHandler(new CraftingTableTransfer()); + //registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.WORKTABLE_SHELF, 1, OreDictionary.WILDCARD_VALUE), VanillaRecipeCategoryUid.CRAFTING); + //registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.WORKTABLE_SLAB, 1, OreDictionary.WILDCARD_VALUE), VanillaRecipeCategoryUid.CRAFTING); // ***************************************************************************** // // Tile Recipes @@ -120,40 +73,40 @@ public class ModJEI implements IModPlugin { // // Drying Racks // - registry.handleRecipes(DryingRecipe.class, new DryingRecipeHandler(), DryingRecipeCategory.CATEGORY); - registry.addRecipes(DryingRecipeChecker.getRecipes(), DryingRecipeCategory.CATEGORY); + //registry.handleRecipes(DryingRecipe.class, new DryingRecipeHandler(), DryingRecipeCategory.CATEGORY); + //registry.addRecipes(DryingRecipeChecker.getRecipes(), DryingRecipeCategory.CATEGORY); // TODO: report to JEI? wildcard does not work for the tab icon //registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.DRYING_RACK, 1, OreDictionary.WILDCARD_VALUE), DryingRecipeCategory.CATEGORY); - for (ITypeWood.EnumType type : ITypeWood.EnumType.values()) - registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.DRYING_RACK, 1, type.getMetadata()), DryingRecipeCategory.CATEGORY); + //for (ITypeWood.EnumType type : ITypeWood.EnumType.values()) + // registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.DRYING_RACK, 1, type.getMetadata()), DryingRecipeCategory.CATEGORY); // // Hibachi // - registry.handleRecipes(HibachiRecipe.class, new HibachiRecipeHandler(), HibachiRecipeCategory.CATEGORY); - registry.addRecipes(HibachiRecipeChecker.getRecipes(), HibachiRecipeCategory.CATEGORY); - for (ITypeMud.EnumType type : ITypeMud.EnumType.values()) - registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.HIBACHI, 1, type.getMetadata()), HibachiRecipeCategory.CATEGORY); + //registry.handleRecipes(HibachiRecipe.class, new HibachiRecipeHandler(), HibachiRecipeCategory.CATEGORY); + //registry.addRecipes(HibachiRecipeChecker.getRecipes(), HibachiRecipeCategory.CATEGORY); + //for (ITypeMud.EnumType type : ITypeMud.EnumType.values()) + // registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.HIBACHI, 1, type.getMetadata()), HibachiRecipeCategory.CATEGORY); // // Smelter // - registry.handleRecipes(SmelterRecipe.class, new SmelterRecipeHandler(), SmelterRecipeCategory.CATEGORY); - registry.addRecipes(SmelterRecipeChecker.getRecipes(), SmelterRecipeCategory.CATEGORY); - for (ITypeMud.EnumType type : ITypeMud.EnumType.values()) { - ItemStack stack = new ItemStack(PrimalAPI.Blocks.SMELTER, 1, type.getMetadata()); - NBTTagCompound nbt = new NBTTagCompound(); - stack.setTagInfo("BlockEntityTag", nbt); - nbt.setBoolean("covered", true); - registry.addRecipeCatalyst(stack, SmelterRecipeCategory.CATEGORY); - } + //registry.handleRecipes(SmelterRecipe.class, new SmelterRecipeHandler(), SmelterRecipeCategory.CATEGORY); + //registry.addRecipes(SmelterRecipeChecker.getRecipes(), SmelterRecipeCategory.CATEGORY); + //for (ITypeMud.EnumType type : ITypeMud.EnumType.values()) { + // ItemStack stack = new ItemStack(PrimalAPI.Blocks.SMELTER, 1, type.getMetadata()); + // NBTTagCompound nbt = new NBTTagCompound(); + // stack.setTagInfo("BlockEntityTag", nbt); + // nbt.setBoolean("covered", true); + // registry.addRecipeCatalyst(stack, SmelterRecipeCategory.CATEGORY); + //} // // Cauldron // - registry.handleRecipes(CauldronRecipe.class, new CauldronRecipeHandler(), CauldronRecipeCategory.CATEGORY); - registry.addRecipes(CauldronRecipeChecker.getRecipes(), CauldronRecipeCategory.CATEGORY); - registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.CAULDRON), CauldronRecipeCategory.CATEGORY); + registry.handleRecipes(CrucibleCrafting.class, new CrucibleRecipeHandler(), CrucibleRecipeCategory.CATEGORY); + registry.addRecipes(CrucibleRecipeChecker.getRecipes(), CrucibleRecipeCategory.CATEGORY); + //registry.addRecipeCatalyst(new ItemStack(PrimalAPI.Blocks.CAULDRON), CrucibleRecipeCategory.CATEGORY); // ***************************************************************************** // // In-World Tools @@ -161,7 +114,7 @@ public class ModJEI implements IModPlugin { // // Flaking // - registry.handleRecipes(FlakeRecipe.class, new FlakeRecipeHandler(), FlakeRecipeCategory.CATEGORY); + /*registry.handleRecipes(FlakeRecipe.class, new FlakeRecipeHandler(), FlakeRecipeCategory.CATEGORY); registry.addRecipes(FlakeRecipeChecker.getRecipes(), FlakeRecipeCategory.CATEGORY); registry.addRecipeCatalyst(new ItemStack(Blocks.STONE), FlakeRecipeCategory.CATEGORY); @@ -204,10 +157,11 @@ public class ModJEI implements IModPlugin { registry.addRecipes(HoeRecipeChecker.getRecipes(), HoeRecipeCategory.CATEGORY); for (ItemStack stack : hoes) registry.addRecipeCatalyst(stack, HoeRecipeCategory.CATEGORY); - +*/ // ***************************************************************************** // // Info // ***************************************************************************** // + /* registry.addIngredientInfo(new ItemStack(PrimalAPI.Blocks.FISH_TRAP, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.primal.fish_trap"); registry.addIngredientInfo(new ItemStack(PrimalAPI.Blocks.DRYING_RACK, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.primal.drying_rack"); registry.addIngredientInfo(new ItemStack(PrimalAPI.Blocks.HIBACHI, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.primal.hibachi"); @@ -246,10 +200,11 @@ public class ModJEI implements IModPlugin { //registry.addIngredientInfo(new ItemStack(PrimalAPI.Blocks.NETHER_GROWTH),ItemStack.class,"jei.info.primal.nethergrowth"); registry.addIngredientInfo(new ItemStack(PrimalAPI.Items.DIRT_STICK), ItemStack.class, "jei.info.primal.debug_dirt_stick"); - - this.cleanLists(); + */ + //this.cleanLists(); } + /* private void buildToolLists() { for (Item item : ForgeRegistries.ITEMS.getValuesCollection()) { if (item != null) { @@ -281,4 +236,5 @@ public class ModJEI implements IModPlugin { blades.clear(); gallaghers.clear(); } + */ } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeCategory.java b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeCategory.java new file mode 100644 index 00000000..4f49f251 --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeCategory.java @@ -0,0 +1,103 @@ +package nmd.primal.forgecraft.compat.JEI.crucible; + +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.*; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; +import nmd.primal.core.common.compat.jei.AbstractCategory; +import nmd.primal.core.common.helper.CommonUtils; +import nmd.primal.core.common.init.ModInfo; + +import javax.annotation.Nonnull; + +/** + * Created by mminaie on 9/13/18. + */ +public class CrucibleRecipeCategory extends AbstractCategory +{ + public static String CATEGORY = CommonUtils.prefix("cauldron"); + + private static ResourceLocation gui_background = new ResourceLocation(ModInfo.MOD_ID,"textures/gui/jei/cauldron.png"); + private static ResourceLocation gui_progress = new ResourceLocation(ModInfo.MOD_ID,"textures/gui/jei/cauldron_progress.png"); + private final IDrawable background; + private final IDrawableAnimated progress; + + public CrucibleRecipeCategory(IGuiHelper guiHelper) + { + background = guiHelper.createDrawable(gui_background, 0, 0, 160, 60, 0, 0, 0, 0); + + IDrawableStatic progressDrawable = guiHelper.createDrawable(gui_progress, -14, -1, 24, 52); + progress = guiHelper.createAnimatedDrawable(progressDrawable, 200, IDrawableAnimated.StartDirection.BOTTOM, false); + } + + @Nonnull + @Override + public String getUid() + { + return CATEGORY; + } + + @Nonnull + @Override + public String getTitle() + { + return I18n.format("jei.category.primal.cauldron"); + } + + @Nonnull + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void drawExtras(@Nonnull Minecraft minecraft) + { + progress.draw(minecraft, 67, 18); + } + + @Override + public void setRecipe(IRecipeLayout layout, CrucibleRecipeWrapper recipe, IIngredients ingredients) + { + IGuiFluidStackGroup fluids = layout.getFluidStacks(); + IGuiItemStackGroup items = layout.getItemStacks(); + + // input fluid + fluids.init(0, true, 6, 8, 13, 48, 4000, true, null); + fluids.set(ingredients); + + // output_items fluid + //if (recipe.output_fluid != null) { + fluids.init(1, false, 135, 8, 13, 48, 4000, true, null); + fluids.set(ingredients); + //} + + // input items + items.init(0, true, 31, 18); + items.init(1, true, 50, 18); + items.init(2, true, 31, 37); + items.init(3, true, 50, 37); + + //items.set(0, recipe.item_input_1); + //items.set(1, recipe.item_input_2); + //items.set(2, recipe.item_input_3); + //items.set(3, recipe.item_input_4); + + //items.set(0, RecipeHelper.getSlotList(recipe.input_slots, 0)); + //items.set(1, RecipeHelper.getSlotList(recipe.input_slots, 1)); + //items.set(2, RecipeHelper.getSlotList(recipe.input_slots, 2)); + //items.set(3, RecipeHelper.getSlotList(recipe.input_slots, 3)); + + // output_items items + //if (recipe.output_items != null) { + items.init(4, false, 104, 18); + items.set(ingredients); + + items.init(5, false, 104, 37); + items.set(ingredients); + //} + } +} \ No newline at end of file diff --git a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeChecker.java b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeChecker.java new file mode 100644 index 00000000..a841dcd2 --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeChecker.java @@ -0,0 +1,20 @@ +package nmd.primal.forgecraft.compat.JEI.crucible; + +import nmd.primal.forgecraft.crafting.CrucibleCrafting; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by mminaie on 9/13/18. + */ +public class CrucibleRecipeChecker { + + public static List getRecipes() { + List recipes = new ArrayList<>(); + for (CrucibleCrafting recipe : CrucibleCrafting.RECIPES) { + recipes.add(recipe); + } + return recipes; + } +} diff --git a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeHandler.java b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeHandler.java new file mode 100644 index 00000000..1664347c --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeHandler.java @@ -0,0 +1,20 @@ +package nmd.primal.forgecraft.compat.JEI.crucible; + +import mezz.jei.api.recipe.IRecipeWrapper; +import mezz.jei.api.recipe.IRecipeWrapperFactory; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; + +import javax.annotation.Nonnull; + +/** + * Created by mminaie on 9/13/18. + */ +public class CrucibleRecipeHandler implements IRecipeWrapperFactory +{ + @Nonnull + @Override + public IRecipeWrapper getRecipeWrapper(@Nonnull CrucibleCrafting recipe) + { + return new CrucibleRecipeWrapper(recipe); + } +} \ No newline at end of file diff --git a/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeWrapper.java b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeWrapper.java new file mode 100644 index 00000000..55c6a28f --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/compat/JEI/crucible/CrucibleRecipeWrapper.java @@ -0,0 +1,70 @@ +package nmd.primal.forgecraft.compat.JEI.crucible; + +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; + +import javax.annotation.Nonnull; +import java.awt.*; +import java.util.List; + +/** + * Created by mminaie on 9/13/18. + */ +public class CrucibleRecipeWrapper implements IRecipeWrapper +{ + protected final CrucibleCrafting recipe; + + //protected final List ; + protected final int cookTemp; + protected final int cookTime; + protected final int coolTime; + + protected final ItemStack dropsCooked; + protected final ItemStack dropsRaw; + + protected Ingredient ing0; + protected Ingredient ing1; + protected Ingredient ing2; + protected Ingredient ing3; + protected Ingredient ing4; + + protected List crucibleCrafting; + + + public CrucibleRecipeWrapper(CrucibleCrafting recipe) + { + this.recipe = recipe; + this.cookTemp = recipe.getCookTemp(); + this.cookTime = recipe.getCookTime(); + this.coolTime = recipe.getCoolTime(); + + this.dropsCooked = recipe.getDropsCooked(); + this.dropsRaw = recipe.getDropsRaw(); + + this.ing0 = recipe.getIng0(); + this.ing1 = recipe.getIng1(); + this.ing2 = recipe.getIng2(); + this.ing3 = recipe.getIng3(); + this.ing4 = recipe.getIng4(); + + this.crucibleCrafting = recipe.getIngredientList(); + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(Ingredient.class, this.crucibleCrafting); + //ingredients.setOutputs(ItemStack.class, this.dropsCooked); + } + + @Override + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) + { + minecraft.fontRenderer.drawString(String.valueOf(cookTime), 80, 48, Color.gray.getRGB()); + minecraft.fontRenderer.drawString(String.valueOf(cookTemp), 80, 38, Color.gray.getRGB()); + } +} \ No newline at end of file diff --git a/kfc/src/main/java/nmd/primal/forgecraft/crafting/AbstractCrafting.java b/kfc/src/main/java/nmd/primal/forgecraft/crafting/AbstractCrafting.java new file mode 100644 index 00000000..a51d01cf --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/crafting/AbstractCrafting.java @@ -0,0 +1,70 @@ +package nmd.primal.forgecraft.crafting; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.IForgeRegistryEntry; +import nmd.primal.core.api.interfaces.ICustomRecipe; +import nmd.primal.forgecraft.ModInfo; + +import java.util.Collection; + +/** + * Created by mminaie on 9/15/18. + */ +public abstract class AbstractCrafting > extends IForgeRegistryEntry.Impl implements ICustomRecipe +{ + private boolean is_disabled, is_hidden; + + public AbstractCrafting() + { + this.is_disabled = false; + this.is_hidden = false; + } + + abstract public Collection getRecipes(); + + // ***************************************************************************** // + // Disable/Hidden Recipe controls + // ***************************************************************************** // + @Override + public RECIPE setDisabled(boolean is_disabled) + { + this.is_disabled = is_disabled; + return (RECIPE) this; + } + + @Override + public RECIPE setHidden(boolean is_hidden) + { + this.is_hidden = is_hidden; + return (RECIPE) this; + } + + @Override + public boolean isDisabled() + { + return this.is_disabled; + } + + @Override + public boolean isHidden() + { + return this.is_hidden; + } + + // ***************************************************************************** // + // Helper Methods + // ***************************************************************************** // + public static ResourceLocation getFullRecipeName(String prefix, String name) + { + return getFullRecipeName(ModInfo.MOD_ID, prefix, name); + } + + public static ResourceLocation getFullRecipeName(String id, String prefix, String name) + { + return new ResourceLocation(id, prefix + "_" + name); + } + + // ***************************************************************************** // + // .. + // ***************************************************************************** // +} \ No newline at end of file diff --git a/kfc/src/main/java/nmd/primal/forgecraft/crafting/BloomeryCrafting.java b/kfc/src/main/java/nmd/primal/forgecraft/crafting/BloomeryCrafting.java deleted file mode 100644 index 9734f1cd..00000000 --- a/kfc/src/main/java/nmd/primal/forgecraft/crafting/BloomeryCrafting.java +++ /dev/null @@ -1,138 +0,0 @@ -package nmd.primal.forgecraft.crafting; - -import net.minecraft.item.ItemStack; - -import java.util.ArrayList; - -/** - * Created by mminaie on 1/24/17. - */ -public class BloomeryCrafting { - // ***************************************************************************** // - // Recipe Handler Bloomery - // ***************************************************************************** // - private static ArrayList bloomeryRecipes = new ArrayList<>(); - - private ItemStack input; - private ItemStack output; - private ItemStack output_failed; - private ItemStack cool_output; - - - private int heat_threshold; - private int ideal_time; - private int cooldown; - - private float heat_variance; - private float time_variance; - - - - public BloomeryCrafting(ItemStack input, ItemStack output, ItemStack output_failed, ItemStack cool_output, int heat_threshold, int ideal_time, int cooldown,float heat_variance, float time_variance) - { - this.input = input; - this.output = output; - this.output_failed = output_failed; - this.cool_output = cool_output; - this.heat_threshold = heat_threshold; - this.ideal_time = ideal_time; - this.cooldown = cooldown; - this.heat_variance = heat_variance; - this.time_variance = time_variance; - - } - - // ***************************************************************************** // - // Recipe Methods - // ***************************************************************************** // - public static void addRecipe(ItemStack input, ItemStack output, ItemStack failed, ItemStack cool, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance) - { - bloomeryRecipes.add(new BloomeryCrafting(input, output, failed, cool, heat_threshold, ideal_time, cooldown, heat_variance, time_variance)); - } - - public static boolean isRecipeItem(ItemStack stack) - { - for(BloomeryCrafting recipe : bloomeryRecipes) { - if (stack.isItemEqual(recipe.input)) - return true; - } - return false; - } - - public static boolean isOutputItem(ItemStack stack) - { - for(BloomeryCrafting recipe : bloomeryRecipes) { - if (stack.isItemEqual(recipe.output)) - return true; - } - return false; - } - - public static boolean isCoolItem(ItemStack stack) - { - for(BloomeryCrafting recipe : bloomeryRecipes) { - if (stack.isItemEqual(recipe.cool_output)) - return true; - } - return false; - } - - public static BloomeryCrafting getRecipe(ItemStack stack) - { - for(BloomeryCrafting recipe : bloomeryRecipes) { - if (stack.isItemEqual(recipe.input)) - return recipe; - } - return null; - } - - public static BloomeryCrafting getRecipeFromOutput(ItemStack stack) - { - for(BloomeryCrafting recipe : bloomeryRecipes) { - if (stack.isItemEqual(recipe.output)) - return recipe; - } - return null; - } - - public ItemStack getInput() - { - return this.input; - } - - public ItemStack getOutput() - { - return this.output; - } - - public ItemStack getOutputFailed() - { - return this.output_failed; - } - - public ItemStack getCoolOutput() - { - return this.cool_output; - } - - public int getHeatThreshold() - { - return this.heat_threshold; - } - - public int getIdealTime() - { - return this.ideal_time; - } - - public int getCooldown(){ return this.cooldown;} - - public float getHeatVariance(){return this.heat_variance; } - - public float getTimeVariance(){return this.time_variance; } - - /// - // end - /// - -} diff --git a/kfc/src/main/java/nmd/primal/forgecraft/crafting/CrucibleCrafting.java b/kfc/src/main/java/nmd/primal/forgecraft/crafting/CrucibleCrafting.java index e43c5eb6..8cf0b385 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/crafting/CrucibleCrafting.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/crafting/CrucibleCrafting.java @@ -2,24 +2,71 @@ package nmd.primal.forgecraft.crafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; +import net.minecraftforge.registries.IForgeRegistry; +import nmd.primal.forgecraft.ModInfo; +import javax.annotation.Nullable; import java.util.*; /** * Created by mminaie on 11/11/17. */ -public class CrucibleCrafting { +public class CrucibleCrafting { //extends AbstractCrafting { // ***************************************************************************** // // Recipe Handler CrucibleHandler // ***************************************************************************** // + //public static final String RECIPE_PREFIX = "crucible"; + //public static final IForgeRegistry REGISTRY = ModInfo.Registries.CRUCIBLE_CRAFTINGS; + //public static final Collection RECIPES = REGISTRY.getValuesCollection(); + private static ArrayList crucibleCrafting = new ArrayList<>(); private int cookTemp; private int cookTime; private int coolTime; + public Ingredient getIng0() { + return ing0; + } + + public void setIng0(Ingredient ing0) { + this.ing0 = ing0; + } + + public Ingredient getIng1() { + return ing1; + } + + public void setIng1(Ingredient ing1) { + this.ing1 = ing1; + } + + public Ingredient getIng2() { + return ing2; + } + + public void setIng2(Ingredient ing2) { + this.ing2 = ing2; + } + + public Ingredient getIng3() { + return ing3; + } + + public void setIng3(Ingredient ing3) { + this.ing3 = ing3; + } + + public Ingredient getIng4() { + return ing4; + } + + public void setIng4(Ingredient ing4) { + this.ing4 = ing4; + } + private Ingredient ing0; private Ingredient ing1; private Ingredient ing2; @@ -29,6 +76,14 @@ public class CrucibleCrafting { private ItemStack dropsCooked; private ItemStack dropsRaw; + public List getIngredientList() { + return ingredientList; + } + + public void setIngredientList(List ingredientList) { + this.ingredientList = ingredientList; + } + private List ingredientList = new List() { @Override public int size() { @@ -152,7 +207,7 @@ public class CrucibleCrafting { public CrucibleCrafting(Ingredient i0, Ingredient i1, Ingredient i2, Ingredient i3, Ingredient i4, ItemStack outputRaw, ItemStack outputCooked, Integer temp, Integer cookTime, Integer coolTime){ - + //super(); this.ing0 = i0; this.ing1 = i1; this.ing2 = i2; @@ -227,4 +282,32 @@ public class CrucibleCrafting { public ItemStack getDropsRaw() { return dropsRaw; } + + +/* + /// forge registries require a unique REGISTRY_NAME /// + @Override + public String getRecipePrefix() + { + return RECIPE_PREFIX; + } + + @Override + public Collection getRecipes() + { + return RECIPES; + } + + /** + * Shim for getting a recipe directly from correctly formatted name + * @param recipe_name basic recipe name, no prefix or mod id + * @return Recipe object + */ +/* + @Nullable + public static CrucibleCrafting getRecipe(String recipe_name) + { + return REGISTRY.getValue(getFullRecipeName(RECIPE_PREFIX, recipe_name)); + } +*/ } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/init/ModBlocks.java b/kfc/src/main/java/nmd/primal/forgecraft/init/ModBlocks.java index 4f119072..e79d6033 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/init/ModBlocks.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/init/ModBlocks.java @@ -13,8 +13,6 @@ import net.minecraftforge.fml.relauncher.SideOnly; import nmd.primal.forgecraft.blocks.Anvil.AnvilIron; import nmd.primal.forgecraft.blocks.Anvil.AnvilStone; import nmd.primal.forgecraft.blocks.*; -import nmd.primal.forgecraft.blocks.Crucibles.Crucible; -import nmd.primal.forgecraft.blocks.Crucibles.CrucibleHot; import nmd.primal.forgecraft.blocks.Crucibles.NBTCrucible; /** diff --git a/kfc/src/main/java/nmd/primal/forgecraft/init/ModCrafting.java b/kfc/src/main/java/nmd/primal/forgecraft/init/ModCrafting.java index 4501a1ed..f25898ba 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/init/ModCrafting.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/init/ModCrafting.java @@ -9,9 +9,11 @@ import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreIngredient; import nmd.primal.core.api.PrimalAPI; import nmd.primal.core.common.recipes.irecipe.RecipeHandler; -import nmd.primal.forgecraft.crafting.*; +import nmd.primal.forgecraft.crafting.AnvilCrafting; +import nmd.primal.forgecraft.crafting.CastingformCrafting; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; +import nmd.primal.forgecraft.crafting.ForgeCrafting; -import javax.annotation.Nullable; import java.util.Random; /** @@ -29,6 +31,7 @@ public class ModCrafting{ /***CRUCIBLE CRAFTING***/ /***********************/ + CrucibleCrafting.addRecipe( new OreIngredient("oreIron"), Ingredient.EMPTY, diff --git a/kfc/src/main/java/nmd/primal/forgecraft/init/ModTiles.java b/kfc/src/main/java/nmd/primal/forgecraft/init/ModTiles.java index baf80a4d..cb0da4d3 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/init/ModTiles.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/init/ModTiles.java @@ -13,7 +13,6 @@ public class ModTiles { registerTileEntity(TileForge.class, "firebox"); registerTileEntity(TilePistonBellows.class, "pistonbellows"); registerTileEntity(TileBloomery.class, "bloomery"); - registerTileEntity(TileBaseCrucible.class, "basecrucible"); registerTileEntity(TileAnvil.class, "anvil"); registerTileEntity(TileBreaker.class, "breaker"); registerTileEntity(TileCastingForm.class, "castingform"); diff --git a/kfc/src/main/java/nmd/primal/forgecraft/init/recipes/CrucibleRecipes.java b/kfc/src/main/java/nmd/primal/forgecraft/init/recipes/CrucibleRecipes.java new file mode 100644 index 00000000..b8200fe1 --- /dev/null +++ b/kfc/src/main/java/nmd/primal/forgecraft/init/recipes/CrucibleRecipes.java @@ -0,0 +1,202 @@ +package nmd.primal.forgecraft.init.recipes; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.OreIngredient; +import net.minecraftforge.registries.IForgeRegistry; +import nmd.primal.core.api.PrimalAPI; +import nmd.primal.core.common.recipes.tile.CauldronRecipe; +import nmd.primal.forgecraft.ModInfo; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; +import nmd.primal.forgecraft.init.ModItems; + + +/** + * Created by mminaie on 9/15/18. + */ +/* +@GameRegistry.ObjectHolder(ModInfo.MOD_ID) +@Mod.EventBusSubscriber +public final class CrucibleRecipes { + + @SubscribeEvent + public static void registerRecipes(RegistryEvent.Register event) + { + final IForgeRegistry registry = event.getRegistry(); + + /***Default Recipe***/ + /** + registry.register(new CrucibleCrafting( + + ).setRecipeName("")); + ***/ + + /* + registry.register(new CrucibleCrafting( + new OreIngredient("oreIron"), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(Blocks.IRON_ORE, 1), + new ItemStack(ModItems.ironingotball, 1), + 100, + 100, + 1000).setRecipeName("wroughtiron")); + + registry.register(new CrucibleCrafting( + new OreIngredient("dustIron"), + Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CARBONATE_SLACK, 1)), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.IRON_DUST, 1), + new ItemStack(ModItems.ironcleaningotball, 1), + 100, + 100, + 1000).setRecipeName("cleaniron")); + + registry.register(new CrucibleCrafting( + Ingredient.fromStacks(new ItemStack(ModItems.ironcleaningotball, 1)), + Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_HIGH, 1)), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(ModItems.ironcleaningotball, 1), + new ItemStack(ModItems.steelingotball, 1), + 100, + 100, + 1000 + ).setRecipeName("steel")); + + registry.register(new CrucibleCrafting( + Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_PURE, 1)), + Ingredient.fromStacks(new ItemStack(Blocks.LEAVES, 1, 15)), + Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_PURE, 1)), + Ingredient.fromStacks(new ItemStack(Blocks.LEAVES, 1, 15)), + new OreIngredient("dustMagnetite"), + new ItemStack(PrimalAPI.Blocks.ORE_MAGNETITE, 1), + new ItemStack(ModItems.wootzingotball, 1), + 100, + 100, + 1000 + ).setRecipeName("damascus")); + + registry.register(new CrucibleCrafting( + Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_PURE, 1)), + Ingredient.fromStacks(new ItemStack(Blocks.LEAVES, 1, 15)), + Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_PURE, 1)), + Ingredient.fromStacks(new ItemStack(Blocks.LEAVES, 1, 15)), + new OreIngredient("magnetite"), + new ItemStack(PrimalAPI.Blocks.ORE_MAGNETITE, 1), + new ItemStack(ModItems.wootzingotball, 1), + 100, + 100, + 1000 + ).setRecipeName("damascus")); + + registry.register(new CrucibleCrafting( + new OreIngredient("dustCopper"), + new OreIngredient("dustCopper"), + new OreIngredient("dustCopper"), + new OreIngredient("dustTin"), + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.SLAG, 1), + new ItemStack(ModItems.bronzeingotball, 1), + 100, + 100, + 1000 + ).setRecipeName("bronzebasic")); + + NBTTagCompound tagBronzeDefault = new NBTTagCompound(); + tagBronzeDefault.setString("upgrades", ""); + ItemStack defaultBronze = new ItemStack(ModItems.bronzeingotball, 1); + defaultBronze.setTagCompound(tagBronzeDefault.copy()); + registry.register(new CrucibleCrafting( + new OreIngredient("oreBronze"), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.SLAG, 1), + defaultBronze, + 100, + 100, + 1000 + ).setRecipeName("defaultbronze")); + + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("upgrades", "redstone"); + ItemStack redBronze = new ItemStack(ModItems.bronzeingotball, 1); + registry.register(new CrucibleCrafting( + new OreIngredient("ingotBronze"), + new OreIngredient("dustRedstone"), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.SLAG, 1), + redBronze, + 100, + 100, + 100 + ).setRecipeName("redbronze")); + + NBTTagCompound diamondBronzeTag = new NBTTagCompound(); + tag.setString("upgrades", "diamond"); + ItemStack diamondBronze = new ItemStack(ModItems.bronzeingotball, 1); + diamondBronze.setTagCompound(diamondBronzeTag.copy()); + registry.register(new CrucibleCrafting( + new OreIngredient("ingotBronze"), + new OreIngredient("dustDiamond"), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.SLAG, 1), + diamondBronze, + 100, + 100, + 100 + ).setRecipeName("diamondbronze")); + + NBTTagCompound emeraldBronzeTag = new NBTTagCompound(); + tag.setString("upgrades", "emerald"); + ItemStack emeraldBronze = new ItemStack(ModItems.bronzeingotball, 1); + emeraldBronze.setTagCompound(emeraldBronzeTag.copy()); + registry.register(new CrucibleCrafting( + new OreIngredient("ingotBronze"), + new OreIngredient("dustEmerald"), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.SLAG, 1), + diamondBronze, + 100, + 100, + 100 + ).setRecipeName("emeraldbronze")); + + NBTTagCompound tagBronzeLapis = new NBTTagCompound(); + tagBronzeDefault.setString("upgrades", "lapis"); + ItemStack lapisBronze = new ItemStack(ModItems.bronzeingotball, 1); + lapisBronze.setTagCompound(tagBronzeLapis.copy()); + registry.register(new CrucibleCrafting( + new OreIngredient("oreBronze"), + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + Ingredient.EMPTY, + new ItemStack(PrimalAPI.Items.SLAG, 1), + lapisBronze, + 100, + 100, + 1000 + ).setRecipeName("lapisbronze")); + + } +} diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/BaseMultiItem.java b/kfc/src/main/java/nmd/primal/forgecraft/items/BaseMultiItem.java index fd28aef1..b0f47429 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/BaseMultiItem.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/BaseMultiItem.java @@ -4,7 +4,6 @@ import com.mojang.realmsclient.gui.ChatFormatting; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.IItemPropertyGetter; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java b/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java index 44e9e042..401dda3d 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java @@ -15,15 +15,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import nmd.primal.core.api.PrimalAPI; import nmd.primal.core.api.interfaces.IPickup; -import nmd.primal.core.common.PrimalCore; -import nmd.primal.core.common.helper.FluidHelper; import nmd.primal.core.common.helper.NBTHelper; import nmd.primal.core.common.helper.PlayerHelper; import nmd.primal.core.common.tiles.AbstractTileTank; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseCrucible.java b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseCrucible.java deleted file mode 100644 index ade5faf7..00000000 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseCrucible.java +++ /dev/null @@ -1,39 +0,0 @@ -package nmd.primal.forgecraft.tiles; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ITickable; -import net.minecraft.world.World; -import nmd.primal.forgecraft.crafting.BloomeryCrafting; - -/** - * Created by mminaie on 2/4/17. - */ -public class TileBaseCrucible extends BaseTile implements ITickable { - - private int iteration = 0; - public int countdown = 0; - - @Override - public void update () { - if (!world.isRemote) { - World world = this.getWorld(); - IBlockState state = world.getBlockState(this.pos); - iteration++; - //System.out.println(iteration); - if(iteration == 100 ){ - iteration = 0; - countdown += 100; - //System.out.println(countdown); - BloomeryCrafting recipe = BloomeryCrafting.getRecipeFromOutput(new ItemStack(state.getBlock(), 1)); - if(recipe != null){ - if (countdown > recipe.getCooldown()){ - world.setBlockState(this.pos, Block.getBlockFromItem(recipe.getCoolOutput().getItem()).getDefaultState(), 3); - countdown = 0; - } - } - } - } - } -} diff --git a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBloomery.java b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBloomery.java index 51684091..6224b1b6 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBloomery.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBloomery.java @@ -15,7 +15,6 @@ import nmd.primal.core.api.PrimalAPI; import nmd.primal.core.common.helper.FireHelper; import nmd.primal.core.common.helper.RecipeHelper; import nmd.primal.forgecraft.blocks.BloomeryBase; -import nmd.primal.forgecraft.blocks.Crucibles.Crucible; import nmd.primal.forgecraft.blocks.Crucibles.NBTCrucible; import nmd.primal.forgecraft.crafting.CrucibleCrafting; import nmd.primal.forgecraft.init.ModItems; @@ -284,9 +283,6 @@ public class TileBloomery extends TileBaseSlot implements ITickable { if (stack.getItem() == ModItems.softcrucible) { return true; } - if(Block.getBlockFromItem(stack.getItem()) instanceof Crucible ){ - return true; - } if(Block.getBlockFromItem(stack.getItem()) instanceof NBTCrucible ){ return true; } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileNBTCrucible.java b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileNBTCrucible.java index 2a592a30..419eb834 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileNBTCrucible.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileNBTCrucible.java @@ -9,12 +9,16 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import nmd.primal.core.api.PrimalAPI; +import nmd.primal.core.api.interfaces.IRecipeCache; import nmd.primal.forgecraft.crafting.CrucibleCrafting; +import java.util.ArrayList; +import java.util.List; + /** * Created by mminaie on 11/11/17. */ -public class TileNBTCrucible extends BaseTile implements ITickable { +public class TileNBTCrucible extends BaseTile implements ITickable, IRecipeCache { private ItemStack drops; private int heat; @@ -126,6 +130,36 @@ public class TileNBTCrucible extends BaseTile implements ITickable { return nbt; } + // ***************************************************************************** // + // IRecipeCache + // ***************************************************************************** // + private List recipe_cache = new ArrayList<>(); + + @Override + public List getRecipeCache() + { + return recipe_cache; + } + + @Override + public CrucibleCrafting matchRecipe() + { + for (CrucibleCrafting recipe : this.getRecipeCache()) { + if (recipe.isRecipe(this.ingList.get(0), this.ingList.get(1), this.ingList.get(2), this.ingList.get(3), this.ingList.get(4))) { + return recipe; + } + } + + for (CrucibleCrafting recipe : CrucibleCrafting.RECIPES) { + if (recipe.isRecipe(this.ingList.get(0), this.ingList.get(1), this.ingList.get(2), this.ingList.get(3), this.ingList.get(4))) { + this.addRecipeCache(recipe); + return recipe; + } + } + + return null; + } + } /* diff --git a/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java b/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java index f7d73594..efa901ee 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java @@ -1,6 +1,5 @@ package nmd.primal.forgecraft.util; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -14,7 +13,6 @@ import net.minecraft.world.World; import nmd.primal.core.api.PrimalAPI; import nmd.primal.core.common.items.tools.Gallagher; import nmd.primal.forgecraft.CommonUtils; -import nmd.primal.forgecraft.blocks.IngotBall; import nmd.primal.forgecraft.crafting.AnvilCrafting; import nmd.primal.forgecraft.init.ModItems; import nmd.primal.forgecraft.items.BaseMultiItem; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java b/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java index 811c28a2..9e365ed4 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java @@ -1,22 +1,15 @@ package nmd.primal.forgecraft.util; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.items.ItemStackHandler; import nmd.primal.core.api.PrimalAPI; -import nmd.primal.core.common.PrimalCore; -import nmd.primal.core.common.helper.NBTHelper; import nmd.primal.core.common.helper.PlayerHelper; import nmd.primal.core.common.helper.RecipeHelper; -import nmd.primal.core.common.init.recipes.custom.RecipesGallagher; -import nmd.primal.core.common.recipes.AbstractToolRecipe; import nmd.primal.core.common.recipes.inworld.GallagherRecipe; import nmd.primal.forgecraft.blocks.CustomContainerFacing; import nmd.primal.forgecraft.tiles.TileBreaker;