Jump to content

rasmustof

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by rasmustof

  1. but then how do i put i item inside the output slot?!?
  2. but how do i use that void for what i wanna do?!? if you need more files just ask
  3. 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?!?
  4. okay but then what do i need to add in the tileentity
  5. 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)
  6. 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
  7. 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; } }
  8. 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
  9. 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
  10. hello so im making something that requires that i need to detect if the block placed in the slot is the sand block(Block.sand) so this is what i did for a item: //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; } and then i dont know how to do the same kind of thing, but with the Sand block or any kind of block for that matter
  11. as to the name issue i cant figure it out ... it looks the same to me ...
  12. where you do super(id, par2Material); just add: this.setCreativetab([your tab]
  13. hello it seems that your Block class is wrong cant tell where but here is my working code that you can take a look at: @SideOnly(Side.CLIENT) private Icon[] iconArray; public Icon getIcon(int par1, int par2) { return this.iconArray[par2 % this.iconArray.length]; } public int damageDropped(int par1) { return par1; } @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, @SuppressWarnings("rawtypes") List par3List) { for (int var4 = 0; var4 < 15; ++var4) { par3List.add(new ItemStack(par1, 1, var4)); } } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { this.iconArray = new Icon[16]; for (int i = 0; i < this.iconArray.length; ++i) { this.iconArray[i] = par1IconRegister.registerIcon(Reference.MOD_ID + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".")+1)+ i); ofc you need to change 15 to 3 in my var4
  14. If Block.blocksList[stack.getItem().itemID] is returning null, that means that the item is not a block, ergo if its not null it must be a block. Ergo allow it (return true). but your code doesnt work .... it makes it so evrything is accepted if you want it so only blocks can be placed in it, you need a custom slot. and thats why i have a custom slot look here: package EsteticsPLUS; import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; ; public class SlotTraider3 extends Slot { public SlotTraider3(IInventory par1iInventory, int par2, int par3, int par4) { super(par1iInventory, par2, par3, par4); } @Override public boolean isItemValid(ItemStack stack) { if (Block.blocksList[stack.getItem().itemID] != null) { return true; } else return false; } }
  15. If Block.blocksList[stack.getItem().itemID] is returning null, that means that the item is not a block, ergo if its not null it must be a block. Ergo allow it (return true). but your code doesnt work .... it makes it so evrything is accepted
  16. this method doesnt work ... but how do i actually define that only blocks cacn be accepted currently this accepts evrything ...
  17. so i know that when limitating the slot to only accept item you need this code: @Override public boolean isItemValid(ItemStack par1ItemStack) { if (par1ItemStack != null) { Item item = par1ItemStack.getItem(); return item != null && item == EsteticsPLUS.HydrocroconyxIngot; } return false; } but how can i do the same thing with blocks so it only accepts blocks and not items
  18. where do i need to add that... im a noob at modding
  19. hello do i wrote this code : http://paste.minecraftforge.net/view/5f1e5272 so basicly when i run the mod i can find the item(Trader Stone) but the name is just emty no name at all just reply if you need any more info best regards Rasmustof UPDATE: fixed it by changing to this: http://paste.minecraftforge.net/view/c2e39318
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.