Jump to content

bkvaluemeal

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by bkvaluemeal

  1. I took that out and instead told it to write the pixel black. There was an issue with the map looking like an acid trip. Everything was kinda... melting.
  2. I have the minimap updating at 5 FPS. This seems to work a lot better, but only appears to be delaying the inevitable. This was mainly a proof of concept for me. I may decide to work on this more later, but for now I am finished.
  3. Even when I take out the for loops and render a black box, I still lag and break the game. I have no doubt that all that cleanup is a problem, but there has to be a way to reuse the dynamic texture. Unless, I'm approaching this in entirely the wrong way.
  4. No, it "crashes" because Java's memory fills up and the server shuts down. I get messages saying the server jumped ahead X number of ticks. I'm not handling the dynamic textures properly. I don't exactly know how other than to create a new one and load it.
  5. That's true. Haha! Could you suggest a way to get the topmost block or perhaps a better way to draw the map without crashing my client? I'm most concerned about the latter. Edit: I made the map look better. It checks blocks above and below the player. public class MiniMapHandler { private static final Minecraft MC = Minecraft.getMinecraft(); public static final BufferedImage MAP = new BufferedImage(75, 75, BufferedImage.TYPE_INT_RGB); @SubscribeEvent public void onTick(PlayerTickEvent event) { BlockPos center = MC.thePlayer.getPosition(); MAP.flush(); for (int z = center.getZ() - 37; z < center.getZ() + 38; z++) { for (int x = center.getX() - 37; x < center.getX() + 38; x++) { for (int y = center.getY() + 10; y > center.getY() - 10; y--) { BlockPos pos = new BlockPos(x, y, z); IBlockState state = MC.theWorld.getBlockState(pos); if (!state.getBlock().isAir(MC.theWorld.init(), pos)) { int color = state.getBlock().getMapColor(state).colorValue; MAP.setRGB(x - center.getX() + 37, z - center.getZ() + 37, color); break; } } } } MAP.setRGB(37, 37, 0xFFFFFF); } }
  6. I knew that creating this wasn't going to be easy, but this is a lot of work! With The Division launching soon, I honestly don't think I'll be working on this much longer. I've opted to use getMapColor() (despite what I said) in lieu of starting a huge project. I have created a much better way to draw the map, although is there a way to update the DynamicTexture without making a new one every time? My game starts to lag after a while and updateDynamicTexture() doesn't seem to do the trick. MiniMapHandler: public class MiniMapHandler { private static final Minecraft MC = Minecraft.getMinecraft(); public static final BufferedImage MAP = new BufferedImage(75, 75, BufferedImage.TYPE_INT_RGB); @SubscribeEvent public void onTick(PlayerTickEvent event) { BlockPos center = MC.thePlayer.getPosition(); for (int z = center.getZ() - 37; z < center.getZ() + 38; z++) { for (int x = center.getX() - 37; x < center.getX() + 38; x++) { IBlockState state = MC.theWorld.getBlockState(new BlockPos(x, center.getY(), z)); int color = state.getBlock().getMapColor(state).colorValue; MAP.setRGB(x - center.getX() + 37, z - center.getZ() + 37, color); } } } } Inside onRenderGui(RenderGameOverlayEvent event): TEXTURE = new DynamicTexture(MiniMapHandler.MAP); MC.getTextureManager().bindTexture(MC.getTextureManager().getDynamicTextureLocation("minimap", TEXTURE)); drawModalRectWithCustomSizedTexture(MC.displayWidth / 2 - 78, 13, 0, 0, 75, 75, 75, 75); The map reminds me of NetHack...
  7. This works, but I get tons of errors. What is the right way to do this? I really don't even want to use the getMapColor() function because it flickers between black and green. I don't know why. public class MiniMapHandler { private static final Minecraft MC = Minecraft.getMinecraft(); private static final BufferedImage MAP = new BufferedImage(75, 75, BufferedImage.TYPE_INT_RGB); private static DynamicTexture TEXTURE = new DynamicTexture(MAP); @SubscribeEvent public void onTick(PlayerTickEvent event) { // (Y, X) They're swapped. Don't feel like retyping. BlockPos zero_zero = MC.thePlayer.getPosition(); BlockPos one_zero = MC.thePlayer.getPosition().north(); BlockPos n_one_zero = MC.thePlayer.getPosition().south(); BlockPos zero_one = MC.thePlayer.getPosition().east(); BlockPos zero_n_one = MC.thePlayer.getPosition().west(); IBlockState state_zero_zero = MC.theWorld.getBlockState(zero_zero); IBlockState state_one_zero = MC.theWorld.getBlockState(one_zero); IBlockState state_n_one_zero = MC.theWorld.getBlockState(n_one_zero); IBlockState state_zero_one = MC.theWorld.getBlockState(zero_one); IBlockState state_zero_n_one = MC.theWorld.getBlockState(zero_n_one); int color_zero_zero = state_zero_zero.getBlock().getMapColor(state_zero_zero).colorValue; int color_one_zero = state_one_zero.getBlock().getMapColor(state_one_zero).colorValue; int color_n_one_zero = state_n_one_zero.getBlock().getMapColor(state_n_one_zero).colorValue; int color_zero_one = state_zero_one.getBlock().getMapColor(state_zero_one).colorValue; int color_zero_n_one = state_zero_n_one.getBlock().getMapColor(state_zero_n_one).colorValue; MAP.setRGB(37, 37, color_zero_zero); MAP.setRGB(37, 38, color_one_zero); MAP.setRGB(37, 36, color_n_one_zero); MAP.setRGB(38, 37, color_zero_one); MAP.setRGB(36, 37, color_zero_n_one); TEXTURE = new DynamicTexture(MAP); } public static ResourceLocation getTexture() { return MC.getTextureManager().getDynamicTextureLocation("minimap", TEXTURE); } } Inside onRenderGui(RenderGameOverlayEvent event): MC.getTextureManager().bindTexture(MiniMapHandler.getTexture()); drawModalRectWithCustomSizedTexture(MC.displayWidth / 2 - 78, 13, 0, 0, 75, 75, 75, 75);
  8. Right, my question is how do they get that texture? The default Minecraft blocks are easy enough, but how do you grab the textures of custom blocks? Edit: Let me clarify, I can use the loadTexture() function I mentioned before only if I know where the resource location is, correct? I will assume I don't know that. Some modder may decide not to follow convention. I can't seem to find a way to pull a texture from an arbitrary block.
  9. Well, no, but what I'm saying is that Xaero's map, for instance, looks nothing like the item you can craft in game. It is much more detailed. I don't think the getMapColor() function has the ability to yield that level of detail. So, how do they do it? I'll play around with the getMapColor() function and see what I get. I'll post that when I'm done.
  10. Cool, that works too. IBlockState state = MC.theWorld.getBlockState(MC.thePlayer.getPosition()); int color = 0xFF000000 | state.getBlock().getMapColor(state).colorValue; drawRect(50, 50, 100, 100, color); Although, it's not the level of detail I was looking for. It swaps between black and the actual color for whatever reason. Xaero's map mod doesn't work like this, right?
  11. At first I tried this: IBlockState state = MC.theWorld.getBlockState(MC.thePlayer.getPosition()); int color = state.getBlock().getMapColor(state).colorValue; drawRect(0, 0, 100, 100, color); That didn't work. So then I found a thread talking about getting the textures from the jar like so: MC.getTextureManager().bindTexture(new ResourceLocation("textures/blocks/grass_side.png")); drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 64, 64, 64, 64); This does work, and I could get the RGB values like this: static int[] loadTexture(String block) { try { final ResourceLocation resourceLocation = new ResourceLocation("textures/blocks/" + block + ".png"); final IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); final IResource resource = resourceManager.getResource(resourceLocation); final InputStream in = resource.getInputStream(); final BufferedImage image = ImageIO.read(in); return image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth()); } catch (Exception e) { } return null; } My thought now is to cache all the block colors found in Minecraft, but what do I do about custom blocks added by a mod? Is it possible to iterate through the textures in their jar?
  12. I'm trying to understand how minimap mods actually work. I found the open source MapWriter and have browsed the source code for other popular minimaps, but what I can't seem to figure out is how they actually get the colors for the map. I've tried something like how the map item works (getting the color of the block I'm standing on and drawing a rectangle on screen with that integer), but nothing happened. Could someone explain this to me please? This is what I've got so far, and you can see where I'd like to add the minimap. The zone your in (top left) will change based on a text file stored locally or on the server. When your armor's durability is less than 75%, a manikin type thing will appear in the bottom right. [/img]
  13. Good news! I made it work, and it is working just like I imagined. Although, the player gets spammed constantly with "your game mode has been changed" because of the tick handler. Any ideas how I could make it silent? This is how I change the player's game mode. MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername("username").setGameType(EnumGameType.SURVIVAL)
  14. MinecraftServer.getServer() is the server, yes? How do you select a player? I was expecting a MinecraftServer.getServer().getPlayer(playerName) FOUND IT
  15. I knew I would have to do that soon. I was planning on getting an array of all the online players and sorting through them one by one. I have it set to every 20 ticks to get the player's coordinates and compare them with a polygon. If you're inside it, then set the game mode to X.
  16. I had it set to client. Whops! I want this to be multiplayer. I just tried this. this.mc.playerController.setGameType(EnumGameType.SURVIVAL); Is that what I'm looking for?
  17. I would have thought that this.mc.thePlayer.setGameType(EnumGameType.SURVIVAL); was the correct way to change a player's game mode, but that doesn't seem to work. How do you do this?
  18. I can't seem to figure out how to add mods like Industrial Craft into the Eclipse work space so that I can make "sub-mods". Can anyone help?
  19. So does this mean that pretty much every block that is intractable is a container? Containers don't have to literally contain something do they? They can store data like a sign right?
  20. So does this mean that pretty much every block that is intractable is a container? Containers don't have to literally contain something do they? They can store data like a sign right?
  21. What if I didn't want a container?
  22. What if I didn't want a container?
  23. I made a gui and it works, but I can only close it using the escape key. How can I set this to the 'E' key?
  24. I made a gui and it works, but I can only close it using the escape key. How can I set this to the 'E' key?
×
×
  • Create New...

Important Information

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