Jump to content

PlatonCraft

Members
  • Posts

    114
  • Joined

  • Last visited

Everything posted by PlatonCraft

  1. Oh, my bad... I forgot about my modid in path. Now all works. BTW do you know why my items' names showing only after changing language? Do you have similar problem? If not could you please give me your code of naming items?
  2. hah, you helping me, I helping you. =) But I have already tried this way to register. Is it work for you? maybe I put my textures in wrong place? Where did you placed textures?
  3. I get recipes work in my mod. Code is below GameRegistry.addRecipe(new ItemStack(mysimpletool, 1), new Object[]{ "XXX", " # ", " # ", ('X'), Items.apple, ('#'), Items.coal}); mysimple tool is described in main class of mod public static Item mysimpletool; and in preInit in mainclass mysimpletool = new ItemMySimpleTool().setUnlocalizedName("mysimpletool"); P.S. I would appreciate if you say me how to register textures
  4. So, forge is out. And no one knows how to use it... Great!!! Question is how to register textures is 1.7.2 It would be very good if anyone would tell me it. I want to give texture to my item.
  5. Still need help. Where should I call my own method in TileEntity from?
  6. public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) { return par1 == 1 && par2ItemStack != null ? par2ItemStack.getItem().itemID == Item.book.itemID : false; } Like that? Anyway, nevermind. It doesn't important for me. I'm just begian learning java. So my knowledge is small. i know how to call my own method. I don't know where from should i call it.
  7. Now I've got a problem I created my own method is TileEntity public void UnEnchantment () { if (isItemValidForSlot(0, this.itemslots[0])) { System.out.println("HAHA!!"); } else { System.out.println("Crying!!"); } } And it doesn't works. I ain't see my Strings in console or anywhere else. What shoud i do to make mod call it?
  8. Now I think that these methods are for calling only. Thing that i wanted isn't very important to me. So I'll ask another question if I'll get in trouble
  9. Doesn't works. [spoiler=My TileEntity] package platon.mods.unenchant; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityUnEnchTbl extends TileEntity implements ISidedInventory { ItemStack[] itemslots = new ItemStack[2]; public static String localizedName; private static final int[] slot_top = {0}; private static final int[] slot_bottom = {1}; public int getSizeInventory() { return this.itemslots.length; } public ItemStack getStackInSlot(int i) { return this.itemslots[i]; } public ItemStack decrStackSize(int par1, int par2) { if (this.itemslots[par1] != null) { ItemStack itemstack; if (this.itemslots[par1].stackSize <= par2) { itemstack = this.itemslots[par1]; this.itemslots[par1] = null; return itemstack; } else { itemstack = this.itemslots[par1].splitStack(par2); if (this.itemslots[par1].stackSize == 0) { this.itemslots[par1] = null; } return itemstack; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.itemslots[par1] != null) { ItemStack itemstack = this.itemslots[par1]; this.itemslots[par1] = null; return itemstack; } else { return null; } } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.itemslots[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); this.itemslots = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.itemslots.length) { this.itemslots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } if (par1NBTTagCompound.hasKey("CustomName")) { this.localizedName = par1NBTTagCompound.getString("CustomName"); } } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.itemslots.length; ++i) { if (this.itemslots[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.itemslots[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } par1NBTTagCompound.setTag("Items", nbttaglist); if (this.isInvNameLocalized()) { par1NBTTagCompound.setString("CustomName", this.localizedName); } } public String getInvName() { return this.isInvNameLocalized() ? this.localizedName : "container.UnEnchTbl"; } public boolean isInvNameLocalized() { return this.localizedName != null && this.localizedName.length() > 0; } /** * Setting the localizedName Variable * @param localizedName */ public static void func_94043_a(String par1Str){ localizedName = par1Str; } public int getInventoryStackLimit() { return 1; } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } public void openChest() { } public void closeChest() { } public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) { return par2ItemStack != null ? par2ItemStack.getItem().itemID == Item.book.itemID : false; } public int[] getAccessibleSlotsFromSide(int par1) { if (par1 == 0) return slot_top; else return slot_bottom; } public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3){ return isItemValidForSlot(1, par2ItemStack); } public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) { return isItemValidForSlot(1, par2ItemStack); } } I want to put only books in second slot with id 1. By the way if i set canInsertItem and canExtractItem to false, i still may put and take things. What should i do to make it work?
  10. Am i need to create new SlotUnEnchTbl class that extends TileEntity? Or it must extends the Slot class. Am i need to replace this.addSlotToContainer(new Slot(unenchtbl, 1, 16, 49)); to this.addSlotToContainer(new SlotUnEnchTbl(unenchtbl, 1, 16, 49)); ?? And in http://www.minecraftforum.net/topic/1924178-forge-162-micros-furnace-tutorials/ tutorial guy doesn't creates any Slot class, but he has definition that in bottom slot you can put only permitted things (they're also in the TileEntity class)
  11. Hah thanks man, i have one more problem i want to put to second slot only books and nothing else. How can i make it? I writed that String and it doesn't work. Or i should call it from somewhere? public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 0 ? true : (itemslots[i].getItem().itemID == ItemBook.book.itemID); } For that time i want to put if first slot with id 0 anything. Also i writed that expression public int[] getAccessibleSlotsFromSide(int par1) { if (par1 == 0) return slot_top; else return slot_bottom; } Is it useful? And what it does?
  12. Just implement? and what inventory? which class is it? I misunderstood what i need to write to code and where.
  13. I fixed a half of second problem. Now i can put items in the slots, but i cant get 'em out of slots [spoiler=TileEntity] package platon.mods.unenchant; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityUnEnchTbl extends TileEntity implements ISidedInventory { ItemStack[] itemslots = new ItemStack[2]; public static String localizedName; public int getSizeInventory() { return this.itemslots.length; } public ItemStack getStackInSlot(int i) { return this.itemslots[i]; } public ItemStack decrStackSize(int i, int j) { return null; } public ItemStack getStackInSlotOnClosing(int i) { return null; } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.itemslots[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); this.itemslots = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.itemslots.length) { this.itemslots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } if (par1NBTTagCompound.hasKey("CustomName")) { this.localizedName = par1NBTTagCompound.getString("CustomName"); } } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.itemslots.length; ++i) { if (this.itemslots[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.itemslots[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } par1NBTTagCompound.setTag("Items", nbttaglist); if (this.isInvNameLocalized()) { par1NBTTagCompound.setString("CustomName", this.localizedName); } } public String getInvName() { return this.isInvNameLocalized() ? this.localizedName : "container.UnEnchTbl"; } public boolean isInvNameLocalized() { return this.localizedName != null && this.localizedName.length() > 0; } /** * Setting the localizedName Variable * @param localizedName */ public static void func_94043_a(String par1Str){ localizedName = par1Str; } public int getInventoryStackLimit() { return 1; } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } public void openChest() { } public void closeChest() { } public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } public int[] getAccessibleSlotsFromSide(int var1) { return null; } public boolean canInsertItem(int i, ItemStack itemstack, int j) { return true; } public boolean canExtractItem(int i, ItemStack itemstack, int j) { return true; } }
  14. removed, nothing changed. I fixed one problem. Now the only problem is when i put something to slots in block(both of them) that disappears
  15. I changed id from 0 to 1 which i registereg and block stopped to open completely I registering id with this "ModLoader.registerContainerID(this, 1);" I changed 0 to 1 in GuiHandler, problem is pre previous. Things disapperars http://pastebin.com/ttPWwvji http://pastebin.com/nSMjqfFF http://pastebin.com/2As32ubj
  16. I copied OnBlockActivated from tutorial, now in opens, but when i open it , items from first and second slot disappears. When i trying to put item to my own slots in blocks they're also disappears My code in archive https://mega.co.nz/#!jccCwKJL!aZ1C0jbz_KFPz-9SaNJQ41TWESxUy7h5BDrO6SdEhwM
  17. Now my OnBlockUse is public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c) { player.openGui(EnchantBase.instance, 1, world, x, y, z); return true; } I didn't changed anything else When i click my block, animation does but gui doesn't opens and no errors What should i change also?
  18. But if i'll delete all ModLoader strings, what should i paste instead of them?
  19. [spoiler=EnchantBase] [spoiler=Block] package platon.mods.unenchant; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.src.ModLoader; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockUnEnchTbl extends BlockContainer { public BlockUnEnchTbl(int par1) { super(par1, Material.rock); this.setHardness(3.0F); this.setCreativeTab(CreativeTabs.tabDecorations); this.setResistance(5.0F); this.setLightValue(0.0F); } @Override public void registerIcons(IconRegister reg){ this.blockIcon = reg.registerIcon("unenchant:BlockUnEnchTbl"); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c) { TileEntityUnEnchTbl unenchtbl = (TileEntityUnEnchTbl) world.getBlockTileEntity(x, y, z); if(player instanceof EntityPlayerMP && unenchtbl !=null) { player.openGui(EnchantBase.modid, 1, world, x, y, z); ModLoader.serverOpenWindow((EntityPlayerMP) player, new ContainerUnEnchTbl(player, world, x, y, z), 1, x, y, z); } else { ModLoader.openGUI((EntityPlayerSP) player, new GuiUnEnchTbl(player, world, x, y, z)); } return true; } public TileEntity createNewTileEntity(World par1World) { return new TileEntityUnEnchTbl(); } }
  20. What i need to do to be a @NetworkMod I have @NetworkMod (clientSideRequired = true, serverSideRequired = false) this.
  21. I did it. When i click any thing in inventory it doesnt moving and i getting error "A mod tried to open a gui on the server without being a NetworkMod" And when come out yo menu there is an error I fixed it by setting "private String StuffName" equal to "StuffName". Now error dissapeared but I do not know whether it was possible to do so.
  22. You are opening your GUI wrongly. You need an IGUiHandler and then use EntityPlayer.openGui I created following class [spoiler=IGUIHandler] package platon.mods.unenchant; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandlerUnEnchant implements IGuiHandler { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); switch(id) { case 0: return new ContainerUnEnchTbl(player, world, x, y, z); } return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); switch(id) { case 0: return new GuiUnEnchTbl(player, world, x, y, z); } return null; } } How to register it? And where should i call EntityPlayer.openGui. Tell me fullly, please.
  23. I have one more question: When i put item to created by me slot it destoyes the item. how can i fix that?
  24. You are genius, i am stupid. I thought that index is not should be in array.
  25. Sorry, my bad. I have already.
×
×
  • Create New...

Important Information

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