Jump to content

DeadPix

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by DeadPix

  1. Alright guys, thank you all for wonderful replies. As @jabelar asked, what I am trying to achieve - I am trying to write an 'AI' that will be walking through the lands and completing some goals (the AI takes over the player). At the very moment I am trying to come up with some reasonable path finding algo that I could further extend. I pretty much want to set target destination to which from player.posX/posY/posZ the AI will travel, and so I need to probably start with creating a structure that will represent visible surface. Is it correct? And would something like this be a good approach? Start with figuring out on what block I am currently standing. Check block bellow and the block above on whether it is an air block to determine that I am on 'some sort' of a surface. Continue with all blocks around (all eight of them) the same way as above, storing only those that have 2 (or 3 - possible to jump) air blocks above them. Extend the 'circle' and so on and so forth, up until some distance. Output of this function would then be sort of a map of my surroundings on which I could then start calculating the best path. Also when I would need some specific item or tool or ore to mine, I would take it into account in the algorithm I mentioned and store these values there too so I could feed my path finding with that.
  2. Hello again! I need to get an information about the blocks that are around the player (or a certain location) - probably for few chunks around the player. I understand that I can loop through coordinates around the player and create a BlockPos structure for each block around the player and then query them (pretty much check them in condition) on what they are, but it seems to me, that this functionality is something that should be already implemented in the game/forge itself. I looked through the documentation and there is nothing except for BlockStates, I also tried looking into the code, but am pretty much clueless at the moment. What is the best way to do the following. Get information about 'any' block? Is it to create a BlockPos object for it and then somehow convert it to Block and find info from there? And how would I convert BlockPos to Block correctly, please? Get information about chunk and its composure (e.g. what blocks are in there at specific positions, or to specified 3D-depth from some position? Are there dedicated structures that can be loaded easily, or do I have to manually specify every block I am interested in inspecting? Thank you!
  3. @jabelar, @Animefan8888 Alright, thank you guys for your input - in the end, I decided to create a weaker version of aforementioned SharedPreferences (for boolean value only) and it seems to work exactly as I wanted it to. I need it only client side - and the scenario when player edits those values, is not a problem. I do not need it to persist between game loads, so I also do not save it anywhere, but in the future I will need some persistent functionality for something else, so I am also grateful for your suggestion on reading around it, jabelar. Thanks.
  4. I am only a little bit smarter after reading it now, than I have been after reading it the last time. But also I am now certain that I need it client side only. So, what does it mean for my original question, please?
  5. I am not sure how to exactly determine that. But probably only client side? It will be mostly client relevant values like 'is this thing on or off' and similar. Is that client side only?
  6. Hello, in mod I am working on I have a need to store some values that I would need to check on in multiple places in my mod. I know that this value will be unique for every player (pretty much every instance of Minecraft running the mod will have this value different). In Android, there are SharedPreferences into which one can store such information. Is there dedicated class/space in forge that I should take advantage of? Is there a recommended approach for this? Or will it be okay just to create a public static class, let's say SharedPreferences with HashMap and getters and setters for indexes in the HashMap? Thank you in advance.
  7. Most likely to make development more user friendly. I believe the original names func_xxx are a result of decompilation, and the new names are user friendly aliases for them.
  8. coolAlias: I am sorry for my necromancy here, but I'd like to ask related question. You said: Note, the emphasizes is mine. What do you exactly mean by changing direction smoothly? Is there a way to change direction smoothly in a sense that player will get more than 20 FPS when rotating? I already tried hooking my yaw rotation changing code onto drawScreen() method and onRenderTick() methods and I never get the smooth feeling out of it. It is always capped at 20 changes per second (so... it updates every tick, which makes the transition 20 FPS, despite the rest of the world runs nicely 60fps). Any advice here?
  9. Hello, I know 1.9.4 is fairly old version, but I figured not much has changed since then regarding the tick/render mechanics, so answers for current version should apply as well. I am working on something that controls player's yaw/pitch and I bumped into following problem: * I do most work when onPlayerTick() occurs - which basically means to calculate next pitch/yaw correction, add it to Minecraft.getMinecraft().thePlayer.rotation(Yaw|Pitch) and move on to next iteration. * My computer has steady 60 FPS, there are 20 ticks per second, the pitch/yaw rotation updates do not look smooth, because I am only allowed to change it once per 3 frames rendered. * I know it is possible to make it look smooth, because it looks smooth when I control the yaw/pitch with my mouse when playing. * This video illustrates my problem. I did some Googling and found out, that I might be able to use partialTicks and subscribing to drawScreen() method, so I tried onFrame method, which does following: // Helper variables static float previousYaw = 0; static float previousPitch = 0; static float desiredNextYaw = 0; static float desiredNextPitch = 0; static float desiredYaw; static float desiredPitch; public static void onFrame(float partialTicks) { Minecraft.getMinecraft().thePlayer.rotationPitch = (desiredNextPitch - previousPitch) * partialTicks + previousPitch; Minecraft.getMinecraft().thePlayer.rotationYaw = (desiredNextYaw - previousYaw) * partialTicks + previousYaw; } Then I subscribe this to GuiScreenEvent.DrawScreenEvent event like this: @SubscribeEvent public void drawScreen(GuiScreenEvent.DrawScreenEvent event) { // Help with smoothing transitions between yaws/pitches if (this.currentTask.taskName.equals("DawdleAroundTask")) { DawdleAroundTask.onFrame(event.getRenderPartialTicks()); } } And finally, I still, every onPlayerTick occurrence, during ClientTickEvent.Phase.START, run method of the DawdleAroundTask.runTick() which looks like this (yaw/pitch corrections are unimportant and therefore I removed them to provide minimal readable sample): // Mimicking pre-tick-phase Minecraft.getMinecraft().thePlayer.rotationYaw = desiredNextYaw; Minecraft.getMinecraft().thePlayer.rotationPitch = desiredNextPitch; // /Mimicking pre-tick-phase /* HERE IS WHERE I EXPECT A MUCH MORE LOGIC TO BE DONE AND THEREFORE PRETEND PRE-TICK-PHASE AND POST-TICK-PHASE */ // Mimicking post-tick-phase desiredYaw += getRandom()[0]; desiredPitch += getRandom()[1]; // Corrections desiredNextPitch = previousPitch - pitchDistance; // Mimicking post-tick-phase When I run this now, it still looks like it is updating only every third frame/once per tick, which is not nearly enough. How do I make it look smoothly? I would like it to look as if I am controlling the mouse and the game smoothly turns player around when I move the mouse. Is it possible that I am using wrong events? I am sorry for rather a long post, but I feel like that just reading the text part describing what events and what methods I use, could tell enough to you, ultra smart people around here, on what I am doing wrong. I always come here to beg for help as a last resort and I seriously admire the level of understanding and insight into it that you guys here have. Looking forward to your replies!
  10. Thank you for replying. Now I am looking into the implementation as you suggested and can't wrap my mind around this - in EntityPlayerSP on lines 913~917 I see following code: boolean flag = this.movementInput.jump; boolean flag1 = this.movementInput.sneak; float f = 0.8F; boolean flag2 = this.movementInput.moveForward >= f; this.movementInput.updatePlayerMoveState(); When I look into MovementInput#updatePlayerMoveState(), its implementation is blank. Why? And what is the purpose of this in a bigger picture? What I am pretty much trying to do is essentially simulate player control - I want my mode to take over control and do some actions. My current idea is to implement logic that would every tick (onPlayerTick?) check the state of current task to be performed (for example "travel to coordinates", "break a block" and similar). I will have probably a lot of smaller classes representing tasks to be executed and will be executing them in order to accomplish bigger tasks: e.g. "get to x,y,z" will be composed of "travel to x+1, z+1, adjust y if needed" where "adjust y if needed" would be composed of some logic that would determine when to jump/place a block, how many blocks to place. For this, will I need to know stuff like "how long in ticks does it take for this particular block to break"? And what do you think of my current approach? Do you see possible weak spots in doing this the way I am currently planning to do it? Also, would you recommend to me to use something else than setting up MovementInput value properly and putting it to getMinecraft().thePlayer.movementInput? Thanks in advance for any help provided!
  11. I am looking for something like documentation to mechanics of the game and the values of different attributes (right now, for example I would like to know what number should I put in MovementInput.moveForward and MovementInput.moveStrafe to make it the same values as is normal for walking & sprinting in Minecraft. But in the future I am sure I will have to handle more stuff like this and I will have to look up other values for other attributes. Where can I find those things? I checked for example this: http://minecraft.gamepedia.com/Sprinting, but it has certainly different values than those I should put in the mentioned class.
  12. Technically, yes he does have mental ownership of the name - he created the name earlier than you and it does not matter that he is doing nothing with it. TheBest (haha) you can do is do the following: Find out who's the author, ask him to hand over the name (with reasonable points), Go with what others usually go with - name your mod: 'thebest108's inventors toolbox'. If your mode becomes successful, they will start to omit your name in it, and your mod will be highest in a Google search for inventors toolbox search so you won't be penalized for slightly different mod name.
  13. This may actually be a buggy behavior. I have rewritten this to 1.9.4: @SubscribeEvent public void clickOnLadder(PlayerInteractEvent event) { if (event.getPos() != null) { System.out.println(event.getPos().getX() + " " + event.getPos().getY() + " " +event.getPos().getZ()); System.out.println(event.getWorld().getBlockState(event.getPos()).getBlock().getLocalizedName()); } } And it produces following output: Empty handed: Ladder in hand: It all looks the same to me. I also tried right clicking the block with other placeable items and it produced the same output. Strange thing though is that the code snipped is apparently called multiple times.
  14. Unfortunatelly I can not provide you with tutorial, but I figured out that Immersive Engineering mod is open source so I suggest you to take a look to their code and maybe you will find something useful to your goals. :-)
  15. Ernio: Thank you for your input, I will have a look into materials you provided. Just one more question to clarify exactly what you meant: 'While code itself if not bad in mean of ticks/timing, it is bad regarding design.' Is there a typo in 'itself if not bad' or not? Like if you meant to say 'is not bad' implying that it is correct to subscribe to PlayerTickEvent, or you meant to say that I am questionably wrong with subscribing to that event? Thanks in Advance. :-)
  16. I think you could try subscribing to onPlayerTick() using: @SubscribeEvent public void onPlayerTick(PlayerTickEvent evt) There are 20 ticks per second. Adding a tick counter is what I would do. More reading on ticks subject can be found here. Update - something like this could work: private int tickCounter = 0; @SubscribeEvent public void onPlayerTick(PlayerTickEvent evt) { if (tickCounter % 20 == 0 && tickCounter < 201) { player.attackEntityFrom(DamageSource.drown, 2); } tickCounter++; }
  17. Hi! I am currently working on something really similar to what you described. Have you progressed on that matter?
  18. Hi! I am currently working on something really similar to what you described. Have you progressed on that matter?
  19. OrangeVillager91, Ernio: Thank you, I appreciate your replies. I already resolved problem I was referring to in the first post in this thread, and now I intend to do the same with the current one. I did a thorough google search for the topic of ClientPlayerController but no luck so far. I studied a bit more the game mechanics (still lot to catch up though) and find out that there is always client/server relationship. But I also noticed that people talk A LOT about 'their GUI'. I understand meaning of the word, but I fail the grasp the concept in the context of it. Let's assume I want my mod to take control over player and move him one block ahead, move not teleport. What is the approach? Is it something like this? I tell the (local - I consider having the mod operational only for single player, for now) server I move my player block ahead (How will I do that? Where should I look for functions that can do that? More specifically please :-) ) I tell GUI that I moved the player? (if positive, how do I even access the GUI and tell it to do such a thing) Or - there is no need to notify GUI about the change, minecraft will do that on its own? One more thing that crossed my mind is that people talking about GUI are actually talking about their HUD part of the UI that player sees and update that GUI? Thanks in advance for your further assistance.
  20. OrangeVillager91, Ernio: Thank you, I appreciate your replies. I already resolved problem I was referring to in the first post in this thread, and now I intend to do the same with the current one. I did a thorough google search for the topic of ClientPlayerController but no luck so far. I studied a bit more the game mechanics (still lot to catch up though) and find out that there is always client/server relationship. But I also noticed that people talk A LOT about 'their GUI'. I understand meaning of the word, but I fail the grasp the concept in the context of it. Let's assume I want my mod to take control over player and move him one block ahead, move not teleport. What is the approach? Is it something like this? I tell the (local - I consider having the mod operational only for single player, for now) server I move my player block ahead (How will I do that? Where should I look for functions that can do that? More specifically please :-) ) I tell GUI that I moved the player? (if positive, how do I even access the GUI and tell it to do such a thing) Or - there is no need to notify GUI about the change, minecraft will do that on its own? One more thing that crossed my mind is that people talking about GUI are actually talking about their HUD part of the UI that player sees and update that GUI? Thanks in advance for your further assistance.
  21. Again, thanks for your replies, Draco18s & diesieben07, I put to use both of them. Now when I believe I solved my problem I also updated original post to be more descriptive and contained my solution. Would you mind looking at the facts I provided and validating them? I would like to avoid confusing visitors coming from search engine.
  22. Again, thanks for your replies, Draco18s & diesieben07, I put to use both of them. Now when I believe I solved my problem I also updated original post to be more descriptive and contained my solution. Would you mind looking at the facts I provided and validating them? I would like to avoid confusing visitors coming from search engine.
  23. Thank you for your reply. So even when I want to make 'single player' mod, I have to count in the 'server side'. If I want to react to message sent from the 'client' (I manually type in the game "/runbot"), I have to intercept this message "on server"? How will I do it then, please?
  24. Thank you for your reply. So even when I want to make 'single player' mod, I have to count in the 'server side'. If I want to react to message sent from the 'client' (I manually type in the game "/runbot"), I have to intercept this message "on server"? How will I do it then, please?
  25. As soon as I figure out the problem I suggested in the other post, I will face another problem - how to make the player move? I imagine there is a singleton object that represents player, which will allow me to interact with it. Am I right? How do I get my hands on the object? Once I get my hands on the object, I also imagine there are methods to allow me to teleport player instantly to given coordinates. But that's not what I would like to do that. I would like the player to actually move to the position. For the start, let's consider only flat platform the player will be moving on. In the future, I suppose I will teach the bot that controls the player to overcome some obstacles. Maybe I should have started with different question. Is it possible to write a bot that will "take over" control over player (the one from which perspective I am looking) and make him do something? If positive, how to do some basic stuff like moving the player? Thanks in advance for any help provided.
×
×
  • Create New...

Important Information

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