adding crafting for charred tool handle
This commit is contained in:
@@ -75,28 +75,21 @@ public class Anvil extends CustomContainerFacing {
|
||||
ItemStack pItem = player.inventory.getCurrentItem();
|
||||
|
||||
// ***************************************************************************** //
|
||||
// Crafting
|
||||
// Crafting Anvil Recipes
|
||||
// ***************************************************************************** //
|
||||
if(pItem.getItem() == PrimalItems.STONE_GALLAGHER){
|
||||
System.out.println("Use the ghallegher");
|
||||
StringBuilder craftingIDBuilder = new StringBuilder();
|
||||
//craftingIDBuilder.append("");
|
||||
int craftingID = 0;
|
||||
for(int i=0; i<tile.getSlotListSize(); i++){
|
||||
Integer[] tempArray = new Integer[25];
|
||||
for(int i=0; i < 25 ; i++){
|
||||
if(!tile.getSlotStack(i).isEmpty()){
|
||||
craftingIDBuilder.append(i);
|
||||
tempArray[i] = 1;
|
||||
} else tempArray[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
craftingID = Integer.parseInt(craftingIDBuilder.toString());
|
||||
System.out.println(craftingID);
|
||||
AnvilCrafting recipe = AnvilCrafting.getRecipe(craftingID);
|
||||
if(recipe != null){
|
||||
CommonUtils.spawnItemEntity(world, player, recipe.getOutput());
|
||||
for(int i=0; i<tile.getSlotListSize(); i++){
|
||||
if(!tile.getSlotStack(i).isEmpty()){
|
||||
AnvilCrafting recipe = AnvilCrafting.getRecipe(tempArray);
|
||||
if(recipe != null) {
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos, recipe.getOutput());
|
||||
for (int i = 0; i < tile.getSlotListSize(); i++) {
|
||||
if (!tile.getSlotStack(i).isEmpty()) {
|
||||
tile.setSlotStack(i, ItemStack.EMPTY);
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -16,7 +16,7 @@ import nmd.primal.forgecraft.ModInfo;
|
||||
*/
|
||||
public class BlockCustomBase extends BlockBase {
|
||||
|
||||
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
public AxisAlignedBB boundBox = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
|
||||
public BlockCustomBase(Material material, String registryName, Float hardness) {
|
||||
super(material, registryName, hardness);
|
||||
|
||||
@@ -6,31 +6,43 @@ import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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 nmd.primal.core.api.PrimalItems;
|
||||
import nmd.primal.forgecraft.CommonUtils;
|
||||
import nmd.primal.forgecraft.ModInfo;
|
||||
import nmd.primal.forgecraft.init.ModBlocks;
|
||||
|
||||
/**
|
||||
* Created by mminaie on 2/6/17.
|
||||
*/
|
||||
public class IngotBall extends BlockCustomBase {
|
||||
|
||||
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(7/16D, 0.0D, 7/16D, 9/16D, 2/16D, 9/16D);
|
||||
protected static AxisAlignedBB boundBoxLarge = new AxisAlignedBB(6/16D, 0.0D, 6/16D, 10/16D, 4/16D, 10/16D);
|
||||
protected static AxisAlignedBB boundBoxSmall = new AxisAlignedBB(7/16D, 0.0D, 7/16D, 9/16D, 2/16D, 9/16D);
|
||||
public static final PropertyBool ACTIVE = PropertyBool.create("active");
|
||||
private String type;
|
||||
|
||||
public IngotBall(Material material, String registryName, Float hardness){
|
||||
public IngotBall(Material material, String registryName, Float hardness, String type){
|
||||
super(material, registryName, hardness);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
|
||||
{
|
||||
return boundBox;
|
||||
if(this.type.equals("chunk")){
|
||||
return boundBoxSmall;
|
||||
}else
|
||||
return boundBoxLarge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import static javax.swing.UIManager.put;
|
||||
@@ -20,48 +21,15 @@ public class AnvilCrafting {
|
||||
|
||||
private static ArrayList<AnvilCrafting> anvilRecipes = new ArrayList<>();
|
||||
|
||||
private static int input;
|
||||
private Integer[] input = new Integer[25];
|
||||
|
||||
private static ItemStack slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24;
|
||||
|
||||
private static ItemStack [] slots = {slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24};
|
||||
|
||||
private static int[] craftingIDs = {6781014};
|
||||
|
||||
public static int getCraftingIDs(Integer x) {
|
||||
return craftingIDs[x];
|
||||
}
|
||||
|
||||
public static int[] getCraftingIDArray() {
|
||||
return craftingIDs;
|
||||
}
|
||||
|
||||
private static ItemStack[] craftable = {new ItemStack(Blocks.OBSIDIAN, 1)};
|
||||
|
||||
public static ItemStack getCraftable(Integer x) {
|
||||
return craftable[x];
|
||||
}
|
||||
|
||||
|
||||
/*public static Hashtable<Integer, ItemStack> anvilReference = new Hashtable<Integer, ItemStack>(){{
|
||||
|
||||
put(6781014, new ItemStack(Blocks.OBSIDIAN, 1));
|
||||
|
||||
//put(3, ModItems.battleAxe);
|
||||
|
||||
}};*/
|
||||
|
||||
public static ItemStack getSlots(Integer x) {
|
||||
return slots[x];
|
||||
}
|
||||
|
||||
public static ItemStack[] getSlots() {
|
||||
return slots;
|
||||
}
|
||||
|
||||
private ItemStack output;
|
||||
|
||||
public AnvilCrafting(Integer input, ItemStack output){
|
||||
public AnvilCrafting(Integer[] input, ItemStack output){
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
@@ -72,30 +40,26 @@ public class AnvilCrafting {
|
||||
// Recipe Methods
|
||||
// ***************************************************************************** //
|
||||
|
||||
public static void addRecipe(Integer input, ItemStack output)
|
||||
public static void addRecipe(Integer[] input, ItemStack output)
|
||||
{
|
||||
anvilRecipes.add(new AnvilCrafting(input, output));
|
||||
}
|
||||
|
||||
public static boolean isRecipeItem(Integer craftingID)
|
||||
public static boolean isRecipe(Integer[] array)
|
||||
{
|
||||
for(AnvilCrafting recipe : anvilRecipes) {
|
||||
for(int i=0; i < AnvilCrafting.craftingIDs.length ; i++){
|
||||
if (craftingID.equals(getCraftingIDs(i)))
|
||||
if (Arrays.equals(array, recipe.input))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static AnvilCrafting getRecipe(Integer id)
|
||||
public static AnvilCrafting getRecipe(Integer[] array)
|
||||
{
|
||||
for(AnvilCrafting recipe : anvilRecipes) {
|
||||
for (int i = 0; i < AnvilCrafting.craftingIDs.length; i++) {
|
||||
if (id.equals(getCraftingIDs(i)))
|
||||
if (Arrays.equals(array, recipe.input))
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,26 @@ package nmd.primal.forgecraft.init;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
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.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import nmd.primal.core.api.PrimalItems;
|
||||
import nmd.primal.core.common.blocks.PrimalBlock;
|
||||
import nmd.primal.forgecraft.CommonUtils;
|
||||
import nmd.primal.forgecraft.blocks.*;
|
||||
import nmd.primal.forgecraft.items.blocks.ItemBlockIngotBall;
|
||||
|
||||
@@ -71,8 +83,28 @@ public class ModBlocks {
|
||||
failedironcrucible = new Crucible(Material.ROCK, "failedironcrucible");
|
||||
failedironcruciblehot = new CrucibleHot(Material.ROCK, "failedironcruciblehot");
|
||||
|
||||
ironball = new IngotBall(Material.IRON, "ironball", 5.0F);
|
||||
ironchunk = new IngotBall(Material.IRON, "ironchunk", 5.0F);
|
||||
ironball = new IngotBall(Material.IRON, "ironball", 5.0F, "ingot") {
|
||||
@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){
|
||||
Item pItem = player.getHeldItem(hand).getItem();
|
||||
BlockPos belowPos = new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ());
|
||||
|
||||
if(pItem.equals(PrimalItems.STONE_GALLAGHER) && world.getBlockState(belowPos).getBlock().equals(Blocks.STONE)){
|
||||
player.swingArm(hand);
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
world.setBlockState(belowPos, ModBlocks.stoneanvil.getDefaultState().withProperty(Anvil.FACING, player.getHorizontalFacing()), 2);
|
||||
world.playEvent(1031, pos, 0);
|
||||
//CommonUtils.spawnItemEntityFromWorld(world, pos, new ItemStack(ModBlocks.stoneanvil, 1));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
ironchunk = new IngotBall(Material.IRON, "ironchunk", 5.0F, "chunk");
|
||||
|
||||
stoneanvil = new Anvil(Material.ROCK, "stoneanvil", 5.0f);
|
||||
//ironballitemcool = new ItemBlockIngotBall(ironball);
|
||||
|
||||
@@ -7,6 +7,9 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import nmd.primal.core.api.PrimalItems;
|
||||
import nmd.primal.core.common.crafting.ToolRecipe;
|
||||
import nmd.primal.core.common.items.tools.PrimalTool;
|
||||
import nmd.primal.forgecraft.blocks.Bloomery;
|
||||
import nmd.primal.forgecraft.blocks.IngotBall;
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
@@ -19,6 +22,7 @@ import nmd.primal.forgecraft.crafting.ForgeCrafting;
|
||||
public class ModCrafting {
|
||||
|
||||
public static void register() {
|
||||
|
||||
/***Forge***/
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.firebox),
|
||||
"X X", "XYX", "X X", 'X', Items.BRICK, 'Y', Blocks.FURNACE);
|
||||
@@ -146,11 +150,33 @@ public class ModCrafting {
|
||||
1.0f
|
||||
);
|
||||
|
||||
//Makes a Charred Tool Handle
|
||||
ForgeCrafting.addRecipe(
|
||||
ModBlocks.ironchunk,
|
||||
ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, false),
|
||||
ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true),
|
||||
new ItemStack(ModBlocks.ironchunk, 1),
|
||||
ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, false),
|
||||
800,
|
||||
170,
|
||||
400,
|
||||
1.0f,
|
||||
1.0f
|
||||
);
|
||||
|
||||
// ***************************************************************************** //
|
||||
// ANVILING
|
||||
// ***************************************************************************** //
|
||||
|
||||
AnvilCrafting.addRecipe(6781014, new ItemStack(Blocks.OBSIDIAN, 1));
|
||||
//AnvilCrafting.addRecipe(6781014, new ItemStack(Blocks.OBSIDIAN, 1));
|
||||
AnvilCrafting.addRecipe(
|
||||
new Integer[] { 0,0,0,0,0,
|
||||
0,1,1,1,0,
|
||||
1,0,0,0,1,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0 },
|
||||
new ItemStack(Blocks.OBSIDIAN, 1)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import nmd.primal.forgecraft.items.blocks.ItemBlockIngotBall;
|
||||
public class ModItems {
|
||||
|
||||
public static Item pistonbellows;
|
||||
public static Item heavytoolhandle;
|
||||
public static Item softcrucible;
|
||||
public static Item stonetongs;
|
||||
//public static Item ironingotballcool;
|
||||
|
||||
Reference in New Issue
Block a user