happy path achieved

This commit is contained in:
Mohammad-Ali Minaie
2018-01-07 00:45:42 -05:00
parent 008332636b
commit 81c9ff54a7
9 changed files with 205 additions and 37 deletions

View File

@@ -6,10 +6,12 @@ org.gradle.jvmargs=-Xmx3G
mod_group=nmd.primal.forgecraft mod_group=nmd.primal.forgecraft
mod_name=ForgeCraft mod_name=ForgeCraft
mod_version=1.4.01 mod_version=1.4.04
forge_version=14.23.1.2566 forge_version=14.23.1.2581
mcp_mappings=snapshot_20171003 mcp_mappings=snapshot_20171003
mc_version=1.12.2 mc_version=1.12.2
primal_version=0.6+ primal_version=0.6+
jei_version=4.8+ jei_version=4.8+
waila_version=1.7.0-B3
apple_version=2.1+

View File

@@ -19,7 +19,7 @@ public class ModInfo {
public static final String MOD_CHANNEL = MOD_ID; public static final String MOD_CHANNEL = MOD_ID;
public static final String MOD_VERSION = "1.4.01"; public static final String MOD_VERSION = "1.4.01";
public static final String MC_VERSIONS = "[1.12.0, 1.13.0)"; public static final String MC_VERSIONS = "[1.12.0, 1.13.0)";
public static final String DEPENDENCIES = "required-after:forge@[14.21.1.2400,);" + "required-after:primal@[0.6.0,);"; public static final String DEPENDENCIES = "required-after:forge@[14.21.1.2400,);" + "required-after:primal@[0.6,);";
/** Mod Structures **/ /** Mod Structures **/
public static final String SERVER_PROXY = "nmd.primal.forgecraft.proxy.ServerProxy"; public static final String SERVER_PROXY = "nmd.primal.forgecraft.proxy.ServerProxy";

View File

@@ -10,6 +10,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@@ -27,6 +28,8 @@ import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.core.common.recipes.FireSource; import nmd.primal.core.common.recipes.FireSource;
import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.crafting.BloomeryCrafting; import nmd.primal.forgecraft.crafting.BloomeryCrafting;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.items.SlottedTongs;
import nmd.primal.forgecraft.tiles.TileBloomery; import nmd.primal.forgecraft.tiles.TileBloomery;
import java.util.Random; import java.util.Random;
@@ -177,6 +180,41 @@ public class BloomeryBase extends CustomContainerFacing implements ITileEntityPr
} }
} }
/***SLOTTED TONGS CODE TO PLACE THE ITEMS***/
if(pItem.getItem() instanceof SlottedTongs) {
SlottedTongs temp = (SlottedTongs) pItem.getItem();
if (!pItem.isEmpty() && tile.isItemValidForSlot(1, temp.slotList.get(0))) {
if (!tileItem1.isEmpty()) {
return false;
}
if(tileItem1.isEmpty()){
ItemStack place_stack = temp.slotList.get(0).copy();
//if (tile.putStack(slot, place_stack))
tile.setSlotStack(1, place_stack);
temp.slotList.set(0, ItemStack.EMPTY);
return true;
}
}
}
/***SLOTTED TONGS CODE TO REMOVE THE ITEMS***/
if(pItem.getItem() instanceof SlottedTongs) {
SlottedTongs temp = (SlottedTongs) pItem.getItem();
if (!pItem.isEmpty() && temp.slotList.get(0).isEmpty()) {
if (tileItem1.isEmpty()) {
return false;
}
if(!tileItem1.isEmpty()){
ItemStack place_stack = tileItem1.copy();
if(temp.slotList.get(0).isEmpty()){
temp.slotList.set(0, place_stack);
tile.setSlotStack(1, ItemStack.EMPTY);
return true;
}
}
}
}
if (!tile.getSlotStack(0).isEmpty()) { if (!tile.getSlotStack(0).isEmpty()) {
if(player.inventory.getCurrentItem().getItem() instanceof ItemSpade) { if(player.inventory.getCurrentItem().getItem() instanceof ItemSpade) {
ItemStack returnStack = tile.getSlotStack(0).copy(); ItemStack returnStack = tile.getSlotStack(0).copy();

View File

@@ -34,6 +34,7 @@ import nmd.primal.core.common.tiles.machines.TileStorageCrate;
import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModItems; import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.items.ItemCrucible; import nmd.primal.forgecraft.items.ItemCrucible;
import nmd.primal.forgecraft.items.SlottedTongs;
import nmd.primal.forgecraft.tiles.TileBaseCrucible; import nmd.primal.forgecraft.tiles.TileBaseCrucible;
import nmd.primal.forgecraft.tiles.TileNBTCrucible; import nmd.primal.forgecraft.tiles.TileNBTCrucible;
@@ -73,6 +74,9 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
/**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/ /**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/
if(!player.isSneaking()) { if(!player.isSneaking()) {
if(!pItem.isEmpty()) { if(!pItem.isEmpty()) {
if(pItem.getItem() instanceof SlottedTongs) {
return false;
} else {
for (int i = 0; i < tile.ingList.size(); i++) { for (int i = 0; i < tile.ingList.size(); i++) {
if (tile.ingList.get(i).isEmpty()) { if (tile.ingList.get(i).isEmpty()) {
tile.ingList.set(i, pItem1); tile.ingList.set(i, pItem1);
@@ -84,6 +88,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
} }
} }
} }
}
/**CLEARS THE INVENTORY**/ /**CLEARS THE INVENTORY**/
if(player.isSneaking()){ if(player.isSneaking()){
for(int i=0; i<tile.ingList.size(); i++){ for(int i=0; i<tile.ingList.size(); i++){

View File

@@ -32,6 +32,7 @@ import nmd.primal.forgecraft.items.weapons.SlayerSword;
public class ModItems { public class ModItems {
//public static Item test; //public static Item test;
public static Item slottedtongs;
public static Item itemcrucible; public static Item itemcrucible;
public static Item bellowshandle; public static Item bellowshandle;
public static Item forgehammer; public static Item forgehammer;
@@ -143,6 +144,7 @@ public class ModItems {
public static void init() { public static void init() {
//OBJLoader.INSTANCE.addDomain(ModInfo.MOD_ID); //OBJLoader.INSTANCE.addDomain(ModInfo.MOD_ID);
//pistonbellows = new ItemBellowsHandle("pistonbellows"); //pistonbellows = new ItemBellowsHandle("pistonbellows");
slottedtongs = new SlottedTongs("slottedtongs");
itemcrucible = new ItemCrucible("itemcrucible"); itemcrucible = new ItemCrucible("itemcrucible");
bellowshandle = new BaseItem("bellowshandle"); bellowshandle = new BaseItem("bellowshandle");
softcrucible = new ItemSoftCrucible("softcrucible"); softcrucible = new ItemSoftCrucible("softcrucible");
@@ -268,6 +270,7 @@ public class ModItems {
} }
public static void register() { public static void register() {
ForgeRegistries.ITEMS.register(slottedtongs);
ForgeRegistries.ITEMS.register(itemcrucible); ForgeRegistries.ITEMS.register(itemcrucible);
ForgeRegistries.ITEMS.register(castingmud); ForgeRegistries.ITEMS.register(castingmud);
ForgeRegistries.ITEMS.register(bellowshandle); ForgeRegistries.ITEMS.register(bellowshandle);

View File

@@ -1,13 +1,31 @@
package nmd.primal.forgecraft.items; package nmd.primal.forgecraft.items;
import net.minecraft.block.Block;
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.inventory.ItemStackHelper;
import net.minecraft.item.Item; 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;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.core.api.interfaces.IPickup;
import nmd.primal.core.common.helper.NBTHelper;
import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.tiles.TileNBTCrucible;
/** /**
* Created by mminaie on 12/30/17. * Created by mminaie on 12/30/17.
*/ */
public class SlottedTongs extends Item { public class SlottedTongs extends Item implements IPickup {
public SlottedTongs(String unlocalizedName) { public SlottedTongs(String unlocalizedName) {
setUnlocalizedName(unlocalizedName); setUnlocalizedName(unlocalizedName);
@@ -16,4 +34,61 @@ public class SlottedTongs extends Item {
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
} }
public NonNullList<ItemStack> slotList = NonNullList.withSize(1, ItemStack.EMPTY);
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ)
{
if(!world.isRemote){
IBlockState state = world.getBlockState(pos);
Block block = world.getBlockState(pos).getBlock();
if(slotList.get(0).isEmpty() || slotList.get(0).getItem().equals(Items.AIR) || slotList.get(0).getItem().equals(Blocks.AIR)){
ItemStack tempStack = takeBlock(world, pos, state, face, player, block).copy();
slotList.set(0, tempStack);
world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
return EnumActionResult.SUCCESS;
}
if(!slotList.get(0).isEmpty() ){
System.out.println("Current Item:" + slotList.get(0));
NBTTagCompound tag = this.slotList.get(0).getSubCompound("BlockEntityTag").copy();
if(tag != null){
ItemBlock temp = (ItemBlock) slotList.get(0).getItem();
int i = this.getMetadata(slotList.get(0).getMetadata());
IBlockState iblockstate1 = temp.getBlock().getStateForPlacement(world, pos, face, hitX, hitY, hitZ, i, player, hand);
temp.placeBlockAt(slotList.get(0), player, world, pos.up(1), face, hitX, hitY, hitZ, iblockstate1);
slotList.set(0, ItemStack.EMPTY);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
return EnumActionResult.FAIL;
}
return EnumActionResult.SUCCESS;
}
public ItemStack getItem(World world, BlockPos pos, IBlockState state, Block block)
{
block = world.getBlockState(pos).getBlock();
return NBTHelper.getStackBlockNBT(world, pos, state, new ItemStack(Item.getItemFromBlock(block), 1, block.damageDropped(state)));
}
public ItemStack takeBlock(World world, BlockPos pos, IBlockState state, EnumFacing face, EntityPlayer player, Block block)
{
if (!world.isRemote) {
block = world.getBlockState(pos).getBlock();
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileNBTCrucible) {
return this.getItem(world, pos, state, block);
//PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, this.getItem(world, pos, state, block));
//world.updateComparatorOutputLevel(pos, state.getBlock());
}
}
return ItemStack.EMPTY;
}
} }

View File

@@ -35,6 +35,8 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
private int heat; private int heat;
private int cookCounter; private int cookCounter;
@Override @Override
public void update () { public void update () {
World world = this.getWorld(); World world = this.getWorld();
@@ -80,26 +82,27 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
private void slotOneManager(){ private void slotOneManager(){
NonNullList<ItemStack> ingList = NonNullList.<ItemStack>withSize(5, ItemStack.EMPTY); NonNullList<ItemStack> ingList = NonNullList.<ItemStack>withSize(5, ItemStack.EMPTY);
NBTTagCompound tag = this.getSlotStack(1).getSubCompound("BlockEntityTag"); NBTTagCompound tag = this.getSlotStack(1).getSubCompound("BlockEntityTag");
if(tag != null) {
ItemStackHelper.loadAllItems(tag, ingList); ItemStackHelper.loadAllItems(tag, ingList);
CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4)); CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4));
if(recipe != null){ if (recipe != null) {
if(this.getHeat() >= recipe.getCookTemp() && if (this.getHeat() >= recipe.getCookTemp() &&
!this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")){ !this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) {
cookCounter++; cookCounter++;
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("hot", true); this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("hot", true);
this.updateBlock(); this.updateBlock();
this.markDirty(); this.markDirty();
} }
if(cookCounter >= recipe.getCookTime() && if (cookCounter >= recipe.getCookTime() &&
!this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")){ !this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) {
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("status", true); this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("status", true);
cookCounter = 0; cookCounter = 0;
this.updateBlock(); this.updateBlock();
this.markDirty(); this.markDirty();
} }
if (this.getSlotStack(1).isEmpty()){ if (this.getSlotStack(1).isEmpty()) {
this.cookCounter=0; this.cookCounter = 0;
} }
System.out.println(recipe.getCookTemp()); System.out.println(recipe.getCookTemp());
System.out.println(recipe.getCookTime()); System.out.println(recipe.getCookTime());
@@ -107,6 +110,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
System.out.println(recipe.getDropsCooked()); System.out.println(recipe.getDropsCooked());
System.out.println(recipe.getDropsRaw()); System.out.println(recipe.getDropsRaw());
} }
}
//} //}
} }

View File

@@ -18,6 +18,47 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
private int heat; private int heat;
private boolean hot; private boolean hot;
private boolean status; private boolean status;
public Item getDrops() {
return drops;
}
public void setDrops(Item drops) {
this.drops = drops;
}
public int getHeat() {
return heat;
}
public void setHeat(int heat) {
this.heat = heat;
}
public boolean getHot() {
return hot;
}
public void setHot(boolean hot) {
this.hot = hot;
}
public boolean getStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public NonNullList<ItemStack> getIngList() {
return ingList;
}
public void setIngList(NonNullList<ItemStack> ingList) {
this.ingList = ingList;
}
public NonNullList<ItemStack> ingList = NonNullList.<ItemStack>withSize(5, ItemStack.EMPTY); public NonNullList<ItemStack> ingList = NonNullList.<ItemStack>withSize(5, ItemStack.EMPTY);
@Override @Override

View File

@@ -3,7 +3,7 @@
"name": "Kitsu's Forgecraft", "name": "Kitsu's Forgecraft",
"description": "Forged with sweat and blood", "description": "Forged with sweat and blood",
"version": "1.4.01", "version": "1.4.01",
"mcversion": "1.12.1", "mcversion": "1.12.2",
"url": "", "url": "",
"updateUrl": "", "updateUrl": "",
"authorList": ["KitsuShadow"], "authorList": ["KitsuShadow"],