Jump to content

Kinniken

Members
  • Posts

    266
  • Joined

  • Last visited

Everything posted by Kinniken

  1. I realise I'm not supposed to do this, but as a debugging tool for SP-only usage it worked fine in 1.7. I'm just wondering if anybody can confirm that yes, you can no longer access chunks for other threads than the main one in 1.12. The Client-Server thing is not the real issue there, I assume I'd have the same problems if I was running that code in a thread split from the main server thread. After that I could of course fix it by using packets, it's just a lot more work for a very side feature. And those static references are because my mod requires a large amount of world-specific data that can't be accessed via Minecraft means like DimensionManager.
  2. Hi all, I have a GUI in my mod that displays a map of nearby chunks with their load status and whether or not they are "force loaded" by my mod. In 1.7, it worked fine, in 1.12, it occasionally crashes with this error: net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:835) (Sorry, I don't have the full stack trace on hand, I'll add it when I can) This error actually happens in the main thread, not my GUI code, and I've had it before when doing actions in other threads that are not thread-safe. The code I'm running in my GUI is this: private void drawChunkMap(final int i, final int j) { if (Mill.serverWorlds.isEmpty()) { return; } final int windowXstart = (width - getXSize()) / 2; final int windowYstart = (height - getYSize()) / 2; final World world = Mill.serverWorlds.get(0).world; final MillWorld mw = Mill.serverWorlds.get(0); GL11.glDisable(2896 /* GL_LIGHTING */); GL11.glDisable(2929 /* GL_DEPTH_TEST */); final int startX = (getXSize() - (chunkMapSizeInBlocks / 8)) / 2; final int startY = (getYSize() - (chunkMapSizeInBlocks / 8)) / 2; final int posXstart = (player.chunkCoordX * 16) - (chunkMapSizeInBlocks / 2); final int posZstart = (player.chunkCoordZ * 16) - (chunkMapSizeInBlocks / 2); final int mouseX = (((i - startX - windowXstart) / 2) * 16) + posXstart; final int mouseZ = (((j - startY - windowYstart) / 2) * 16) + posZstart; drawGradientRect(startX - 2, startY - 2, startX + (chunkMapSizeInBlocks / 8) + 2, startY + (chunkMapSizeInBlocks / 8) + 2, 0x20000000, 0x20000000); final ArrayList<String> labels = new ArrayList<String>(); for (int x = posXstart; x < (posXstart + chunkMapSizeInBlocks); x += 16) { for (int z = posZstart; z < (posZstart + chunkMapSizeInBlocks); z += 16) { int colour = 0; if (!world.isChunkGeneratedAt(x / 16, z / 16)) { colour = 0x40111111; } else { final Chunk chunk = world.getChunkProvider().provideChunk(x / 16, z / 16); if (chunk.isLoaded()) { colour = 0xc000ff00; } else { colour = 0xc0ff0000; } drawPixel(startX + ((x - posXstart) / 8), startY + ((z - posZstart) / 8), colour); if ((mouseX == x) && (mouseZ == z)) { labels.add(MLN.string("chunk.chunkcoords", "" + (x / 16) + "/" + (z / 16))); } } } } // copy to avoid ConcurrentModificationException final ArrayList<Building> buildings = new ArrayList<Building>(mw.allBuildings()); for (final Building b : buildings) { if (b.isTownhall && (b.winfo != null) && (b.villageType != null)) { for (int x = b.winfo.mapStartX; x < (b.winfo.mapStartX + b.winfo.length); x += 16) { for (int z = b.winfo.mapStartZ; z < (b.winfo.mapStartZ + b.winfo.width); z += 16) { if ((x >= posXstart) && (x <= (posXstart + chunkMapSizeInBlocks)) && (z >= posZstart) && (z <= (posZstart + chunkMapSizeInBlocks))) { int colour; if (b.villageType.lonebuilding) { colour = 0xf0990099; } else { colour = 0xf00000ff; } drawPixel(startX + ((x - posXstart) / 8) + 1, startY + ((z - posZstart) / 8) + 1, colour); if ((mouseX == x) && (mouseZ == z)) { labels.add(MLN.string("chunk.village", b.getVillageQualifiedName())); } } } } } } boolean labelForced = false; for (final ChunkPos cc : ForgeChunkManager.getPersistentChunksFor(world).keys()) { if (((cc.x * 16) >= posXstart) && ((cc.x * 16) <= (posXstart + chunkMapSizeInBlocks)) && ((cc.z * 16) >= posZstart) && ((cc.z * 16) <= (posZstart + chunkMapSizeInBlocks))) { drawPixel(startX + (((cc.x * 16) - posXstart) / 8), startY + (((cc.z * 16) - posZstart) / 8) + 1, 0xf0ffffff); if ((mouseX == (cc.x * 16)) && (mouseZ == (cc.z * 16)) && !labelForced) { labels.add(MLN.string("chunk.chunkforced")); labelForced = true; } } } if (!labels.isEmpty()) { int stringlength = 0; for (final String s : labels) { final int w = fontRenderer.getStringWidth(s); if (w > stringlength) { stringlength = w; } } drawGradientRect((i - 3 - windowXstart) + 10, j - 3 - windowYstart, ((i + stringlength + 3) - windowXstart) + 10, (j + (11 * labels.size())) - windowYstart, 0xc0000000, 0xc0000000); for (int si = 0; si < labels.size(); si++) { fontRenderer.drawString(labels.get(si), (i - windowXstart) + 10, (j - windowYstart) + (11 * si), 0x909090); } } GL11.glEnable(2896 /* GL_LIGHTING */); GL11.glEnable(2929 /* GL_DEPTH_TEST */); } Can anybody confirm that it is my calls to the chunk provider that are forbidden from a GUI? And if that's the case, is there a recommanded way of dealing with this? I could have the data be pre-calculated in the main thread, but it would be an ugly hack... Thanks
  3. Hi all, I have a GUI whose displayed information depends on the content of various chests (a trading screen, where the supply of goods comes from N chests in a building). I'm having issues in 1.12 I did not have in 1.7 where actions taken by the player (buying/selling goods) don't seem to be applied client-side immediately in the building's chest, only in his inventory. For example, if he buys a stack of stone, it will immediately appear in his inventory, but it won't disappear immediately in the building's chests, so it might show in my GUI as still available even though the stock is gone. I'd happily post code but the full setup covers multiple complicated classes. Is there any particular way to force Minecraft to immediately update a tile entity's data on a given client? BTW, all this happens in SSP, not just MP. Thanks
  4. Ok, solved it, it was mostly faulty debugging on my side. With this in the entity class: public boolean canDespawn() { return false; } It seems to be working fine.
  5. I know the theory of it, I've been battling with it since Minecraft 1.4 And yes this means Millénaire is a very CPU-demanding mod, especially if you set it up with a large activity radius. Still, it's a worthwhile compromise for many players, and in fact one of the most requested feature ever is a way to keep villages running permanently even if the player is really far away (on the converse, you can also set it up so that only villages within say 100 meters are active). I'll check that enable persistence feature but if it's about persisting entities when a chunk is reloaded I already have that. That tracking range might be more what I'm looking for, thanks.
  6. Hi guys, My mod (Millénaire, for those who remember) depends heavily on keeping mobs active far away from the player (on loaded chunks of course). In 1.12 I'm having difficulties with this, Minecraft tends to freeze or even despawn my villagers when the player is 100 meters away or so, and if the player loads the game with villagers beyond that range they don't respawn even if the chunk is active. Is there any way to force this? Thanks K.
  7. Hi guys, In Minecraft 1.7 I had mobs that would wear clothes, that were separate textures applied on top of the main one at rendering time with this code: @Override protected int shouldRenderPass(final EntityLivingBase entityliving, final int i, final float f) { final int armourRes = this.shouldRenderPass((EntityLiving) entityliving, i, f); int clothRes = -1; if (i == 0) { clothRes = setClothModel((MillVillager) entityliving, i, f); } if (armourRes > 0) { return armourRes; } return clothRes; } Basically, a separate model from the main one, just slightly bigger. In 1.12 I can't figure out how to do something similar. BTW, I can't use layers in the JSON because I don't know in advance (when my mod is built) what clothes will be available. Thanks!
  8. Hi guys, I have a block that extends BlockWallSign, and I want it to render the exact same way. It works fine. However, I get this in my logs at startup: [10:47:36] [main/ERROR] [FML/]: Exception loading model for variant millenaire:panel#facing=east for blockstate "millenaire:panel[facing=east]" net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model millenaire:panel#facing=east with loader VariantLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:233) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:221) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:159) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?] at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1169) ~[ModelLoader$VariantLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?] ... 21 more The Minecraft block doesn't seem to have a model, it doesn't need one since the rendering is handled by the entity. Why does forge attempt to load one for mine? Can I stop that behaviour? Thanks!
  9. Hi Lex, Thanks for the post and all the good work on Forge. I'm glad to hear that you're carrying in! I'm not too keen either on the direction the Minecraft world is taking, but it's not a reason to give up. All the best K.
  10. Ok, forget it. I knew it was stupid, just not that stupid. Turns out that in my refactoring I had deleted the registration of the block. Weird that it doesn't throw an error though.
  11. Thanks, I'll check it out. You really should add @Override to your methods though, you'll cry if you don't next time MC gets updated This method makes me think I won't be able to keep my current setup of multiple crops per block though: protected Item func_149866_i() { return Items.wheat_seeds; } Ah well, I guess there's no point anymore anyway.
  12. Hi guys, In 1.6 I used to add colours to my chat texts by adding a "\247" followed by a colour code. This enabled colouring bits of texts (i.e. a word or two in a line). In 1.7 it still works, except that I can't find a way to get the colour to continue on the next line. This is my code: ChatComponentText cc=new ChatComponentText(s); Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(cc); If I have a code switching the text to say blue on line one, it will work, but line two will revert to white. I can do multi-line colouring, but with getChatStyle().setColor(colour), and that only works to colour the entire text as far as I can tell. Anybody has some sample code of a way to do this? Thanks K.
  13. Hi guys, Is there any info anywhere on custom crops in MC 1.7.2? I'm having trouble with mines. There's a new IPlantable interface implemented by BlockBush, is there a way to add my plant types to it? Thanks K.
  14. Yep. And if I ever come back to this forum in a few weeks complaining that the code above doesn't work properly, feel free to remind me of this thread
  15. I don't doubt I could do things more cleanly, but I have a hell of a lot of more urgent points to work on if I ever want to get a working release of Millénaire for 1.7 out
  16. For a collection with an expected size of 1, the actual difference isn't going to be very significant... After that, I suppose it depends how often you can that method. If it's every tick then you need to be careful. If it's once in very specific circumstances then I'm skeptical the difference will amount to anything.
  17. In case anyone else needs it: This assumes the modifier will be in the first entry in the set and seems to work fine with the vanilla Minecraft weapons. No idea whether there are cases where this won't be true.
  18. Thanks, will check with him what he used.
  19. With the correct criteria. Thanks, though.
  20. Cool! In which version if Forge was it released, do you know? I had a user reporting that issue with the latest Forge.
  21. Hi guys, It seems stupid, but I haven't managed to get the damage from an Item (like ItemSword or ItemTool). Here was my attempt: public static double getItemWeaponDamage(Item item) { Multimap multimap = item.getItemAttributeModifiers(); if (multimap.containsKey(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName())) { if (multimap.get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()) instanceof AttributeModifier) { AttributeModifier weaponModifier=(AttributeModifier) multimap.get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()); return weaponModifier.getAmount(); } } return 0; } However multimap.get doesn't return an AttributeModifier but an class com.google.common.collect.AbstractMapBasedMultimap$WrappedSet. Anyone knows how this works? Thanks K.
  22. Hi guys, I'm having issues with some of my packets causing disconnections because they are over 32k (for those who know my mod, in particular the village map if village radiuses are high). Anyone know of ways to tackle that? I'm thinking along those lines: - Compressing the streams, for instance with GZIPOutpustream. Not sure how to deal with the new ByteBufOutputStream however, they do not look compatible. - Bumping the 32k limit, if this is possible for a mod to do - Of course, splitting the info over multiple packets would work, but that's a lot of work if I want to do it for the various packet types where it can happen Before I reinvent the wheel yet again, has anybody successfully done this already? Thanks K.
  23. Hi, When running my mod in dev (via Eclipse), all my textures show up fine in-game, whether for items, blocks, GUIs or entities. When running my mod packaged with regular Minecraft however GUIs and entities have missing textures (items and blocks still work fine). All my textures are within the new src/main/resources directory (in sub-directories inside assets actually) and they get exported to the jar fine as far as I can tell. For example, here is a texture I declare in one of my GUIs: ResourceLocation background=new ResourceLocation(Mill.modId,"/textures/gui/ML_trade.png"); Where "Mill.modId" is "millenaire". In the exported jar that file exists at the following location: assets/millenaire/textures/gui/ML_trade.png Which seems correct to me. Any ideas? Thanks. K.
  24. I saw that tutorial, it looks need but would require a lot of refactoring to adapt my mod to it. In any case, I found the issue, and it was really stupid - I had misconfigured my handlers and the packet I was receiving was a server-side packet. Bad luck for me, the content was almost the same as the client packet I was expecting which got me on a completely wrong track. Anyway, onward to the next bug
×
×
  • Create New...

Important Information

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