Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Everything posted by osum4est

  1. Hey, did you ever get it working? I'm running into the same issue :(
  2. Figured it out! Such a simple error. Instead of adding guiLeft and top onto the mouse points you have to subract them! Should of realized that. Well, thanks for your help! I really appreciated it!
  3. In the mouseClicked method. Is it because it isn't going to the server or something? public void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); textFieldName.mouseClicked(i + guiLeft, j + guiTop, k); } When I do this I cannot even find where I'm supposed to click. So guiLeft and top are definately not 0
  4. I have made a GUI with a textbox, but when I click it, it doesn't activate! But, if I click it's location from the actual size of the window, so subtracting GuiTop and GuiLeft, it will activate. I tried adding GuiTop and left to the click but it still won't work. Any Help? Code: package skillcraft.client.interfaces; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import tileentities.TileEntityRunetable; public class GuiRunetable extends GuiContainer { int testX = 25; int testY = 25; private TileEntityRunetable runetable; GuiTextField textFieldName; public GuiRunetable(InventoryPlayer invPlayer, TileEntityRunetable runetable) { super(new ContainerRunetable(invPlayer, runetable)); this.runetable = runetable; xSize = 176; ySize = 191; } @Override public void initGui() { super.initGui(); textFieldName = new GuiTextField(fontRenderer, 68, 5, 100, 15); textFieldName.setMaxStringLength(20); textFieldName.setFocused(false); } private static final ResourceLocation texture = new ResourceLocation("skillcraft", "textures/gui/runetablegui.png"); @Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } @Override public void updateScreen() { textFieldName.updateCursorCounter(); } @Override protected void drawGuiContainerForegroundLayer(int x, int y) { fontRenderer.drawString("Rune Table", 8, 8, 0x404040); int[] error = runetable.runeHandler.errorCheck(); if (error[0] == 1) { fontRenderer.drawString("You maxed out this rune!", 26, 67, 0xFF3300); } else if (error[0] == 2) { fontRenderer.drawString("Can't add this rune to this item!", 10, 67, 0xFF3300); } else if (error[0] == 3) { fontRenderer.drawString("You must have " + error[1] + " levels!", 28, 67, 0xFF3300); } textFieldName.drawTextBox(); } @Override protected void keyTyped(char key, int par2) { //if (!textFieldName.isFocused()) //{ super.keyTyped(key, par2); //} textFieldName.textboxKeyTyped(key, par2); //if (runetable.getStackInSlot(2) != null) //{ /// runetable.nameTool(textFieldName.getText()); ///} switch (key) { case 'w': testY--; break; case 'a': testX--; break; case 's': testY++; break; case 'd': testX++; break; case 'o': System.out.println(testX + ", " + testY); } } public void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); textFieldName.mouseClicked(i, j, k); } }
  5. Ok thanks for clearing that up. Is there a way, though, for it to just follow me by either setting it's path? I tried but I got a null error. Same if I try to just set it's position to about mine. It doesn't have to be a pet or anything. I also tried setting its path to entity? Sorry not at my computer now but it took an entity creature and I'm not sure if you can cast entity player into that.
  6. I did but i'm not sure how to make it my pet in order for it to follow it's owner
  7. I want to add a task to the pig that will make the pig follow the player, regardless of what is held. Maybe i could make it my pet? Although i'm not sure how to do that. Any help is appreciated. Thanks!
  8. Hello, I have a working NBT system that keeps track of its speed and everything. I do not know how I would dynamically change the speed, though. I got it to sort-of work except it changes the speed for all picks of its type, not that specific item stack. Heres that code: And in the item class in onUpdate() efficiencyOnProperMaterial = Efficiency.getSpeed(stack); How would I change the speed for a specific Item Stack? I do not want to put 30 if statements in the onUpdate class... Thanks
  9. Hello! I've been trying all day and I just can't figure out how to do this. I want to make a "Runetable" that allows you to put in a tool and a rune and in return, get a special version of that tool. What i'm having trouble with is the detecting what items are in the slots as for some reason they always seem null. I'm not sure if I should detect the items in the slots and have a new tool appear in the other slot or use the crafting matrix. Although I havn't found any helpful tutorials for using the crafting matrix so I don't know how to use it. I've looked at the Crafting Table's container and I still just need some help. Which should I use and can I have some guidance on how to do it? Here's what I have so far: TileEntityRunetable.java package tileentities; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import skillcraft.items.ItemInfo; import skillcraft.items.ItemRuneJump; import skillcraft.items.Items; public class TileEntityRunetable extends TileEntity implements IInventory { private ItemStack[] items; public TileEntityRunetable() { items = new ItemStack[2]; } @Override public int getSizeInventory() { return items.length; } @Override public ItemStack getStackInSlot(int i) { return items[i]; } @Override public ItemStack decrStackSize(int i, int count) { ItemStack itemstack = getStackInSlot(i); if (itemstack != null) { if (itemstack.stackSize <= count) { setInventorySlotContents(i, null); } else { itemstack = itemstack.splitStack(count); onInventoryChanged(); } } return itemstack; } @Override public ItemStack getStackInSlotOnClosing(int i) { ItemStack item = getStackInSlot(i); setInventorySlotContents(i, null); return item; } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { items[i] = itemstack; System.out.println(itemstack.itemID); if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } onInventoryChanged(); } @Override public String getInvName() { return "InventoryRunetable"; } @Override public boolean isInvNameLocalized() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return entityplayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64; } @Override public void openChest(){} @Override public void closeChest(){} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return false; } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList items = new NBTTagList(); for (int i = 0; i < getSizeInventory(); i++) { ItemStack stack = getStackInSlot(i); if (stack != null) { NBTTagCompound item = new NBTTagCompound(); item.setByte("Slot", (byte)i); stack.writeToNBT(item); items.appendTag(item); } } compound.setTag("Items", items); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList items = compound.getTagList("Items"); for (int i = 0; i < items.tagCount(); i ++) { NBTTagCompound item = (NBTTagCompound)items.tagAt(i); int slot = item.getByte("Slot"); if (slot >= 0 && slot < getSizeInventory()) { setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item)); } } } public void checkRecipie(Slot rune, Slot item) { if (rune.getStack().itemID == ItemInfo.RUNE_JUMP_ID) System.out.println("always crashes..."); } } BlockRuneTable.java package skillcraft.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; import skillcraft.SkillCraft; import skillcraft.client.CreativeTab; import skillcraft.items.ItemInfo; import tileentities.TileEntityRunetable; import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockRuneTable extends BlockContainer { public BlockRuneTable(int id) { super(id, Material.rock); setCreativeTab(CreativeTab.skillcraftTab); setHardness(2F); setStepSound(Block.soundStoneFootstep); setUnlocalizedName(BlockInfo.RUNETABLE_UNLOCALIZED_NAME); } @SideOnly(Side.CLIENT) private Icon topIcon; @SideOnly(Side.CLIENT) private Icon botIcon; @SideOnly(Side.CLIENT) private Icon sideIcon; @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister register) { topIcon = register.registerIcon(BlockInfo.TEXTURE_LOCATION + ":" + BlockInfo.RUNETABLE_TOP); botIcon = register.registerIcon(BlockInfo.TEXTURE_LOCATION + ":" + BlockInfo.RUNETABLE_BOT); sideIcon = register.registerIcon(BlockInfo.TEXTURE_LOCATION + ":" + BlockInfo.RUNETABLE_SIDE); } @SideOnly(Side.CLIENT) @Override public Icon getIcon(int side, int meta) { switch (side) { case 0: return botIcon; case 1: return topIcon; default: return sideIcon; } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { FMLNetworkHandler.openGui(player, SkillCraft.instance, 0, world, x, y, z); } return true; } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityRunetable(); } } ContainerRunetable.java package skillcraft.client.interfaces; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import skillcraft.client.interfaces.slots.SlotAddRune; import skillcraft.client.interfaces.slots.SlotNewItem; import skillcraft.client.interfaces.slots.SlotOldItem; import tileentities.TileEntityRunetable; public class ContainerRunetable extends Container { private TileEntityRunetable runetable; public InventoryCrafting craftMatrix = new InventoryCrafting(this, 1, 2); public IInventory craftResult = new InventoryCraftResult(); public ContainerRunetable(InventoryPlayer invPlayer, TileEntityRunetable runetable) { this.runetable = runetable; for(int x = 0; x < 9; x++) { addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 142)); } for(int y = 0; y < 3; y++) { for(int x = 0; x < 9; x++) { addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18)); } } addSlotToContainer(new SlotOldItem(invPlayer, 37, 53, 28)); addSlotToContainer(new SlotAddRune(invPlayer, 38, 53, 46)); addSlotToContainer(new SlotNewItem(invPlayer, 0, 124, 35)); } @Override public boolean canInteractWith(EntityPlayer entityplayer) { return runetable.isUseableByPlayer(entityplayer); } public TileEntityRunetable getRunetable() { return runetable; } @Override public ItemStack slotClick(int slot, int clickType, int clickMeta, EntityPlayer player) { if(slot <= 38 && slot > -1) updateCrafting(); ItemStack stack = super.slotClick(slot, clickType, clickMeta, player); return stack; } public void updateCrafting() { runetable.checkRecipie(getSlot(0), getSlot(1)); } } I attached a picture of the GUI i've made along with the items that should be used together in the right slots in case that helps. Also, I'm new to the forums so if I did something wrong, sorry i'll try to fix it http://s27.postimg.org/mtb2xjz77/2014_01_27_22_08_12.png[/img] Thank you!
  • Create New...

Important Information

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