rasmustof Posted June 24, 2013 Posted June 24, 2013 hello so ... i need to know how i can check if a boolean from annother class is true and then issue some code ... using a simple if statement, but what do i need to type my boolean is called CheckInventoryTrader1 ... can someone please tell me how to do it Quote
Draco18s Posted June 24, 2013 Posted June 24, 2013 If it's not a static variable, then you need a reference to an instance of that class. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 24, 2013 Author Posted June 24, 2013 well here is the boolean: //checking if the placed item is "Hydrocroconyzx ingot" only retuns false if there is no item in the slot since no othere item/block is allowed in the slot public boolean CheckInventoryTrader1(ItemStack par1ItemStack) { Item item = par1ItemStack.getItem(); if(par1ItemStack != null && item == EsteticsPLUS.HydrocroconyxIngot){ return true; } else return false; } im not intirely sure on how to do so if you can post the code that would be nice Quote
Draco18s Posted June 24, 2013 Posted June 24, 2013 And where is this function? Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 24, 2013 Author Posted June 24, 2013 On 6/24/2013 at 4:28 PM, Draco18s said: And where is this function? its in my slot class here: package EsteticsPLUS; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class SlotTrader1 extends Slot{ public SlotTrader1(EntityPlayer player, IInventory par1iInventory, int par2, int par3, int par4) { super(par1iInventory, par2, par3, par4); } @Override public boolean isItemValid(ItemStack par1ItemStack) { if (par1ItemStack != null) { Item item = par1ItemStack.getItem(); return item != null && item == EsteticsPLUS.HydrocroconyxIngot; } return false; } //checking if the placed item is "Hydrocroconyzx ingot" only retuns false if there is no item in the slot since no othere item/block is allowed in the slot public boolean CheckInventoryTrader1(ItemStack par1ItemStack) { Item item = par1ItemStack.getItem(); if(par1ItemStack != null && item == EsteticsPLUS.HydrocroconyxIngot){ return true; } else return false; } } Quote
rasmustof Posted June 25, 2013 Author Posted June 25, 2013 still havent found it out, even if it is something simple please just ask if you need to see anything but i warn you ... its messy Quote
Draco18s Posted June 25, 2013 Posted June 25, 2013 When you put a function in a class it is assumed that you need it in that class. You're not using it in that class (it is, in fact, identical to the isItemValid function) but you want to call that function from another class....why? Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 25, 2013 Author Posted June 25, 2013 so im making this slot system where you have 2 slots that are inputs and then have a output that is triggered using that boolean(have one in the other slot too) and then from that i can display a metadata block and have a upp and a down button that can modify the output be adding one to the metadata or remove one(hint: i talked a little bit with Vswe about it) Quote
Draco18s Posted June 25, 2013 Posted June 25, 2013 That is not how you should be doing things. The two input slots handle whether or not the item is valid, the TileEntity should handle if both slots are filled and put the output item in the output slot. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 25, 2013 Author Posted June 25, 2013 okay but then what do i need to add in the tileentity Quote
Draco18s Posted June 25, 2013 Posted June 25, 2013 On 6/25/2013 at 8:08 PM, rasmustof said: okay but then what do i need to add in the tileentity Or the Living Entity. Whateverthehellentity that lets you open the GUI that has the slots in it. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 25, 2013 Author Posted June 25, 2013 that will be this entity package EsteticsPLUS; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityTrader extends TileEntity implements IInventory { private ItemStack[] inv; public TileEntityTrader(){ inv = new ItemStack[9]; } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int slot) { return inv[slot]; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openChest() {} @Override public void closeChest() {} @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { ItemStack stack = inv[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } @Override public String getInvName() { return "EsteticsPLUS.tileentitytrader"; } @Override public boolean isInvNameLocalized() { return true; } @Override public boolean isStackValidForSlot(int i, ItemStack itemstack) { return false; } } so what do i need to add?!? Quote
Draco18s Posted June 25, 2013 Posted June 25, 2013 /** * Called when an the contents of an Inventory change, usually */ public void onInventoryChanged() { ... } Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 26, 2013 Author Posted June 26, 2013 but how do i use that void for what i wanna do?!? if you need more files just ask Quote
Draco18s Posted June 26, 2013 Posted June 26, 2013 That void function is the function that checks the slots to see if both have items, and if so, do whatever needs to be done. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
rasmustof Posted June 26, 2013 Author Posted June 26, 2013 but then how do i put i item inside the output slot?!? Quote
Draco18s Posted June 26, 2013 Posted June 26, 2013 On 6/26/2013 at 12:25 PM, rasmustof said: but then how do i put i item inside the output slot?!? slot.putStack(ItemStack item) Le gasp Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.