Jump to content

Nauktis

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by Nauktis

  1. Hi, I have a question regarding Containers. Is there a new instance created on the server for each player using the GUI? I am a bit confused as a Container contains a list of players and a list of crafters. I am asking because I want to reduce the number of updates I send to the client by caching values in the Container (on the server) and only send information if something changed. But I don't know if there is a one to one relationship between Container instances and players having the GUI open. Thanks.
  2. Use gradle to fetch everything for you. Add this to your build.gradle (you need to change the versions as they come from a property file for me): dependencies { compile "codechicken:CodeChickenLib:${config.minecraft_version}-${config.codechickenlib_version}:dev" compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.codechickencore_version}:dev" compile "codechicken:ForgeMultipart:${config.minecraft_version}-${config.forgemultipart_version}:dev" compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.notenoughitems_version}:dev" }
  3. I found a quick and easy way to do it but I am very curious about the dev version of COFH. They provide so little information on their website for devs... Later I would also like to access the list of existing recipes (to implement my own pulverizer). So if you have information about that as well please post Here's my quick test code (working) try { Class klass = Class.forName("cofh.api.modhelpers.ThermalExpansionHelper"); Method method = klass.getMethod("addPulverizerRecipe", int.class, ItemStack.class, ItemStack.class); method.invoke(null, 150, new ItemStack(Items.apple), new ItemStack(Items.arrow)); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } You obviously want to handle the different catch clauses to account for the fact that the recipe was not added.
  4. Hi, I know someone probably asked before but I really could not find the information. I would like to add Thermal Expansion (pulverizer, induction smelter, etc.) recipes for my items. I know the COFH team provides a class ThermalExpansionHelper to do that but I have no idea how to get access to it in my dev environment. Also, I do not want to depend on any mod. If Thermal Expansion is available, I'll add my recipes but if it is not, my mod will just add classic recipes instead. Could you help me a bit or point me to the right direction? Thanks a lot. N.
  5. Alright, thought I would save some space if I managed to find the value without the need to save it in the NBT tag. I'm probably over-engineering the stuff again -.- Thanks for pointing it out
  6. Hi, I am having some issues with my design regarding the way TileEntities are created. As you know, there are basically two ways for a TileEntity to be created. - The Block creates it upon placement using createNewTileEntity(). There we have all the freedom to pass any information we want. - The TileEntity is created (using default constructor) when loading a game that had one already there. My problem is the following: My TileEntity needs some configuration values when it is created (lets say the size of its inventory). I previously stored this value in the NBT tag of the TileEntity and had no problem. But this value is actually configuration and never changes, so I though it is a bit silly that each TileEntity saves it. Before continuing I need to precise that I can not store that config value statically (MyModConfiguration.getConfigValue()) because my TileEntity is used by different blocks that each have a different config value. Lets say I have block1 that has an inventory size of 10 and block2 that has an inventory size of 20. The way to work around this is to ask the block of the TileEntity its config value (worldObj.getBlock(x,y,z).getConfigValue()). My problem is that when a TileEntity is loaded the readFromNBT is called immediately before anything else from the TileEntity is set (world object, position, etc.) My TileEntity is therefore trying to restore the inventory content while the inventory is not yet created because I can not access its size. Would you see a way to work around this? How do you typically handle loading of TileEntities? I hope my explanations are clear enough and thanks a lot beforehand.
  7. Haha! Good to know Works like a charm btw! Thanks a lot for your help
  8. Alright, I'll try it this way then. I didn't try before because the Javadoc is saying: /** * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. */ Any idea why "(ignoring stack size)"? It is usually used to limit the kind of item you can put in.
  9. Hi, I an trying to limit what can be inserted in an inventory. The kind of limitation I need is: "No more than 10 item Items.apple at any given time." "No more than 8 item Items.arrow at any given time." (all Items.apple do not need to be in the same slot) I am not looking for getInventoryStackLimit() as it will depend on the kind of item. I need the limitation to be applicable for GUI interactions but also machines inserting (hoppers and whatnot). I am currently using a IInventory as sides do not matter but it seems ISidedInventory allows for more control. Worst case scenario, I disallow interactions from machines and use the Slot to have more fine grained control. What do you think? Thanks a lot beforehand for your help
  10. Of course a little gradle clean solved it all. It was probably some leftovers from my different attempts. No more APIs in my jar \o/ Thanks again for taking the time to help me
  11. Well in my case they are in the jar. Doesn't this line tell Gradle to take everything in src/ http://s1.postimg.org/5dusjjl2n/1_src.png[/img] This is the content of my Jar, in my case the cofh api is there. http://s1.postimg.org/gepxokdbj/2_jar.png[/img] And here is the structure of my mod, exactly like you said: Thanks again.
  12. Hi, I've learned a mod isn't supposed to ship the API in its jar file (which of course makes sense). My problem is that by default (unless I missed something), the build.gradle takes everything in src/ How should I configure the build to exclude the api files from the jar? Thanks a lot for your help.
  13. For people finding this topic through Google or Search (like me) Here's the correct settings for the Artifact like TheGreyGhost proposed.
  14. Oh ok, it is that simple I thought the result of this method was only accurate in post-init! Thanks a lot for your help.
  15. Hi, I would like to register different recipes for my items/blocks depending on what mods the user has installed. Simple example, I would have recipes with only vanilla items if the user has nothing but my mod. And I would have recipes that uses items from Thermal Expansion, if they are available. The problem I'm facing is how do I know if Thermal Expansion is installed? Recipes should be registered during the init event. And I'm correct, it is only in the post-init that you can ask if a Mod has been loaded (by its ID) Thanks in advance for your help N.
  16. Thanks for your help. I added -Dfml.coreMods.load=codechicken.core.launch.CodeChickenCorePlugin,codechicken.nei.asm.NEICorePlugin Seems to go a bit further but now it crashes when starting:
  17. Hi, I want to add Waila support to my mod. I followed the procedure ProfMobius highlighted on his website, adding the following to the gradle build file. repositories { maven { name "Mobius Repo" url "http://mobiusstrip.eu/maven" } maven { name 'CB Repo' url "http://chickenbones.net/maven/" } } dependencies { // I dont have to specify NEI.. because gradle magic. aka: transitive dependency resolution compile "mcp.mobius.waila:Waila:1.5.3_1.7.10" } Then a small: gradle clean setupDecompWorkspace eclipse --refresh-dependencies Jar files are there in my Eclipse and I start wrtiting my add-on. The problem I have is that when I start Minecraft from Eclipse, Forge complains that a requirement is not there: NEI Could someone help me? Thanks a lot.
  18. Hi, It is in the updateEntity of the TileEntity that you need to update the energy not in the updateTick of the Block. TileEntity.updateEntity is called every tick while Block.updateTick is randomly called now and then.
  19. Look at Minecraft code that does something close to what you want to achieve. You will often be able to subclass an existing class this way. Otherwise look at the source code of Mods that do something similar. That's how I proceed
  20. I think your problem is the exact same as the one I had, http://www.minecraftforge.net/forum/index.php/topic,22490.0.html (solved in my topic)
  21. Thanks a lot for your help, you really made my day When the server loads the tile entity from NBT it now sends a Packet to my Client who in turn updates its tile entity state. When printing to the chat the values are stil a bit different though but I guess its because the value changes on the server before the client receives the packet. Another problem I have which is very much related is that the daytime seems desynchronized between the Client and the server I use the isDaytime() method on the World object that I receive in the onBlockActivated method of my block: if (pWorld.isRemote) { pPlayer.addChatMessage(new ChatComponentText("Remote isDaytime: " + pWorld.isDaytime())); } else { pPlayer.addChatMessage(new ChatComponentText("NotRemote isDaytime: " + pWorld.isDaytime())); } Which produces: Am I missing something ? isRemote == true is the server and isRemote == false is the Client right? If I understand correctly, the full logic is executed on both the Client and the Server and some things are synced from now and then. My tile entity checks if it is daytime to produce energy and a different behaviour between Client and Server is a big issue for me Again, all my code can be found on GitHub: https://github.com/Nauktis/SolarFlux
  22. Hi, It seems that my tile entity for a block is desynchronized between the server and the client. I noticed it after creating a GUI for my block. The idea is really simple, the tile entity has an amount of energy stored. When loading a game with a block already in it, it seems that the Server is re-creating the tile entity using the readNBT method and therefor gets the proper value for the energy stored but on the Client side, the createNewTileEntity method is called and a new tile entity with no energy in it is created. Here is a link to my GitHub. The Block: https://github.com/Nauktis/SolarFlux/blob/master/src/main/java/com/nauktis/solarflux/blocks/SolarPanelBlock.java The Tile Entity: https://github.com/Nauktis/SolarFlux/blob/master/src/main/java/com/nauktis/solarflux/blocks/SolarPanelTileEntity.java Here is how I know the tile entities are desynchronized SolarPanelTileEntity tile = (SolarPanelTileEntity) pWorld.getTileEntity(pX, pY, pZ); if (pWorld.isRemote) { pPlayer.addChatMessage(new ChatComponentText("Remote: " + tile.getEnergyStored())); } else { pPlayer.addChatMessage(new ChatComponentText("NotRemote: " + tile.getEnergyStored())); } Here is the result: This of course only occurs when loading a game with blocks already placed. Your help will be greatly appreciated N.
  23. Hi, I created a mod that contains some base and utility classes. I'd like to reuse those in a second mod. Can I simply include the classes in my second mod or am I gonna run into class loading issues? What is the way to go? Do I need to create a separate jar file with those classes (without any @Mod annotated class) and use it as a library for my mods? How to proceed with ForgeGradle? Thanks a lot for your help.
×
×
  • Create New...

Important Information

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