trying nbt based crucible processing

This commit is contained in:
Mohammad-Ali Minaie
2017-11-13 07:55:44 -05:00
parent a4512116cf
commit 37ab61a195
8 changed files with 407 additions and 18 deletions

View File

@@ -1,14 +1,18 @@
To-Dos
# To-Dos
*** Bugs ***
## Bugs
*** Current Feature ***
- [x] BlockBreaker Support for copper dust and tin dust
- [x] picking up raw bronze crucible returns some other shit
- [x] Tool breaking should return tool head
## Current Feature
- [ ] Steel Plate Recipe
- [ ] NBT Crucible
- [ ] NBT Crucible Recipes
- [ ] Slotted Tongs
- [ ] Item Crucible
- [ ] NBTCrucible to ItemCrucible transformer
- [ ] StoneTongs ItemCrucible to NBTCrucible transformer
*** Feature Musket ***
## Feature Musket
- [ ] Create powder charge item (copper, charcoal, gunpowder)
- [ ] Create musket round item (lead or iron nugget)
- [ ] Create wadding item (paper)
@@ -19,7 +23,7 @@ To-Dos
- [ ] Create stock item
- [ ] Create lock assembly item
*** Backlog ***
## Backlog
- [ ] Move Ingot break into chunks logic out of the block and into the ForgeHammer
- [ ] Add Iron Ring Recipe
- [ ] Add chainmail recipe
@@ -30,12 +34,17 @@ To-Dos
- [ ] WeaponHead recipes
*** Tid-Bits ***
### Tid-Bits
```
sed -i -- 's/iron/steel/g' *
rm *.json--
rename s/iron/steel/ iron*
```
*** Completed ***
### Completed
- [x] BlockBreaker Support for copper dust and tin dust
- [x] picking up raw bronze crucible returns some other shit
- [x] Tool breaking should return tool head
- [x] Casting Table
- [x] Block
- [x] Gui

View File

@@ -20,6 +20,7 @@ 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.crafting.CrucibleHandler;
import nmd.primal.forgecraft.init.ModBlocks;
import org.apache.commons.lang3.StringUtils;
@@ -50,6 +51,9 @@ public class Crucible extends Block {
if (!world.isRemote) {
ItemStack pItem = player.inventory.getCurrentItem();
if(CrucibleHandler.getCrucibleIngredients().apply(pItem)){
System.out.println("true");
}
if(pItem.isEmpty()){
CommonUtils.spawnItemEntity(world, player, new ItemStack(this, 1));
world.setBlockToAir(pos);

View File

@@ -0,0 +1,114 @@
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.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
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.crafting.CrucibleHandler;
import nmd.primal.forgecraft.tiles.TileBaseCrucible;
import nmd.primal.forgecraft.tiles.TileNBTCrucible;
import java.util.Random;
/**
* Created by mminaie on 11/11/17.
*/
public class NBTCrucible extends Block implements ITileEntityProvider {
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D);
private Ingredient crucibleIngredients;
public NBTCrucible(Material material, String registryName) {
super(material);
setUnlocalizedName(registryName);
setRegistryName(registryName);
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setHardness(3.0f);
crucibleIngredients.apply(new ItemStack(Blocks.IRON_ORE, 1));
}
@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) {
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
ItemStack pItem = player.inventory.getCurrentItem();
if(CrucibleHandler.getCrucibleIngredients().apply(pItem)){
System.out.println("true");
}
}
return false;
}
public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state)
{
}
@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;
}
}

View File

@@ -1,6 +1,7 @@
package nmd.primal.forgecraft.crafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import java.util.ArrayList;
@@ -18,6 +19,7 @@ public class BloomeryCrafting {
private ItemStack output_failed;
private ItemStack cool_output;
private int heat_threshold;
private int ideal_time;
private int cooldown;
@@ -25,6 +27,8 @@ public class BloomeryCrafting {
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;

View File

@@ -0,0 +1,127 @@
package nmd.primal.forgecraft.crafting;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.oredict.OreDictionary;
import nmd.primal.core.api.PrimalAPI;
import nmd.primal.core.common.recipes.RecipeHandler;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.init.ModItems;
/**
* Created by mminaie on 11/11/17.
*/
public class CrucibleHandler {
private static Ingredient crucibleIngredients;
/***ALLOWED CRUCIBLE ITEMS***/
//crucibleIngredients.apply(new ItemStack(Blocks.IRON_ORE, 1));
public static Ingredient getCrucibleIngredients() {
return crucibleIngredients;
}
public static void setCrucibleIngredients(Ingredient crucibleIngredients) {
crucibleIngredients = crucibleIngredients;
}
/*
/***RAW CRUCIBLES
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawironcrucible),
"X","Y",
('X'), "oreIron",
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawcleanironcrucible),
"XL","Y ",
('X'), "dustIron",
('L'), PrimalAPI.Items.CARBONATE_SLACK,
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawsteelcrucible),
"XC","Y ",
('X'), new ItemStack(ModBlocks.ironcleanball, 1),
('C'), new ItemStack(PrimalAPI.Items.CHARCOAL_HIGH),
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"XCX"," X "," Y ",
('X'), "dustCopper",
('C'), "dustTin",
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"XXX"," X "," Y ",
('X'), "nuggetBronze",
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"X","Y",
('X'), new ItemStack(ModItems.bronzepickaxehead, 1,OreDictionary.WILDCARD_VALUE),
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"X","Y",
('X'), new ItemStack(ModItems.bronzeaxehead, 1, OreDictionary.WILDCARD_VALUE),
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"X","Y",
('X'), new ItemStack(ModItems.bronzeshovelhead, 1, OreDictionary.WILDCARD_VALUE),
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"X","Y",
('X'), new ItemStack(ModItems.bronzehoehead, 1, OreDictionary.WILDCARD_VALUE),
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible),
"X","Y",
('X'), new ItemStack(ModItems.bronzegladius, 1, OreDictionary.WILDCARD_VALUE),
('Y'), ModBlocks.emptycrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible_redstone),
"R","Y",
('R'), Items.REDSTONE,
('Y'), ModBlocks.rawbronzecrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible_diamond),
"D","Y",
('D'), PrimalAPI.Items.DIAMOND_KNAPP,
('Y'), ModBlocks.rawbronzecrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible_lapis),
"L","Y",
('L'), new ItemStack(Items.DYE, 1, 4),
('Y'), ModBlocks.rawbronzecrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible_emerald),
"E","Y",
('E'), PrimalAPI.Items.EMERALD_KNAPP,
('Y'), ModBlocks.rawbronzecrucible);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawbronzecrucible, 1),
"T", "Y",
('T'), new ItemStack(ModItems.brokenbronzetool, 1),
('Y'), new ItemStack(ModBlocks.emptycrucible, 1)
);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawironcrucible, 1),
"T", "Y",
('T'), new ItemStack(ModItems.brokenwroughtirontool, 1),
('Y'), new ItemStack(ModBlocks.emptycrucible, 1)
);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawcleanironcrucible, 1),
"T", "Y",
('T'), new ItemStack(ModItems.brokencleanirontool, 1),
('Y'), new ItemStack(ModBlocks.emptycrucible, 1)
);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawsteelcrucible, 1),
"T", "Y",
('T'), new ItemStack(ModItems.brokensteeltool, 1),
('Y'), new ItemStack(ModBlocks.emptycrucible, 1)
);
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.rawwootzcrucible, 1),
"T", "Y",
('T'), new ItemStack(ModItems.brokenwootztool, 1),
('Y'), new ItemStack(ModBlocks.emptycrucible, 1)
);
*/
}

View File

@@ -4,28 +4,35 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.OreIngredient;
import nmd.primal.core.api.PrimalAPI;
import nmd.primal.core.common.helper.CommonUtils;
import nmd.primal.core.common.recipes.RecipeHandler;
import nmd.primal.forgecraft.crafting.AnvilCrafting;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
import nmd.primal.forgecraft.crafting.CastingformCrafting;
import nmd.primal.forgecraft.crafting.ForgeCrafting;
import nmd.primal.forgecraft.crafting.*;
import nmd.primal.forgecraft.crafting.CrucibleHandler;
import java.util.Random;
/**
* Created by kitsu on 11/30/2016.
*/
public class ModCrafting {
public class ModCrafting{
public static void register() {
Random rand = new Random();
//RecipeHandler.addShapedOreRecipe();
CrucibleHandler.setCrucibleIngredients(new OreIngredient("oreIron"));
CrucibleHandler.setCrucibleIngredients(new OreIngredient("dustIron"));
CrucibleHandler.setCrucibleIngredients(new OreIngredient("dustTin"));
CrucibleHandler.setCrucibleIngredients(new OreIngredient("dustCopper"));
//CrucibleHandler.setCrucibleIngredients();
//.fromItems(PrimalAPI.Items.CARBONATE_SLACK, PrimalAPI.Items.CHARCOAL_HIGH));
/***CASTING BLOCK***/
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.castingblock),
" B ", "BXB", " B ", 'X', Blocks.STONE_SLAB, 'B', PrimalAPI.Items.ADOBE_BRICK_DRY);
@@ -70,7 +77,7 @@ public class ModCrafting {
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.bloomery_adobe),
"X X", "X X", "XXX", 'X', PrimalAPI.Items.ADOBE_BRICK_DRY);
/***Block Breaker***/
/***Block Breaker***/
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.blockbreaker),
"L ", "BSB", "BBB", 'L', Blocks.LEVER, 'B', new ItemStack(Blocks.PLANKS, 1, OreDictionary.WILDCARD_VALUE), 'S', PrimalAPI.Items.SILK_CORDAGE_COILED);

View File

@@ -0,0 +1,53 @@
package nmd.primal.forgecraft.items;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.ModInfo;
import javax.annotation.Nullable;
import java.util.List;
/**
* Created by mminaie on 11/11/17.
*/
public class ItemCrucible extends Item {
public ItemCrucible(String unlocalizedName) {
setUnlocalizedName(unlocalizedName);
this.setRegistryName(unlocalizedName);
this.setMaxStackSize(1);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, @Nullable World world, List<String> tooltip, ITooltipFlag flagIn)
{
if(!item.isEmpty())
{
if (item.hasTagCompound())
{
/*tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
if (getEmerald(item) == true) {
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
}
if (getDiamondLevel(item) > 0) {
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
}
if (getRedstoneLevel(item) > 0) {
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
}
if (getLapisLevel(item) > 0) {
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
}
tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() );*/
}
}
}
}

View File

@@ -0,0 +1,71 @@
package nmd.primal.forgecraft.tiles;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ITickable;
import net.minecraft.world.World;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
/**
* Created by mminaie on 11/11/17.
*/
public class TileNBTCrucible extends BaseTile implements ITickable {
private Item drops;
private int heat;
private boolean hot;
private String mod0, mod1, mod2;
@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;
}
}
}*/
}
}
// ***************************************************************************** //
// NBT
// ***************************************************************************** //
@Override
public NBTTagCompound readNBT(NBTTagCompound nbt)
{
super.readNBT(nbt);
this.mod0 = nbt.getString("mod0");
this.mod1 = nbt.getString("mod1");
this.mod2 = nbt.getString("mod2");
this.heat = nbt.getInteger("heat");
this.hot = nbt.getBoolean("hot");
return nbt;
}
@Override
public NBTTagCompound writeNBT(NBTTagCompound nbt)
{
nbt.setInteger("heat", this.heat);
nbt.setString("mod0", this.mod0);
nbt.setString("mod1", this.mod1);
nbt.setString("mod2", this.mod2);
nbt.setBoolean("hot", this.hot);
super.writeNBT(nbt);
return nbt;
}
}