Jump to content

wesserboy

Members
  • Posts

    71
  • Joined

  • Last visited

Everything posted by wesserboy

  1. I have figured it out, it was indeed a scaling issue. After looking at the event class I noticed it supplies you with a resolution. I solved it by getting the scaled height form the event: event.getResolution().getScaledHeight_double()
  2. I am working on a mod that adds some overlays to the game, and for one of them I wanted to render an entity on the hud, but I'm having some problems positioning it where I want it. I am using the RenderGameOverlayEvent.Post event to render it to the hud. When I don't apply any translations it appears in the top left of the screen, which makes sense. Since I want it to show up in the bottom left, I would assume I have to translate it by the height of the screen (I assumed was Minecraft.getMinecraft().displayHeight). However this doesn't work, I have to divide it by 2 to get it to show up at the bottom. I am very confused by this behavior. Then if I make the game fullscreen, the model disappears. I assume there is some kind of scaling going on here, but I have no idea how to reliably calculate the amount I want to translate the model down by. The translation I am currently using is: GlStateManager.translate(25F, mc.displayHeight / 2F - 10, 50F); which somehow works on the default window size. The entire class can be found here: https://github.com/wesserboy/Overlays-MC-/blob/master/src/main/java/com/wesserboy/overlays/renderers/BowAimHelp.java Anyone know how I can render the model in the bottom left of the hud, independent of the window size?
  3. Yes, you still need to call world.spawnEntityInWorld(cow); to actually spawn the entity in the world As a side note: Make sure you only spawn the entity on the server (!world.isRemote)
  4. UPDATE: Problem #1 is magically solved . I suspect that the problem was indeed the "particle" element missing and i probably just forgot to save the file somewhere along the line....... oops Problem #2 is also solved. I solved it by overriding isFullCube to return false (seems obvious now ). I also found the isFullBlock method, should i override this as well? Because it feels to me that these two methods are basically the same thing. (Correct me if i'm wrong)
  5. Hello everyone, For my mod I am making some kind of pedestal that can hold an item, it looks like this: https://s31.postimg.org/6c0glhp3f/2016_07_12_17_05_22.png[/img] I am using a json model file to render the base, and a TileEntitySpecialRenderer for the pillars and the item. The model is rendering correctly, however there are still some minor details that are not working correctly: #1: Probably the easiest one (I think). The block-break particles show up as missing texture. After reading numerous forum posts my friend Google kindly provided me it seemed like the problem always was the missing "particle" element in the json model. Adding this element did however not fix the problem for me. I suspect the problem might be because i am also using a TileEntitySpecialRenderer, but i couldn't find a solution. this is my json model: https://gist.github.com/wesserboy/26c88e64bafa39c7204bb36421e7b8c5 SOLVED, see 2nd post for the answer #2: The bounding box for my model is behaving very strange. Since my model is not occupying the full block space i wanted to set up a custom bounding box. I used the following code to do this: protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.125D, 0.0D, 0.125D, 0.875D, 0.5D, 0.875D); @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } As you can see in the first picture the wireframe shows up the way i expected, and from the top the bounding box acts the same as the one form the slab (The box has the same height), because the player auto-walks on top of it. However when i stand one level below the block (face the same level as the block) and i walk into the block i get the following screen: https://s31.postimg.org/yq5w5dcnf/2016_07_12_17_06_02.png[/img] If i am in survival mode the player also takes damage (suffocation). This leads me to believe that the problem lies in the collision box, however i have no idea how to solve this. SOLVED, see 2nd post for the answer #3 (Bonus issue) I am currently rendering the pillars by rendering obsidian using the RenderItem and scaling this to look like pillars. This is obviously not the correct way of doing things, but i wasn't able to find a way to animate certain parts of a json model using the TileEntitySpecialRenderer. If anyone knows how to properly do this, be sure to let me know. Any help would be much appreciated! If more code is needed, just ask and i will provide it.
  6. The achievement class has a field 'parentAchievement'. Use the same method as before to check if the player has the parentAchievement as well.
  7. Just out of curiosity, why bother translating coordinate symbols? I am pretty sure they are the same in all languages anyway? also, to convert an int to a String you can use: String.valueOf(i); Integer.toString(i); instead of "" + i; which looks a bit cleaner in my opinion
  8. Thank you! I implemented it, and it works like a charm. It is probably also way more reliable than my tick-handler magic
  9. I figured out the problem and it works now. I do however feel like there must be a better way to solve this. I will explain what was causing the crash, and what i did to fix it. I would like to hear any recommendations/ideas on how to improve it, if you have any. The cause: The crash was a ConcurrentModificationException. There were two threads modifying the same List simultaneously: * The thread handling my packet was adding the fake player to the list. * The server thread was checking the chunks around the players in this list in order to tick them, send updates to clients etc... When these two operations happend at the same time --> ConcurrentModificationException. The fix: When the message is received (On the server), I subscribe it to the TickEvent.ServerTickEvent. I use the different phases of this event to monitor the tick progress, and i schedule the insertion of the fake player in between two ticks. (After Phase.END and before the next Phase.START) Fields of improvement: 1. I feel like there should be a better way of loading distant chunks altogether. Inserting fake players and rerouting vanilla packets feel really hacky, and i can't imagine this being the first situation where distant chunks are needed on the client. 2. I think there must be a better way to schedule tasks in between ticks. Vanilla minecraft also has to insert the player into this list when it spawns a new player. This (obviously) doesn't cause a crash, so a mechanism to handle this must already be in place. (at least, I would think) EDIT: Has been improved, now uses a mechanic that is already present in vanilla 3. Possibly other things I haven't thought of yet As mentioned before, any feedback is greatly appreciated, since I am not yet fully convinced of the effectiveness of my current approach. thank you for your interest
  10. I wasn't able to solve the problems of the previous approach, so I am currently working on a new approach: (still to problem #1) I am now creating a fake EntityPlayerMP, and put that one on the location the player should be looking. The packets sent to this fake version, i forward to the client of the original player. The game crashes when i add my fake version to the PlayerChunkMap. It complains about a ConcurrentModificationException. This must be thread related (i think), I can't however seem to figure out which thread is (constantly?) reading the array of PlayerChunkMapEntries. This is the crash log: If additional code is required i will provide it. Any information regarding the crash, or this problem in general would be nice, since I am really stuck on this one
  11. While looking through the minecraft code i found there is one place where such an exception is thrown: net.minecraft.server.MinecraftServer: line 776 It gets thrown when the WorldServer.tick() method fails. This confirms my suspicion that I am indeed overloading the server (which causes a tick to fail). I am confused however why balancing out the requests doesn't work. I think load balancing should fix problems regarding too heavy loads... Anyone that can explain why balancing doesn't work, or point me in the right direction as to how i could fix this?
  12. You have a valid point here However, i couldn't find my answer in the LookingGlass source. I did find a (currently) half working solution: I created a custom packet that the client can use to request a chunk from the server. I reply to this packet by sending a vanilla chunk packet back to the client. Here is the code i use for this packet: @Override public void handleServerSide(MessageChunkRequest message, EntityPlayer player) { if(player instanceof EntityPlayerMP){ EntityPlayerMP playerMP = (EntityPlayerMP) player; if(playerMP.worldObj instanceof WorldServer){ WorldServer world = (WorldServer) playerMP.worldObj; Chunk chunk = world.getChunkProvider().provideChunk(message.chunkX, message.chunkZ); Packet<?> packet = new SPacketChunkData(chunk, 65535); playerMP.connection.sendPacket(packet); } } } On flat worlds this works, however on non-flat worlds this causes a crash: I have never encountered such a crash, but my guess is that the server is overloaded because of all the chunks i request. (most of which have not been generated yet). But if someone could confirm that this is indeed the case that would be nice. I tried only requesting the next chunk when the previously requested one has arrived, but this doesn't help, which makes me think there might be another problem causing the crash... Any help/tips are greatly appreciated.
  13. Turns out I was wrong, he updates them when the client receives the chunk data. I looked which method he used to force a render update: markBlockRangeForRenderUpdate ( How did i miss that method... My brain must have been dead last night). For people that are curious, i found it here: https://github.com/XCompWiz/LookingGlass/blob/946429fc5e7c82393b23e43f1820104b75febbf9/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketChunkInfo.java Problem #2 is fixed now, the chunks re-render when the player steps off the block and it look fine. The only problem that remains is problem #1: How do i force the client to load (and render) a chunk far away from the player?
  14. I had stumbled upon looking glass before, but it seems this is only intended for locations in different dimensions. My block is limited to only the dimension the block is located in. He wrote a custom way to retrieve chunk data from the server (since vanilla doesn't support this for multiple dimensions), but i was kinda hoping to be able to use the vanilla way (Since i stick to the world the client is in already anyway). I don't think he does any marking for re-rendering, since he doesn't move the vision of the actual client side player. I could be wrong though. I will browse through the code once more, to see if it might still be able to give me some clues
  15. Hey everyone, I am currently working on a block that, if the player stands on it, changes the POV to a remote location, which is determined by the block. To achieve this, i made a renderTick handler. Here i check if the player is on top of one of these blocks. if this is the case i change the position of the renderViewEntity in the phase.START, and set it back to the original values in the phase.END. For locations that are close to the original location this works perfectly, however, when the location is further away i run into two problems: 1. The chunks at the remote location are partially/not rendered. I figured this was because the chunks weren't loaded on the client. I tried to check if they were loaded, and it turned out this was indeed not the case. However i can't seem to be able to force the client to load these chunks. So my first question is: How do i force the client to load (and render) these remote chunks? 2. When i step off of the block, the POV is restored. However depending on how far away the POV was replaced, the chunks at the original position are partially/not loaded. I thought these chunks maybe got unloaded because the player was located far away, but this wasn't the case. When i place/break a block (cause a block update) in one of these chunks, it re-renders. I tried to mark all chunks within the render distance dirty, but this didn't work. My second question is: What is causing this and/or how would i go about fixing this? You can find my RenderTickHandler class here: https://gist.github.com/wesserboy/71a7bc547ee8e1e58e8f76c15cdbb3c6 All relevant code should be in there. However if you feel like you need to see more/other code, be sure to let me know, and i will post it. Any answers, clues, ideas, etc... is very much appreciated! Thank you!
  16. Hmm, that's what i figured... Since i don't see myself implementing a new event for forge i guess i'll have to hold off of this one for now. Thank you for confirming my suspicion though, now i can at least stop looking for it
  17. yeah, something along those lines. Lets say i bound the block to a redstone lamp, and i put a lever on the block, i want the lamp to turn on (as if it was powered by the lever). Or if i bound it to a block of stone, i want the stone to provide passive power, etc...
  18. Hello everyone, I will try to explain my idea as good as possible, but if anything is unclear, be sure to ask me to clarify. I have a block, which has a position in the world it is 'bound' to. This block should send all the redstone signals it receives to that bound location, no matter what block is at that location. First off i thought of making a fake air block at the position which would send all its redstone-related calls to the block it is 'bound' to, but the problem is that the bound location won't always be air, so i can't just put another block there. When browsing some classes i found that the world calls block-specific methods to get its redstone, which means i can't influence this directly. Then i thought: is there any (open source) other mod that does the same? However, every mod i could think of uses a block at the receiving end, which is exactly my problem. then i browsed the different events and hooks forge offers, but i couldn't find any that have to do with redstone. This is where i am stuck. I don't have any code to show, since i can't figure out how to implement this. I am basically asking if anyone knows a way to do this, or classes to look at, or any other way to get more info about this topic. Thank you in advance! -Wesserboy
  19. My system is functional for vanilla now It doesn't handle nbt data yet, but this is the next thing i am going to work on. This is the itemStack list it generated on the server: http://pastebin.com/KZ78zkhE the 2048 indicates the amount of bytes used to transfer the data to the server (I found this number using buf.array().length, which i am guessing is the amount of bytes... but 2048 almost seems too perfect ) I am using the same mapping system i posted earlier, i just wrote a system to increase efficiency after the first mapping, and to send it all to the server, if you're interested in any of those i will happily post them, but i think they're quite generic. Now i will implement nbt support. I did know about ByteBufUtils, but i want to look for patterns in the nbtData before i send it to make sure i send the least amount of data needed.
  20. The system is coming along quite nicely, I have figured out how i want to go about doing things, and it just produced the first useful results. My system tries to find a pattern in the subItems, and maps this pattern to every id. this way i only have to send the pattern to the server to reconstruct the subItems. This is the id system i am currently using (There are two front slashes since i copied it from the comments within my class ) //Using an id system to visualize the amount of data needed to reconstruct on the server //id 0: no subItems //id 1: dmg subItems, starting at 0, incrementing by 1 for every subItem //id 2: dmg subitems, starting at another value, incrementing by 1 for every subItem //id 3: dmg subitems, starting at 0, incrementing by another value for every subItem //id 4: dmg subItems, starting at another value, incrementing with another value for every subItem, but with regular pattern //id 5: dmg subItems, with irregular pattern //id 6: nbt subItems...? (still need to figure this mapping out...) // //How to send this to the server? //First send the id of the needed data // //id 0: Item id //id 1: Item id, amount of subItems //id 2: Item id, amount of subItems, start value //id 3: Item id, amount of subItems, increment value //id 4: Item id, amount of subItems, start value, increment value //id 5: Item id, amount of subItems, dmg values //id 6: not sure how to map this yet, as a result not sure how to send it yet // //variable formats: //data id --> byte //item id --> short will probably do (don't think id's go higher than 32767) //amount of subItems --> byte (if you have more than 127 subItems you're doing something wrong...) //start value --> byte? haven't encountered a startValue higher than 127 //increment value --> byte //dmg value --> not sure yet, maybe a scaling system with a header byte indicating the format There were some interesting results there, every id has been mapped at least once, except 4 (and 6 obviously), which i thought was pretty interesting. It generated the following mapping: http://pastebin.com/uYCirVy8 (I generated this list in minecraft 1.7.10, this is why the 1.8 items are missing from the list) The code i used to generate this can be found here: https://gist.github.com/wesserboy/b05aa0129d3079083ac8 This is what i am planning on implementing next: --> write a method that optimizes the amount of data needed by remapping some id's --> make a system that transfers the data to the server --> make a system that constructs a list of itemStacks on the server, based on the data received from the client ----- at this point it should be fully functional for vanilla minecraft ----- --> figure out how to map the nbtData as efficient as possible Since I am not quite sure yet how to efficiently map the nbtData, any idea's are welcome
  21. You can calculate it yourself there are 20 ticks in a second, so you just multiply the cooldown in seconds with 20 to get the cooldown in ticks. since the cooldown is a constant value, you can hardcode it in a field like i described earlier
  22. this is what i would do: (remember, you can design your own system to fit your needs, this is just what i would do) have a private final field in your item class containing the cooldown time in ticks. (in this example i'll call it cooldown). timer is the value of the timer (don't know if you want to save it to the nbt or as the dmgValue) in opUpdate(): if(timer > 0){ >>> decrement the timer } in onItemUse(): if(timer <= 0){ >>> use spell >>> reset timer to cooldown } you can use this to get an idea of a possible implementation, but you'll have to implement the actual system yourself, so you can make sure it fits your needs
  23. you can override the onUpdate() method in your item class, this method gets called once per tick (20 times per second) and you can base your timer off of that. as to how to make the timer itself, there are many different ways to implement one. If you are not using the itemDamage yet, you can use this to safe your timer. If you are already using it you can write your timer to the nbt.
  24. I am currently working on my system, and i am writing a system that maps the amount of data needed to reconstruct the subItems on the server. I ran into something to think about, and it made me think of what you said earlier (the quote): can an itemStack have default nbtdata? and if so, can this nbtdata be requested on the server? My system is not functional yet, if it produces actually useful results i will post the code. Also, if you don't mind i will change the title to something that fits the current discussion better
×
×
  • Create New...

Important Information

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