Jump to content

Bektor

Forge Modder
  • Posts

    852
  • Joined

  • Last visited

Everything posted by Bektor

  1. Ah, ok. That works. (I guess my idea of fixing this would have been more resource intensive ^^) I'm handling the pages by actually having an integer variable which counts on which page we are currenty. Thats basically how I handle the pages. private int page = 0; private int maxPages = 0; private ArrayList<Chapter> chapters = new ArrayList<>(APIMod.chapters); protected void initGui() { if(!this.chapters.isEmpty()) { int buttons = this.buttonList.size() - 1; int y = (this.top + 20) / this.chapters.size() + 10; for(int i = 0; i < this.chapters.size(); i++) { y += 10; GuiButtonChapter button = new GuiButtonChapter(i + buttons, this.left + 20, y, 100, 10, this.chapters.get(i)); button.displayString = I18n.format(this.chapters.get(i).getTitle()); this.buttonList.add(button); } } } public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); }
  2. Anyone got an idea as I'm stuck on this problem. Just to mention, also tried this piece of code... well, it resulted in an index out of bounds exception for(int z = 0; z < this.maxPages; z++) { for(int i = 0; i < this.chapters.size(); i++) { y += 10; if(!(this.chapters.size() > i + z)) { System.out.println("max: " + maxPages); System.out.println("chapters: " + chapters.size()); System.out.println("i: " + i); System.out.println("z: " + z); break; } GuiButtonChapter button = new GuiButtonChapter(i + buttons, this.left + 20, y, 100, 10, this.chapters.get(i + z)); button.displayString = I18n.format(this.chapters.get(i).getTitle()); this.buttonList.add(button); } } Also it does not work. Somehow it even seems to do some weird stuff when going a page back...
  3. Hi, I'm currently working on a custom book and want to create new pages on fly for it. I've got myself and index which includes all chapters the book has and instead of using a scrollbar when more than 10 chapters exists for this book, I want to add a new page to show the rest of the chapters. So each site on the index page shows only 10 chapters and when you've got 100 chapters the index part of the book will be 10 pages long. Here is what I've currently got: if(!this.chapters.isEmpty()) { int buttons = this.buttonList.size() - 1; int y = (this.top + 20) / this.chapters.size() + 10; for(int i = 0; i < this.chapters.size(); i++) { y += 10; GuiButtonChapter button = new GuiButtonChapter(i + buttons, this.left + 20, y, 100, 10, this.chapters.get(i)); button.displayString = I18n.format(this.chapters.get(i).getTitle()); this.buttonList.add(button); } } GuiButtonChapter is the button used to display the chapter and to actually choose to read it. Chapters is a ArrayList which get's loaded in from my API as other mods might want to add chapters to the book. This happens when the Gui object is created. The top and left variables are used to determine the start point of the GUI. Thx in advance. Bektor
  4. I guess the usage of the Java Version would be interesting. So Modders can see how many people are using which Java Version for modded Minecraft.
  5. Ok, thx.
  6. There is a need for sending packets as the code which has the name is Client Side only. I also don't have any Container stuff, it's just a normal GuiScreen. So the GuiScreen has to send a packet to the Server as the GuiScreen is client side and the server doesn't know about that stuff.
  7. As it seems like stuff changed in the network handler (as it's been a long time I send packets the last time), how do I execute this code: I mean, the network stuff is now running in an extra thread and so I don't have access to the code I want to execute in my onMessage method. public class MessageItemNameChanged implements IMessage { private String name; /** Default constructor, as it is required. */ public MessageItemNameChanged() { } public MessageItemNameChanged(String name) { this.name = name; } @Override public void fromBytes(ByteBuf buf) { ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, this.name); } public static class MessageItemNameChangedHandler implements IMessageHandler<MessageItemNameChanged, IMessage> { @Override public IMessage onMessage(MessageItemNameChanged message, MessageContext ctx) { // This is the player the packet was sent to the server from EntityPlayerMP serverPlayer = ctx.getServerHandler().player; ItemStack stack = serverPlayer.getActiveItemStack(); stack.setStackDisplayName(message.name); // No respond packet return null; } } } Just to mention, the packet gets send from the Client to the Server to inform the server about the change in the name of the item.
  8. Hm, I just don't see how to change with this the name of the item.
  9. Hi, I want to how I can rename an item. For example I've got an item with which you can open up a GUI and inside of this GUI you can change the name of the item. I just don't know how to achieve this (besides of sending packets to the Server). Thx in advance. Bektor
  10. I mean something like what the GUI Scale Option from Minecraft does. So when I create a GUI for my Mod which is a bit small I can just scale it to be bigger and when some other GUI is too big I can scale it down, without having to change anything globally. Oh and I already looked at that thread.
  11. I just found out, there is a class called ScaledResolution which could be usefull for this, but as this class does not has any documentation I don't know how (or if I should) use this class in combination with GlStateManager.scale. I also don't know how to recalculate the mouse position after applying the scale stuff.
  12. Anyone?
  13. Hi, I've got a question: How do I change the scale of my Gui? I know there is a scale function in GlStateManager, but using this alone breaks my Gui, as it is no longer centered. Here is my code: @SideOnly(Side.CLIENT) public class GuiBooks extends GuiScreen { private int left; private int top; private final int guiWidth = 146; private final int guiHeight = 182; @Override public void initGui() { super.initGui(); this.left = this.width / 2 - this.guiHeight / 2; this.top = this.height / 2 - this.guiHeight / 2; } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); GlStateManager.color(1.f, 1.f, 1.f, 1.f); this.mc.getTextureManager().bindTexture(GuiLexicon.GUI_BACKGROUND); this.drawTexturedModalRect(this.left, this.top, 0, 0, this.guiWidth, this.guiHeight); } Just to mention, later I will add buttons and stuff like that to the Gui, so it shouldn't break those things when scaling the Gui (like that the bounding box for the button is after scaling on a different position than the button). Thx in advance. Bektor
  14. Hi, how do I get the metadata from an Item, so I can register all sub items with the ModelLoader without having to call the method manually for each sub Item. Thx in advance. Bektor
  15. What do you mean by "infinite loops of "pull from upstream"" and "do it as a pull"?
  16. Well, the basic network is already working. I'm now just wondering how my cables (or to be more clear the controller for the cable line at each end of the cable) can determine if the block they are connected to is a machine or a generator. This should be done mod independent. So my cables could be for example connected to an EnderIO generator and EnderIO machine and still work or EnderIO generator and a machine from me and still work. That's why I am wondering how a cable controller can determine if the block it's connceted to is a generator or a machine.
  17. Hi, I've got some cables which should either extract the energy or send it (haven't decided yet.) So, to make it here easier: When the machines send energy into the cables and the cables send energy around: How does a cable know that the block it should send the energy is the machine in direction A and not the generator in direction B? It would be simple if I would just implement this for my own mod as I could then use a different TileEntityBase for Generators and Machines and check with instanceof, but I don't want my cables to be incompatible with other mods. So how does a cable know the energy should go to this machine. Thx in advance. Bektor
  18. Hm... I had a similiar problem with FTB in 1.7.10. On my side the problem was caused by the Windows 10 Anniversary Update. I don't know what exaclty went wrong, but after the update I had such problems like you describe above. After a clean install of Windows 10 [again] (still the same Update etc., as I made the clean install shortly after the update) it worked again. So it could be that Windows did something wrong there. A friend of me had also similiar problems: We fixed it with updating his out of date drivers (CPU and GPU drivers).
  19. Hm, when placing a breakpoint in the findTransferPipes methods in this line: if(this.getWorld().getTileEntity(current) instanceof TileEntityPipeEnergy) this.getBlocksToScan(toSearch, scanned, current); // Breakpoint at this line It seems like the block is always scanning the same position, as the current BlockPos had the same values even after going through about 40 times this breakpoint. It also seems like the else if statement is never reached. What was my construct for testing it (shows y axis, as x and z are the same for all of these blocks): EDIT: Hm, seems like the if-statement which checks if new blocks should be added was wrong. I also changed EnumSet.allOf(EnumFacing.class) back to EnumFacing.VALUES. But now it scans all block positions which should be scanned again and adds the correct blocks to the list.
  20. Well, I've had one breakpoint before the lambda and one breakpoint inside the forEach loop with the lambda. EDIT: Hm, the list seems to be emtpy, so somewhere in the search method findTransferPipes has to be a problem.
  21. With getCapability is the problem that the HashMap does not contains null as I removed it from getBlocksToScan and changed it back to EnumSet.allOf(EnumFacing.class). This can be seen there: IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, side); And the debug mode tells me that there seems to be a problem with the forEach loop. Everything above the forEach loop get's called, but not even the first line of the forEach loop get's executed.
  22. Hm, got some problems after adding the energy handling logic (WIP) to all the blocks: @diesieben07 NullPointerException when having null as a side like you suggested. Energy seems not to get transfered to other the transfer pipe at the end of the cable Transfer Pipe: Solar Panel update: There is also no log output from transfer pipe with syso and when having it outside of the forEach loop, the log tells me the transfer pipe at the beginning has energy, but at the end of the pipe doesn't have energy.
  23. Hi. How can I save a HashMap which stores a BlockPos and an EnumFacing to NBT data and read it in? HashMap<BlockPos, EnumFacing> Thx in advance. Bektor
  24. Ah, ok. Also what type should I put into there: compound.getTagList("machines", type); And from where do I get these types? I guess NBTBase, thought.
×
×
  • Create New...

Important Information

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