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

TheEpicTekkit

Members
  • Posts

    361
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    UK
  • Personal Text
    Learning new things every day!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

TheEpicTekkit's Achievements

Diamond Finder

Diamond Finder (5/8)

8

Reputation

  1. Thanks for this. I haven't had much time to read through this method, but it looks pretty nice. Though I am looking for an explanation of how the transferStackInSlot method works and how it is used. I don't want to just have code to copy and paste, because I wont learn anything from that.
  2. Hello. I would like help understanding the unnecessarily complicated and undocumented method: transferStackInSlot(EntityPlayer player, int slotIndex) I have looked around for tutorials on how to use this method, and only found things like a custom furnace, which has pretty much the exact same code as the vanilla furnace, and a badly explained transferStackInSlot method. I have also looked at the code of some mods such as EnderIO on Github and just found more confusion. I think that the best documentation on transferStackInSlot that I have found is this. What I would like is for someone to explain this method and how to implement it. I want to actually understand the code, and not have a tutorial that tells me what to write with no explanation, like a lot of tutorials do. I understand that the EntityPlayer parameter is the player using the inventory (obviously), the slotIndex is the slot that was shift-clicked, and the methods goal is to handle shift-clicking of slots, but I don't understand things like the mergeItemStack method, what the ItemStack that transferStackInSlot returns represents, or how to implement this method. Furthermore, if I can understand this method properly, I would like to be able to implement a generic version of this method that automatically works for all containers. EnderIO seems to have it setup this way. But currently, I am trying to implement this for a machine with one input slot, 3 output slots, and a battery slot. Thanks.
  3. Oh... oops, that was just a stupid mistake Now what about the multiple masters issue?
  4. Okay, I just realised that int x, y, and z were being set wrong in the method. x was being set to xCoord + i whixh is the height, and y was yCoord + j which is the width. I fixed this, and now its finding even more masters and has 426 out of 213 blocks... so its finding twice the number of blocks there are.
  5. console is being weird... [15:51:27] [Client thread/INFO] [sTDOUT]: [net.modulartechnology.modtech.moduleModtech.common.tileentity.TileEntityDistillationChamber:checkMultiBlockForm:245]: 285 / 213 for master at 166, 81, 230 [15:51:27] [Client thread/INFO] [sTDOUT]: [net.modulartechnology.modtech.moduleModtech.common.tileentity.TileEntityDistillationChamber:checkMultiBlockForm:245]: 285 / 213 for master at 164, 81, 232 [15:51:27] [server thread/INFO] [sTDOUT]: [net.modulartechnology.modtech.moduleModtech.common.tileentity.TileEntityDistillationChamber:checkMultiBlockForm:245]: 282 / 213 for master at 164, 65, 232 [15:51:28] [Client thread/INFO] [sTDOUT]: [net.modulartechnology.modtech.moduleModtech.common.tileentity.TileEntityDistillationChamber:checkMultiBlockForm:245]: 282 / 213 for master at 164, 65, 232 its finding multiple masters, and 282 out of 213 blocks in the structure... I feel like my method to check the pattern needs to be completely redone ;/
  6. Hi. I have been working on a multiblock system for my mod, this mod will have a lot of multiblocks in it in the future, so I want this system to be dynamic and easy to use. So I decided to use a 3D array of characters to represent blocks in the multiblock. I have this working pretty smothely, but I am now stuck on actually comparing blocks in the world to the 3D char array. These are the classes that handle the characters: MultiblockHandler.java MultiblockPattern.java Here is the method that is currently called in the tileentity every 2 seconds to check the form: (This isn't working) Any help would be much appreciated.
  7. so it doesnt matter that the console says: [15:48:42] [Client thread/INFO] [sTDOUT]: [net.modulartechnology.modtech.common.tileentity.TileEntityMetallurgicLiquefier:updateEntity:50]: Machine energy: 0.0 / 64000.0, on the client [15:48:42] [server thread/INFO] [sTDOUT]: [net.modulartechnology.modtech.common.tileentity.TileEntityMetallurgicLiquefier:updateEntity:50]: Machine energy: 32000.0 / 64000.0, on the server
  8. The client needs to know because otherwise the energy won't display in the machines GUIs... um, so how do I use the toBytes / fromBytes methods then? can you direct me to a detailed tutorial?
  9. So I have an energy network working in my mod (mostly), but I have a problem with client-server synchronization. In my energy network, I have a method that allows a machine to request energy from the network, as follows: public double requestEnergy(TileEntity tile, double energyRequested, boolean doWork) { NetworkHandler.sendToClient(new MessageUpdateEnergy().setVariables(this, tile, energyRequested)); IEnergyProvider provider = getNextAvailableProvider(); if (provider == null) { return 0; } double result = provider.getStoredEnergy(); provider.addEnergy(-result); return result; } but I found out that this is only called server-side. Now because of this, I decided to do some research into packets, before this I had never touched packets. I have made packet handler and a packet to update the energy for the client to receive, but in the packet, the variables are nullified, and I cant figure out why... Here is my packet class: public class MessageUpdateEnergy extends MessageBase<MessageUpdateEnergy> { private Grid grid; private double energyRequested; private TileEntity tile; public MessageUpdateEnergy setVariables(Grid grid, TileEntity tile, double energyRequested) { this.grid = grid; this.tile = tile; this.energyRequested = energyRequested; return this; } @Override public void handleServerSide(MessageUpdateEnergy message, EntityPlayer player) { if (grid == null) { System.out.println("Grid is null"); } if (tile != null && energyRequested > 0) { grid.requestEnergy(tile, energyRequested, true); System.out.println("Sending packet"); } } @Override public void handleClientSide(MessageUpdateEnergy message, EntityPlayer player) { } @Override public void fromBytes(ByteBuf buf) { } @Override public void toBytes(ByteBuf buf) { } } At first I tried setting these variables through the constructor, but I quickly found out that I need a nullary constructor or it crashes. I also tried adding a second constructor to set the variables, this constructor was being called from the grid class, and the variables were set, but they were null again when the handleServer/ClientSide methods were called. Currently I am using a setter method to set these variables, but this is also not working. For the example above, I un-commented out the code in the handleServerSide method, and this kicks the player from the server with a NullPointerException because the grid is null. How would I get an instance of the grid this packet is being sent from, the tileentity asking for energy and the energy the tile wants? I dont really know if this is the best way of doing this, or if it's even possible... if not, please tell me the proper way. Thanks for the help. P.S Sorry if I come across as not understanding packets very well, I probably don't.
  10. Okay, I have seen both of these before, and neither really helped. For the rendering one, I don't understand scala very well, and I don't intend to do any scala code where I can do java. For the transfering the tileentity data post by Whov, I found it hard to understand, and unclear.
  11. Hi everyone. So I have started modding again, and I have run into a problem with multiparts. I am working on a cable, and have decided to make it a multipart, mainly because I want to have each connection of the cable have a separate bounding box, but also because I want functionality such as disabling a connection by clicking with a certain tool, and it also allows for the cable to easily be hidden. The problem I have is that the original tileentity of the cable is deleted when a multipart is added, and the cable's tileentity is replaced with a TMultipart. A side effect of this is also that the cable doesn't render anymore, and I know this is because the TESR cant find the tileentity. How should I transfer the data of the original tileentity to the new one, and make the TESR recognize the TMultipart? I have found plenty of tutorials on multiparts, but none of them explain how to convert a tileentity to a multipart. Any help here would be appreciated. Thanks.
  12. I have done so much research into graph traversal algorithms before attempting this. Mainly DFS, BFS, A-Star, and Diejkstra's algorithm (probably not spelled right) The problem though, is they all have to be parsed two nodes, a from node, and a to node, and they will simply find the shortest route. Now what I need it to do, is locate all the nodes in the first place, and so, from the knowledge of the algorithms I have researched, I have sort of written my own to do so. That is why it is so messy, because it has been trial and error to get it to a working (well, semi working) state. So, you are saying that I should scrap my current method, and rewrite it so that it doesn't recurse? What might be best, and this idea came to me from what Hugo said and would probably involve rewriting the majority of the method anyway, is maybe I could have it split off at a junction, so it will traverse both routes simultaneously, but how would I achieve this?
  13. Okay, I have definitely not cut anything short from the console output (other than everything irrelevant before I placed the fusebox like logging in etc) And I did notice that it was outputting some strange things, eg, the fact that it scanned 3, 4, 5 (and then without recursing) scanned 3, 4, 5 again. Currently, as soon as it finds an available / valid node to move to, it will go to it, and forget about whatever remaining directions there are left to scan. To be honest, come to think of it, this probably shouldn't be the case. So what you are saying, is that I should have it scan al six sides before moving onto the next cable? or that it should have a ForgeDirection parameter in the method to use when recursing? I have a backtrack because, it doesn't split off in both (or more) directions at a junction. I don't know how I would achieve this, and so what it does, is go down the first valid direction it can, and as a result, only travels down one path, any junction (before I set up the backtrack code) would be left completely alone. Also, the cables (Node) gets marked as scanned, so when it returns to the head of the backTrack queue, logically, it should take the unscanned path, and not continue back down the already scanned path. Also, without marking it as scanned, the method would scan around the first cable, find an adjacent cable, scan around that, find the first cable, scan around it, find the second cable, scan around it, find the first cable etc, it would just jump back and forth between those two until it has recursed 64 times (the range limit). This was what was occurring before I figured out how to mark the node as scanned (I discovered that in the Node class I had to override equals(Object o) {...} to hold some custom info, and compare the coords of the nodes, hashCode() {...} because that is apparently good practice to override when overriding equals, and also I had to implement Comparable<T> to make the list / set / queue work properly with the Node) You said to find out why it isn't stopping at already scanned cables, it is though. That is kind of the strange thing.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.