crazy nbt full retard need to make an itemslot

This commit is contained in:
Mohammad-Ali Minaie
2018-01-06 17:33:33 -05:00
parent 19730303c2
commit 008332636b
7 changed files with 122 additions and 30 deletions

View File

@@ -168,8 +168,10 @@ public class BloomeryBase extends CustomContainerFacing implements ITileEntityPr
return false;
}
if(tileItem1.isEmpty()){
ItemStack tempItem = new ItemStack(pItem.getItem(), 1);
tile.setSlotStack(1, tempItem);
ItemStack place_stack = pItem.copy();
//if (tile.putStack(slot, place_stack))
tile.setSlotStack(1, place_stack);
pItem.shrink(1);
return true;
}

View File

@@ -6,6 +6,7 @@ import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ItemStackHelper;
@@ -42,7 +43,7 @@ import java.util.Random;
/**
* Created by mminaie on 11/11/17.
*/
public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
public class NBTCrucible extends BlockContainer implements ITileEntityProvider, IPickup {
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D);
@@ -57,12 +58,6 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
//crucibleIngredients.apply(new ItemStack(Blocks.IRON_ORE, 1));
}
@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state)
{
return NBTHelper.getStackBlockNBT(world, pos, state, super.getItem(world, pos, state));
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ) {
@@ -72,10 +67,7 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
ItemStack pItem1 = new ItemStack(pItem.getItem(), 1);
if(pItem.isEmpty()){
if(!player.isSneaking()) {
//PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, this.getItem(world, pos, state));
//PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, this.getItem(world, pos, state));
return takeBlock(world, pos, state, face, player);
}
}
/**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/
@@ -86,6 +78,7 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
tile.ingList.set(i, pItem1);
pItem.shrink(1);
tile.update();
tile.markDirty();
return true;
}
}
@@ -100,6 +93,7 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
//}
}
tile.update();
tile.markDirty();
return true;
}
}
@@ -113,6 +107,12 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
return this.takeBlock(world, pos, state, EnumFacing.UP, player);
}
@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state)
{
return NBTHelper.getStackBlockNBT(world, pos, state, super.getItem(world, pos, state));
}
@Override
public boolean takeBlock(World world, BlockPos pos, IBlockState state, EnumFacing face, EntityPlayer player)
{
@@ -124,7 +124,7 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, this.getItem(world, pos, state));
world.updateComparatorOutputLevel(pos, state.getBlock());
//world.updateComparatorOutputLevel(pos, state.getBlock());
return world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
}
@@ -147,6 +147,20 @@ public class NBTCrucible extends Block implements ITileEntityProvider, IPickup {
return null;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
if (stack.hasDisplayName())
{
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity instanceof TileNBTCrucible)
{
//((TileStorageCrate)tileentity).setCustomName(stack.getDisplayName());
}
}
}
@Override
public int quantityDropped(Random random)

View File

@@ -189,7 +189,7 @@ public class CrucibleCrafting {
public static CrucibleCrafting getRecipe(ItemStack i0, ItemStack i1, ItemStack i2, ItemStack i3, ItemStack i4){
for(CrucibleCrafting recipe : crucibleCrafting){
if(recipe.ing0.apply(i0) && recipe.ing1.apply(i1) && recipe.ing2.apply(i2) && recipe.ing3.apply(i3) && recipe.ing4.apply(i4) ){
if(recipe.ing0.test(i0) && recipe.ing1.test(i1) && recipe.ing2.test(i2) && recipe.ing3.test(i3) && recipe.ing4.test(i4) ){
return recipe;
}
}
@@ -209,4 +209,23 @@ public class CrucibleCrafting {
return false;
}
public int getCookTemp() {
return cookTemp;
}
public int getCookTime() {
return cookTime;
}
public int getCoolTime() {
return coolTime;
}
public ItemStack getDropsCooked() {
return dropsCooked;
}
public ItemStack getDropsRaw() {
return dropsRaw;
}
}

View File

@@ -0,0 +1,19 @@
package nmd.primal.forgecraft.items;
import net.minecraft.item.Item;
import nmd.primal.forgecraft.ModInfo;
/**
* Created by mminaie on 12/30/17.
*/
public class SlottedTongs extends Item {
public SlottedTongs(String unlocalizedName) {
setUnlocalizedName(unlocalizedName);
this.setRegistryName(unlocalizedName);
this.setMaxStackSize(1);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
}
}

View File

@@ -4,6 +4,9 @@ import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ITickable;
@@ -15,7 +18,9 @@ import nmd.primal.core.common.helper.CommonUtils;
import nmd.primal.core.common.helper.RecipeHelper;
import nmd.primal.forgecraft.blocks.BloomeryBase;
import nmd.primal.forgecraft.blocks.Crucibles.Crucible;
import nmd.primal.forgecraft.blocks.Crucibles.NBTCrucible;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
import nmd.primal.forgecraft.init.ModItems;
import static nmd.primal.core.common.helper.FireHelper.makeSmoke;
@@ -73,6 +78,39 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
}
private void slotOneManager(){
NonNullList<ItemStack> ingList = NonNullList.<ItemStack>withSize(5, ItemStack.EMPTY);
NBTTagCompound tag = this.getSlotStack(1).getSubCompound("BlockEntityTag");
ItemStackHelper.loadAllItems(tag, ingList);
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() &&
!this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")){
cookCounter++;
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("hot", true);
this.updateBlock();
this.markDirty();
}
if(cookCounter >= recipe.getCookTime() &&
!this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")){
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("status", true);
cookCounter = 0;
this.updateBlock();
this.markDirty();
}
if (this.getSlotStack(1).isEmpty()){
this.cookCounter=0;
}
System.out.println(recipe.getCookTemp());
System.out.println(recipe.getCookTime());
System.out.println(recipe.getCoolTime());
System.out.println(recipe.getDropsCooked());
System.out.println(recipe.getDropsRaw());
}
//}
}
/*private void slotOneManager(){
BloomeryCrafting recipe = BloomeryCrafting.getRecipe(this.getSlotStack(1));
if(recipe != null){
//System.out.println(recipe.getIdealTime() + " : " + recipe.getHeatThreshold());
@@ -112,7 +150,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
this.cookCounter=0;
}
}
}
}*/
private void slotZeroManager(World world){
if(this.getSlotStack(0) != ItemStack.EMPTY) {
@@ -252,6 +290,9 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
if(Block.getBlockFromItem(stack.getItem()) instanceof Crucible ){
return true;
}
if(Block.getBlockFromItem(stack.getItem()) instanceof NBTCrucible ){
return true;
}
}
return false;
}

View File

@@ -17,7 +17,7 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
private Item drops;
private int heat;
private boolean hot;
private String mod0, mod1, mod2;
private boolean status;
public NonNullList<ItemStack> ingList = NonNullList.<ItemStack>withSize(5, ItemStack.EMPTY);
@Override
@@ -25,20 +25,7 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
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;
}
}
}*/
}
}
@@ -53,6 +40,7 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
ItemStackHelper.loadAllItems(nbt, this.ingList);
this.heat = nbt.getInteger("heat");
this.hot = nbt.getBoolean("hot");
this.status = nbt.getBoolean("status");
return nbt;
}
@@ -62,6 +50,7 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
ItemStackHelper.saveAllItems(nbt, this.ingList);
nbt.setInteger("heat", this.heat);
nbt.setBoolean("hot", this.hot);
nbt.setBoolean("status", this.status);
super.writeNBT(nbt);
return nbt;
}

View File

@@ -0,0 +1,8 @@
{
"forge_marker":1,
"textures": {
"particle": "forgecraft:blocks/stone_slab",
"texture": "forgecraft:blocks/stone_slab"
},
"parent": "forgecraft:block/crucibleshut"
}