add slot manager for crafting check comment

This commit is contained in:
Mohammad-Ali Minaie
2017-01-24 22:17:52 -05:00
parent 8b41ae6205
commit 0b03f84e5a
12 changed files with 418 additions and 27 deletions

View File

@@ -10,12 +10,13 @@ To-Dos
- [ ] Iron Success Output
- [ ] Iron Post Fail Output
- [ ] Crucible
- [X] Soft Crucible
- [x] Model
- [ ] Block
- [ ] Tile
- [x] Item
- [ ] Tongs
- [ ] Model
- [ ] Item(s)
- [x] Tongs
- [x] Model
- [x] Item(s)
- [ ] Functionality

View File

@@ -52,7 +52,8 @@ public class ModInfo {
public enum ForgecraftBlocks {
FIREBOX("firebox", "firebox"),
PISTONBELLOWS("pistonbellows", "pistonbellows"),
BLOOMERY("bloomery", "bloomery");
BLOOMERY("bloomery", "bloomery"),
EMPTYCRUCIBLE("emptycrucible", "emptycrucible");
private String unlocalizedName;
private String registryName;

View File

@@ -28,6 +28,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.tiles.TileBloomery;
import nmd.primal.forgecraft.tiles.TileFirebox;
@@ -65,6 +66,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
if (tile != null) {
ItemStack pItem = player.inventory.getCurrentItem();
ItemStack tileItem = tile.getSlotStack(0);
ItemStack tileItem1 = tile.getSlotStack(1);
if(pItem.isEmpty()) {
/*if (player.isSneaking()) {
if (!tileItem.isEmpty()) {
@@ -101,6 +103,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
if(tileItem.getCount() < 64){
if(tileItem.getCount() + pItem.getCount() <= 64){
tileItem.grow(pItem.getCount());
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
tile.markDirty();
tile.updateBlock();
return true;
@@ -121,6 +124,18 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
return true;
}
}
if((!pItem.isEmpty()) && tile.isItemValidForSlot(1, pItem)) {
if (!tileItem1.isEmpty()) {
return false;
}
if(tileItem1.isEmpty()){
ItemStack tempItem = new ItemStack(ModItems.softcrucible, 1);
tile.setSlotStack(1, tempItem);
pItem.shrink(1);
}
}
if(!pItem.isEmpty()) {
if(pItem.getItem() == Item.getItemFromBlock(Blocks.STONE_SLAB)){
world.setBlockState(pos, state.withProperty(COVERED, true), 2);

View File

@@ -0,0 +1,69 @@
package nmd.primal.forgecraft.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.ModInfo;
/**
* Created by mminaie on 1/24/17.
*/
public class EmptyCrucible extends Block {
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D);
public EmptyCrucible(Material material, String registryName) {
super(material);
setUnlocalizedName(ModInfo.ForgecraftBlocks.EMPTYCRUCIBLE.getUnlocalizedName());
setRegistryName(registryName);
//setRegistryName(ModInfo.ForgecraftBlocks.FIREBOX.getRegistryName());
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setHardness(3.0f);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
return boundBox;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullyOpaque(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

@@ -117,6 +117,7 @@ public class Firebox extends CustomContainerFacing implements ITileEntityProvide
if(tileItem.getCount() < 64){
if(tileItem.getCount() + pItem.getCount() <= 64){
tileItem.grow(pItem.getCount());
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
tile.markDirty();
tile.updateBlock();
return true;

View File

@@ -0,0 +1,106 @@
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<BloomeryCrafting> bloomeryRecipes = new ArrayList<>();
private ItemStack input;
private ItemStack output;
private ItemStack output_failed;
private int heat_threshold;
private int ideal_time;
private float heat_variance;
private float time_variance;
public BloomeryCrafting(ItemStack input, ItemStack output, ItemStack output_failed, int heat_threshold, int ideal_time, float heat_variance, float time_variance)
{
this.input = input;
this.output = output;
this.output_failed = output_failed;
this.heat_threshold = heat_threshold;
this.ideal_time = ideal_time;
this.heat_variance = heat_variance;
this.time_variance = time_variance;
}
// ***************************************************************************** //
// Recipe Methods
// ***************************************************************************** //
public static void addRecipe(ItemStack input, ItemStack output, ItemStack output_failed, int heat_threshold, int ideal_time, float heat_variance, float time_variance)
{
bloomeryRecipes.add(new BloomeryCrafting(input, output, output_failed, heat_threshold, ideal_time, 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 BloomeryCrafting getRecipe(ItemStack stack)
{
for(BloomeryCrafting recipe : bloomeryRecipes) {
if (stack.isItemEqual(recipe.input))
return recipe;
}
return null;
}
public ItemStack getInput()
{
return this.input;
}
public ItemStack getOutput()
{
return this.output;
}
public ItemStack getOutputFailed()
{
return this.output_failed;
}
public int getHeatThreshold()
{
return this.heat_threshold;
}
public int getIdealTime()
{
return this.ideal_time;
}
public float getHeat_variance(){return this.heat_variance; }
public float getTime_variance(){return this.time_variance; }
///
// end
///
}

View File

@@ -8,6 +8,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.blocks.Bloomery;
import nmd.primal.forgecraft.blocks.EmptyCrucible;
import nmd.primal.forgecraft.blocks.Firebox;
import nmd.primal.forgecraft.blocks.PistonBellows;
@@ -24,6 +25,7 @@ public class ModBlocks {
public static Block pistonbellowsspruce;
public static Block pistonbellowsdarkoak;
public static Block pistonbellowsacacia;
public static Block emptycrucible;
public static void init() {
@@ -36,6 +38,7 @@ public class ModBlocks {
pistonbellowsdarkoak = new PistonBellows(Material.WOOD, "pistonbellowsdarkoak");
pistonbellowsacacia = new PistonBellows(Material.WOOD, "pistonbellowsacacia");
bloomery = new Bloomery(Material.ROCK, "bloomery");
emptycrucible = new EmptyCrucible(Material.ROCK, "emptycrucible");
}
public static void register() {
@@ -47,6 +50,7 @@ public class ModBlocks {
registerBlock(pistonbellowsdarkoak);
registerBlock(pistonbellowsacacia);
registerBlock(bloomery);
registerBlock(emptycrucible);
}
public static void registerRenders() {
@@ -58,6 +62,7 @@ public class ModBlocks {
registerRender(pistonbellowsdarkoak);
registerRender(pistonbellowsacacia);
registerRender(bloomery);
registerRender(emptycrucible);
}
private static void registerBlock(Block block) {

View File

@@ -4,6 +4,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.blocks.Bloomery;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
/**
* Created by kitsu on 11/30/2016.
@@ -28,6 +30,19 @@ public class ModCrafting {
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.pistonbellowsdarkoak), "XXX", "X Y", "XXX",
'X', new ItemStack(Blocks.PLANKS, 1, 5), 'Y', ModItems.pistonbellows);
/***Bellows Handle***/
GameRegistry.addShapedRecipe(new ItemStack(ModItems.pistonbellows), "X X", "X X", " X ", 'X', Items.STICK);
/***Bloomery Crafting***/
//DryingRecipe.addRecipe(new ItemStack(Items.FISH, 1, 0), new ItemStack(PrimalItems.FISH_COD_DRIED), new ItemStack(PrimalItems.FISH_COD_ROTTEN), 25, 0.006F);
BloomeryCrafting.addRecipe(
new ItemStack(ModItems.softcrucible, 1),
new ItemStack(ModBlocks.emptycrucible, 1),
//new ItemStack(ModItems.crackedcrucible, 1),
new ItemStack(Items.STICK, 1),
2100,
2400,
0.25f,
1.0f);
}
}

View File

@@ -32,31 +32,42 @@ public class TileBloomeryRender extends TileEntitySpecialRenderer<TileBloomery>
int bright = tile.getWorld().getCombinedLight(pos.up(), 0);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, bright % 65536, bright / 65536);
ItemStack stack1 = tile.getSlotStack(0);
ItemStack stack0 = tile.getSlotStack(0);
ItemStack stack1 = tile.getSlotStack(1);
boolean is_block = stack1.getItem() instanceof ItemBlock;
if (!stack0.isEmpty()) {
boolean is_block = stack0.getItem() instanceof ItemBlock;
float scale = is_block ? 0.1725F : 0.3F;
double xTrans = is_block ? -1.6D : -0.45D;
double yTrans = is_block ? -1.26D : -0.7D;
int stackRotation = stack0.getCount();
if (!stack1.isEmpty()) {
int stackRotation = stack1.getCount();
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F);
renderItem.renderItem(stack1, renderItem.getItemModelMesher().getItemModel(stack1));
renderItem.renderItem(stack0, renderItem.getItemModelMesher().getItemModel(stack0));
GL11.glPopMatrix();
for(int i = 0; i < Math.ceil(stackRotation/8) + 1; i++){
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
GL11.glRotated(45.0F * i, 0.0F, 1.0F, 0.0F);
GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslated(xTrans, yTrans, 0.0D);
renderItem.renderItem(stack1, renderItem.getItemModelMesher().getItemModel(stack1));
renderItem.renderItem(stack0, renderItem.getItemModelMesher().getItemModel(stack0));
GL11.glPopMatrix();
}
}
if(!stack1.isEmpty()){
GL11.glPushMatrix();
GL11.glTranslated(0, 0.50D, 0);
renderItem.renderItem(stack1, renderItem.getItemModelMesher().getItemModel(stack1));
GL11.glPopMatrix();
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY);
GL11.glPopMatrix();
}

View File

@@ -13,6 +13,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.forgecraft.blocks.Bloomery;
import nmd.primal.forgecraft.blocks.Firebox;
import nmd.primal.forgecraft.init.ModItems;
import static nmd.primal.forgecraft.CommonUtils.getVanillaItemBurnTime;
@@ -40,6 +41,17 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
this.markDirty();
world.notifyBlockUpdate(pos, state, state, 2);
}
slotZeroManager(world);
}
this.heatManager(this.getHeat(), state, this.getSlotStack(0));
}
}
}
//Insert Slot 1 manager for crafting
private void slotZeroManager(World world){
if(this.getSlotStack(0) != ItemStack.EMPTY) {
Integer decrInt = (int) Math.floor(getVanillaItemBurnTime(this.getSlotStack(0)) / 20);
if(decrInt == 0) {
@@ -50,9 +62,10 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
this.markDirty();
this.updateBlock();
}
}
}
this.heatManager(this.getHeat(), state, this.getSlotStack(0));
if (this.getSlotStack(0).getCount() == 1){
this.decrStackSize(0, 1);
this.markDirty();
this.updateBlock();
}
}
}
@@ -114,6 +127,11 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
}
}
}
if(index == 1){
if (stack.getItem() == ModItems.softcrucible) {
return true;
}
}
return false;
}

View File

@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "forgecraft:emptycrucible" }
}
}

View File

@@ -0,0 +1,144 @@
{
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "forgecraft:blocks/stone_slab",
"texture": "forgecraft:blocks/stone_slab"
},
"elements": [
{
"__comment": "Cube1",
"from": [ 5, 0, 5 ],
"to": [ 11, 1, 11 ],
"faces": {
"down": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"up": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"north": { "uv": [ 5, 15, 11, 16 ], "texture": "#texture" },
"south": { "uv": [ 5, 15, 11, 16 ], "texture": "#texture" },
"west": { "uv": [ 5, 15, 11, 16 ], "texture": "#texture" },
"east": { "uv": [ 5, 15, 11, 16 ], "texture": "#texture" }
}
},
{
"__comment": "Cube11",
"from": [ 5, 1, 5 ],
"to": [ 11, 7, 6 ],
"faces": {
"down": { "uv": [ 5, 10, 11, 11 ], "texture": "#texture" },
"up": { "uv": [ 5, 5, 11, 6 ], "texture": "#texture" },
"north": { "uv": [ 5, 9, 11, 15 ], "texture": "#texture" },
"south": { "uv": [ 5, 9, 11, 15 ], "texture": "#texture" },
"west": { "uv": [ 5, 9, 6, 15 ], "texture": "#texture" },
"east": { "uv": [ 10, 9, 11, 15 ], "texture": "#texture" }
}
},
{
"__comment": "Cube11",
"from": [ 5, 1, 10 ],
"to": [ 11, 7, 11 ],
"faces": {
"down": { "uv": [ 5, 10, 11, 11 ], "texture": "#texture" },
"up": { "uv": [ 5, 5, 11, 6 ], "texture": "#texture" },
"north": { "uv": [ 5, 9, 11, 15 ], "texture": "#texture" },
"south": { "uv": [ 5, 9, 11, 15 ], "texture": "#texture" },
"west": { "uv": [ 5, 9, 6, 15 ], "texture": "#texture" },
"east": { "uv": [ 10, 9, 11, 15 ], "texture": "#texture" }
}
},
{
"__comment": "Cube13",
"from": [ 5, 1, 6 ],
"to": [ 6, 7, 10 ],
"faces": {
"down": { "uv": [ 5, 6, 6, 10 ], "texture": "#texture" },
"up": { "uv": [ 5, 6, 6, 10 ], "texture": "#texture" },
"north": { "uv": [ 10, 9, 11, 15 ], "texture": "#texture" },
"south": { "uv": [ 5, 9, 6, 15 ], "texture": "#texture" },
"west": { "uv": [ 6, 9, 10, 15 ], "texture": "#texture" },
"east": { "uv": [ 6, 9, 10, 15 ], "texture": "#texture" }
}
},
{
"__comment": "Cube13",
"from": [ 10, 1, 6 ],
"to": [ 11, 7, 10 ],
"faces": {
"down": { "uv": [ 5, 6, 6, 10 ], "texture": "#texture" },
"up": { "uv": [ 5, 6, 6, 10 ], "texture": "#texture" },
"north": { "uv": [ 10, 9, 11, 15 ], "texture": "#texture" },
"south": { "uv": [ 5, 9, 6, 15 ], "texture": "#texture" },
"west": { "uv": [ 6, 9, 10, 15 ], "texture": "#texture" },
"east": { "uv": [ 6, 9, 10, 15 ], "texture": "#texture" }
}
},
{
"__comment": "Cube15",
"from": [ 4, 5, 6 ],
"to": [ 5, 6, 10 ],
"faces": {
"down": { "uv": [ 4, 6, 5, 10 ], "texture": "#texture" },
"up": { "uv": [ 4, 6, 5, 10 ], "texture": "#texture" },
"north": { "uv": [ 11, 10, 12, 11 ], "texture": "#texture" },
"south": { "uv": [ 4, 10, 5, 11 ], "texture": "#texture" },
"west": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" },
"east": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" }
}
},
{
"__comment": "Cube15",
"from": [ 11, 5, 6 ],
"to": [ 12, 6, 10 ],
"faces": {
"down": { "uv": [ 4, 6, 5, 10 ], "texture": "#texture" },
"up": { "uv": [ 4, 6, 5, 10 ], "texture": "#texture" },
"north": { "uv": [ 11, 10, 12, 11 ], "texture": "#texture" },
"south": { "uv": [ 4, 10, 5, 11 ], "texture": "#texture" },
"west": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" },
"east": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" }
}
},
{
"__comment": "Cube17",
"from": [ 6, 5, 4 ],
"to": [ 10, 6, 5 ],
"faces": {
"down": { "uv": [ 6, 11, 10, 12 ], "texture": "#texture" },
"up": { "uv": [ 6, 4, 10, 5 ], "texture": "#texture" },
"north": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" },
"south": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" },
"west": { "uv": [ 4, 10, 5, 11 ], "texture": "#texture" },
"east": { "uv": [ 11, 10, 12, 11 ], "texture": "#texture" }
}
},
{
"__comment": "Cube18",
"from": [ 6, 5, 11 ],
"to": [ 10, 6, 12 ],
"faces": {
"down": { "uv": [ 6, 4, 10, 5 ], "texture": "#texture" },
"up": { "uv": [ 6, 11, 10, 12 ], "texture": "#texture" },
"north": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" },
"south": { "uv": [ 6, 10, 10, 11 ], "texture": "#texture" },
"west": { "uv": [ 11, 10, 12, 11 ], "texture": "#texture" },
"east": { "uv": [ 4, 10, 5, 11 ], "texture": "#texture" }
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [ 0.1, 1.1, -2.35 ]
},
"firstperson_righthand": {
"translation": [ 0, 4, 0 ]
},
"gui": {
"translation": [ 0, 4, 0 ]
},
"ground": {
"translation": [ 0, 4, 0 ]
},
"fixed": {
"rotation": [ 45, 45, 0 ],
"translation": [ 0, 4, 0 ]
}
}
}