From 01250d528c3fb72f7d266178539101196cb18fa7 Mon Sep 17 00:00:00 2001 From: Mohammad-Ali Minaie Date: Thu, 25 Jan 2018 13:34:04 -0500 Subject: [PATCH] crucible happy path is working --- .../blocks/Crucibles/NBTCrucible.java | 21 ++++++++++---- .../primal/forgecraft/tiles/TileBloomery.java | 7 +++-- .../forgecraft/tiles/TileNBTCrucible.java | 26 ++++++++++++++++-- .../assets/forgecraft/textures/Thumbs.db | Bin 0 -> 4096 bytes 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 kfc/src/main/resources/assets/forgecraft/textures/Thumbs.db 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 c178711b..a350830e 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 @@ -32,6 +32,7 @@ import nmd.primal.core.common.helper.PlayerHelper; import nmd.primal.core.common.helper.WorldHelper; import nmd.primal.core.common.tiles.machines.TileStorageCrate; import nmd.primal.forgecraft.ModInfo; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; import nmd.primal.forgecraft.init.ModItems; import nmd.primal.forgecraft.items.ItemCrucible; import nmd.primal.forgecraft.items.SlottedTongs; @@ -66,8 +67,13 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider, TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos); ItemStack pItem = player.inventory.getCurrentItem(); ItemStack pItem1 = new ItemStack(pItem.getItem(), 1); + /**PICKS UP THE CRUCIBLE**/ if(pItem.isEmpty()){ if(!player.isSneaking()) { + CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4)); + if(recipe != null){ + tile.setDrops(recipe.getDropsRaw()); + } return takeBlock(world, pos, state, face, player); } } @@ -128,7 +134,6 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider, if (tile instanceof TileNBTCrucible) { PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, this.getItem(world, pos, state)); - //world.updateComparatorOutputLevel(pos, state.getBlock()); return world.setBlockState(pos, this.getReplacementBlock(world, pos, state)); } @@ -139,10 +144,16 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider, @Override public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { - // Spawn the dropped daub repair_item here to avoid collision with the remaining block, - // otherwise the repair_item entities was getting thrown off in random directions well beyond pickup range - //if (!world.isRemote) - // CommonUtils.spawnItemOnPlayer(world, player, this.getItem(world, pos, state)); + if (!world.isRemote) { + TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos); + ItemStack pItem = player.inventory.getCurrentItem(); + CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4)); + System.out.println("Harvested" + tile.getStatus() + " | " + tile.getHot()); + if(recipe != null && tile.getStatus() && !tile.getHot()){ + PlayerHelper.spawnItemOnPlayer(world, player, tile.getDrops()); + System.out.println("Drop stuff"); + } + } } @Override 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 be3b9be9..9ced3b93 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBloomery.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBloomery.java @@ -81,9 +81,11 @@ public class TileBloomery extends TileBaseSlot implements ITickable { private void slotOneManager(){ NonNullList ingList = NonNullList.withSize(5, ItemStack.EMPTY); + NonNullList dropList = NonNullList.withSize(1, ItemStack.EMPTY); NBTTagCompound tag = this.getSlotStack(1).getSubCompound("BlockEntityTag"); if(tag != null) { ItemStackHelper.loadAllItems(tag, ingList); + ItemStackHelper.loadAllItems(tag, dropList); CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4)); if (recipe != null) { if (this.getHeat() >= recipe.getCookTemp() && @@ -93,11 +95,10 @@ public class TileBloomery extends TileBaseSlot implements ITickable { this.updateBlock(); this.markDirty(); } - if (cookCounter >= recipe.getCookTime() && - !this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) { - + if (cookCounter >= recipe.getCookTime() && !this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) { this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("status", true); cookCounter = 0; + //dropList.set(0, recipe.getDropsCooked()); this.updateBlock(); this.markDirty(); } 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 8c429012..fb9c10ea 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileNBTCrucible.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileNBTCrucible.java @@ -8,22 +8,23 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.world.World; +import nmd.primal.forgecraft.crafting.CrucibleCrafting; /** * Created by mminaie on 11/11/17. */ public class TileNBTCrucible extends BaseTile implements ITickable { - private Item drops; + private ItemStack drops; private int heat; private boolean hot; private boolean status; - public Item getDrops() { + public ItemStack getDrops() { return drops; } - public void setDrops(Item drops) { + public void setDrops(ItemStack drops) { this.drops = drops; } @@ -60,13 +61,29 @@ public class TileNBTCrucible extends BaseTile implements ITickable { } public NonNullList ingList = NonNullList.withSize(5, ItemStack.EMPTY); + //public NonNullList dropList = NonNullList.withSize(1, ItemStack.EMPTY); @Override public void update () { if (!world.isRemote) { World world = this.getWorld(); IBlockState state = world.getBlockState(this.pos); + coolManager(); + } + } + private void coolManager() { + if(this.getHot()){ + if(this.getHeat() > 0){ + this.setHeat( this.getHeat() - 1); + System.out.println(this.getHeat()); + } + if(this.getHeat() == 0){ + this.setHot(false); + CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4)); + this.setDrops(recipe.getDropsCooked()); + } + //CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4)); } } @@ -79,6 +96,8 @@ public class TileNBTCrucible extends BaseTile implements ITickable { super.readNBT(nbt); this.ingList = NonNullList.withSize(this.ingList.size(), ItemStack.EMPTY); ItemStackHelper.loadAllItems(nbt, this.ingList); + //this.dropList = NonNullList.withSize(this.dropList.size(), ItemStack.EMPTY); + //ItemStackHelper.loadAllItems(nbt, this.dropList); this.heat = nbt.getInteger("heat"); this.hot = nbt.getBoolean("hot"); this.status = nbt.getBoolean("status"); @@ -89,6 +108,7 @@ public class TileNBTCrucible extends BaseTile implements ITickable { public NBTTagCompound writeNBT(NBTTagCompound nbt) { ItemStackHelper.saveAllItems(nbt, this.ingList); + //ItemStackHelper.saveAllItems(nbt, this.dropList); nbt.setInteger("heat", this.heat); nbt.setBoolean("hot", this.hot); nbt.setBoolean("status", this.status); diff --git a/kfc/src/main/resources/assets/forgecraft/textures/Thumbs.db b/kfc/src/main/resources/assets/forgecraft/textures/Thumbs.db new file mode 100644 index 0000000000000000000000000000000000000000..e1b47e865e3fa4c2763177db24570c055a341c04 GIT binary patch literal 4096 zcmeHIc~I1K6o0?{{g!26U07HSAtf$F$}uhhO_m$k#uy+n$)-3Bnj-K()@%nwFhr0P zks3#d!+^>GZ^t4oE5;%v4zU>yMFg7?kYfS)^}f46zzh!dS2Vnx&+onWz21A@_kC}F ztrNB7mKwFgEOG%F##uh7O&h0BCQy<#00#x4kFzYR8U#RbkrvPmJV9Sc{s!XG~pFIss@;Wj`DuQMQ9n zL?n6>iFTdP6KAFDG-K~{#TvUHu{%lA=jM{NaKdQ9{#IgnU1EGl!AeJD62+|+$F91Xc9fU4IjL<{qBMcCRh@}W4gfU{Vr%cb(e?ulY zBDv3>c#oG?SIE{EE$d{P**4IYdi#0V$ww$wZ4=GwkncgH4zA!zQ)a*sQM8C+tHA`H zGZ(#`au{_E&2ZIt>U<4NTyQ}fy9G^i7@Esv@U>HWaUK{ESI5-GO-D?Syf$g{f8fas=ZbJTSH@0^X-=Qj=T3d?{_`u?&^ZaG^`jQaZy04!kUU~ zR$L;Ci^Gt-khmyLJPBOHa7}I0blm)TA+fqHBQ`ZITEV%wcm?>4WCfH--R;FvUN$odL`yHiP<$aQ_mg42ROJv&&UKvJPfvZ!~ zyFBG}ih;bd(OQ1}skX7H{ptPeZ7f@5k0qsx?^sE0`72X8cRAc&2=%KC+Kct8>`M#2 zeurH&6ON0+z54Ulhk6*>)s`iv9b@dh!osZ$-#;R4E9^+BS>CJ{(HCL-QNHBc48aX) z%*H`QqO>&hx$}EEynktwTU7q6>F#vLx(z7P#22^Z9Qv^8UQp1cudY~>tXdP7kk!)D zCapc1tzqt&<~v%mx6I3!oBZ;!9=*4igQce{vok(E)!29`>*QnEdxb1S`>Co!RTGQf Hxo_ZaOO^Ve literal 0 HcmV?d00001