Jump to content

Cakestory

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by Cakestory

  1. Thank you very much for the detailed information, I´ll give it a try as soon as I have finished my exams for this semester.
  2. Hello, I have a few questions regarding Blockstates in 1.10.2. Currently I am creating a mod with logic gates (and, or, xor, ...) that look similar to the vanilla repeater and comperator. My AND-gate consists of 3 torches as input and an output line. The middle torch can be disabled to only enable 2 inputs. To render those I am currently using a vanilla style blockstate.json which looks like that http://pastebin.com/543BW21c and is really bad to read and difficult to write, and requires dozens of model.json files. I am pretty sure that my code is far from being good but this is the first time I am messing with blockstates and the reason I am here today. I am looking for a way to make a more readable and easier blockstate.json and if possible reduce the amount of models to as few as needed. Reading the forge tutorials on blockstates I thought about using submodels to achieve this or find a way to change the texture of a specific part of my model (model consists of parts: PANEL, TORCH_LEFT, TORCH_MIDDLE, TORCH_RIGHT). Sadly I could not find any tutorial on how to achieve this. My questions: 1. Should I use submodels for this or is there a way to set the texture of model parts from blockstate and completly disable those parts (example plz)? 2. If using submodels, is there a way to set the exact submodels location in the block (offset)? I would be really thankful for code snippets and examples. Greetings, Cakestory
  3. Hi, i am currently creating a broad axe for my mod. I am using my algorithm to get the log blocks of the tree the player tries to fell. This method stores all log coords in the axe´s nbt. Now I would like to change the time it takes to break the log that is currently being harvested depending on the size of the array in my items nbt. I already found the getDigSpeed() method can do this, but my problem is, that this method is fired/checked before my tree algorithm is called in onBlockStartBreak() . Is there a way to use this methods or other ways to change the time it takes to break the block depending on the size of the tree?
  4. Hi, i am working on a quiver for my mod that automatically picks up all arrows. I am using the ItemPickupEvent to pickup all arrows that are an EntityItem but I would like to have a way to detect and alter the pickup of EntityArrows that are stuck somewhere to also add these to my quiver automatically. Does anyone know an event or another way to detect EntityArrow PickUp that I could use?
  5. Thanks. I was using this before, but I derped something else. I forgot to do message.data and used this.data instead -> So it was always null. In other words I was reading the field of my class instead of reading the send data. Thank you for all the help guys. I marked this topic as solved.
  6. Thanks for the nice explanation jabelar. Haven´t found anything that informative (and easy to understand) yet. There is just one thing I need to know. I have a packet (message) on Side.Client and would need to get an instance of EntityPlayer in onMessage method. I used the version from pahimar´s EE3 and was able to use ctx.getServerHandler().playerEntity for my Side.SERVER messages. But this unfortinatly does not work for clients and ctx.getClientHandler() does not have a method to get the EntityPlayer. @Override public IMessage onMessage(SyncPlayerPropsPacket message, MessageContext ctx) { EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity(); // The class below implements IExtendeEntityProperties MinetweaksExtendedPlayer.get(player).loadNBTData(data); return null; }
  7. The example code from EE3 seems pretty simple. Thanks for the link jabelar. I will try to use this as soon as I have the time. I haven´t looked into netty yet, so I needed an easy tutorial. About the memory leak: There is just something I experienced in Minecraft 1.7.2 (not sure if this is not a problem in the Forge version). I have a modpack with about 20 mods. After some time the game uses much more memory and freezes when i switch to another window. When I read about the memory leak in the tutorial Packet Handling, which I guess tons of modders are using, I was wondering if this could be the problem. Any ideas on that?
  8. Hi, the current tutorial for the Netty Packet Handling on the Minecraft Forge Wiki is outdated and causes memory leak, as stated by cpw. http://www.minecraftforge.net/wiki/Netty_Packet_Handling I already used this tutorial and i would like to fix this. Is there any new tutorial on how to do it right? And do you know a good tutorial generally explaining the 1.7 Netty Packet System? If not, can someone please give (at least) an example code on how to do it, or do a tutorial on it? It also would be awesome if you could include how to send the packets. I heared something about extending SimpleChannelInboundHandler? EDIT: This is where I got a working example from. So you don´t have to read all posts in case you are just searching for the solution itself:
  9. That would be really helpful. I had a more detailed look at TinkersConstruct´s TabRegistry class and that is the code they use to add their Tab buttons to the inventory screen (called when the inventory key is used): public static void addTabsToInventory (GuiContainer gui) { if (gui.getClass() == GuiInventory.class) { // Values are public at runtime. int cornerX = gui.xSize; int cornerY = gui.guiTop; gui.buttonList.clear(); updateTabValues(cornerX, cornerY, InventoryTabVanilla.class); addTabsToList(gui.buttonList); } } public static void updateTabValues (int cornerX, int cornerY, Class<?> selectedButton) { int count = 2; for (int i = 0; i < tabList.size(); i++) { AbstractTab t = tabList.get(i); if (t.shouldAddToList()) { t.id = count; t.xPosition = cornerX + (count - 2) * 28; t.yPosition = cornerY - 28; t.enabled = !t.getClass().equals(selectedButton); count++; } } } public static void addTabsToList (List buttonList) { for (AbstractTab tab : tabList) { if (tab.shouldAddToList()) { buttonList.add(tab); } } } Here is the full class: https://github.com/SlimeKnights/TinkersConstruct/blob/master/src/main/java/tconstruct/client/tabs/TabRegistry.java As the comment says the values are all public at runtime. I must admit that I am just coding Java for a year now and have no direct idea on how this is handled at runtime, but as GuiInventory.xSize GuiInventory.ySize GuiInventory.guiTop GuiInventory.guiBottom GuiInventory.buttonList are not public fields there is no direct way to use them (without working around it). I would like to suggest making these fields "public" unless you see a problem in doing this. (I don´t know if there is a reason they are not public yet?)
  10. Awesome. Thanks for the fast reply diesieben07.
  11. Hi, mods like Tinkers Construct and Galacticraft add custom Inventory Tabs (like the ones in creative) to the players survival inventory. Making all these differnt mod tabs compatible with each other takes a lot of time for the mod authors or is not even possible if the one or more of the mods is not open source. If it is open source it takes a long time to look through the other modders code. It would be awesome if Forge could provide an easy way to add Tabs to the survival inventory in order to solve this problem. I solved the problem by using Java reflection, but it would be really useful if you could make GuiScreen.buttonList a public field.
  12. Hi, I have a custom dimension and provider for my mod and as this still seems to use numeric IDs, I´m wondering if this could cause incompatibility with other mods using the same dim and provider ID my mod is using? Or does Forge handle this on its own? And if so, can I fix this without forcing the user to set the ID in a config file?
  13. That was a perfect idea. It indeed was destroyed by the explosion. And telling me to use the onBlockExploded method was exactly the right thing. I just leave it empty. As the super method which sets the block to air, is overriden this way, the block is not destroyed anymore. Thank you coolAlias. Solution: @Override public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { // Do not call super.onBlockExploded(...) here! }
  14. I will try to figure it out, later this day, with the information you provided, but I´m having problems trying to understand how this algorith really works. Maybe I will find out when I have more time to look at it. Thanks for the hint.
  15. Hi, I have a block with the same resistance as bedrock that is explosion proof when placed in the world and trying to destroy it with tnt or creepers. This block is placed (with a TileEntity containing the players drops) when the player dies in PlayerDropsEvent with world.setBlock(x,y,z, block). It is working fine but when the player dies from an explosion by a creeper or tnt, the placed block seems to be destroyed by that explosion, also it is explosion resistant. Does anyone know how to fix this?
  16. Hi, I am creating a repair enchantment, that is running fine now, but i would like drain experience from the player whenever it repairs an item in his inventory. Of course i looked for the vanilla /xp command and how it is doing this, but the two methods I found ( player.addExperience(int amount) and player.addExperience(int amount), both working with negative parameters) do not work the way I want them to work. The addExperience() method just drains experience if the experience bar is at 0. But it does not decrease a level after the exp bar is empty but has levels remaining. E.g. I have 30 Levels and a half full exp bar. I run addExperience(-500) The bar shows 30 levels and no (green) exp in the bar, its empty but still says 30 levels What I expected: 29 levels and about 3/4 of the bar is full That was just an example, I don´t know the exact exp that would remain after drawing 500exp points. Does anyone know how to draw experience from the player, so it does decrease levels too?
  17. Thank you for your help. I was able to fix it and posted the solution on the first post in this thread as a pastebin link.
  18. I´m sorry that I cannot see it, but please tell me where I actually call the super.drawString? I cannot see me calling anything but super.drawScreen in the drawScreen(...) method of my GuiSreen class. Maybe I call it without actually noticing it but is it in the drawScreen() or in the drawHoveringText() method and which line?
  19. a) Sorry but could you give the concret code for my drawScreen()? I don´t know where and how I need to add this. EDIT: Oh, I see now. It must be called in the drawHoveringText() itself, but the question on where exactly and how remains. b) I am using the GuiScreen.drawHoveringText() directly from my GuiScreen extending class. Here is my whole class: http://pastebin.com/uFHZbhqB And here the vanilla drawHoweringText() from GuiScreen so you don´t have to look it up: http://pastebin.com/qbb0Eid5 I hope that is all the information you need.
  20. Thanks guys, it is working except for the lightning being strange. Do you know a way to fix it? Everything is getting darker when hovering a button. And the hover text is drawn behind (in the background of) the buttons. This is my drawScreen method (GuiButtonAdvanced extends GuiButton and has just a String "description" in its constructor): @Override public void drawScreen(int x, int y, float f) { this.drawDefaultBackground(); drawRect(width / 2 - 105, 60, width / 2 - 35, height / 2 + 5, new Color(50, 170, 170, 70).getRGB()); drawRect(width / 2 + 35, 60, width / 2 + 105, height / 2 + 30, new Color(85, 75, 170, 70).getRGB()); drawRect(width / 2 - 105, height / 2 + 10, width / 2 - 35, height / 2 + 105, new Color(170, 155, 75, 70).getRGB()); drawRect(width / 2 + 125, 60, width / 2 + 195, height / 2 + 30, new Color(185, 35, 50, 70).getRGB()); this.drawCenteredString(fontRendererObj, I18n.format("menu.title"), width / 2, 25, Color.WHITE.getRGB()); this.drawCenteredString(fontRendererObj, I18n.format("label.buff"), width / 2 - 70, 63, Color.WHITE.getRGB()); this.drawCenteredString(fontRendererObj, I18n.format("label.armor"), width / 2 + 71, 63, Color.WHITE.getRGB()); this.drawCenteredString(fontRendererObj, I18n.format("label.tool"), width / 2 + 161, 63, Color.WHITE.getRGB()); this.drawCenteredString(fontRendererObj, I18n.format("label.options"), width / 2 - 69, height / 2 + 15, Color.WHITE.getRGB()); for (int i = 0; i < buttonList.size(); i++) { if (buttonList.get(i) instanceof GuiButtonAdvanced) { GuiButtonAdvanced btn = (GuiButtonAdvanced) buttonList.get(i); if (btn.func_146115_a()) { String[] desc = { btn.description }; @SuppressWarnings("rawtypes") List temp = Arrays.asList(desc); drawHoveringText(temp, x, y, fontRendererObj); } } } super.drawScreen(x, y, f); }
  21. Hi, I would like to render a tooltip for the GuiButtons in my mod´s menu. Looking through the MinecraftForge forums I found that the MouseUpOrMoved() in my GuiScreen extending class could be used for that. But it does not react until I use a mouse button. My problem is: How do i check for the mouse hovering a GuiButton in Forge 1.7.2 (#1047)? That is the code I used, but it is not working except for when using a mouse button, but not hovering: @Override protected void mouseMovedOrUp(int mouseX, int mouseY, int mouseBtn) { if (mouseX >= 0 && mouseX <= 500 && mouseY >= 0 && mouseY <= 200) { System.out.println("Test"); } } EDIT: The problem was solved like this: http://pastebin.com/wJ1vBJXf Thanks to diesieben07 and sudwood for your help!
  22. Thank you for the fast help again, diesieben07.
  23. Hi, this should be really simple but i can´t figure out why my recipes do not ignore metadata or damage values. Here is my code called in PreInit: GameRegistry.addShapelessRecipe(new ItemStack(Items.string, 4), new ItemStack(Items.shears), new ItemStack(Blocks.wool)); Somehow it does not work with damaged shears or colored wool. Do i have to add something? The only tutorials i found on that told me it is ignoring meta and damage when setting the ItemStack like that.
  24. Found my failure in my custom teleporter class. I will use the vanilla one while i look for the specific line in the code causing it. It was just a quick copy of the Teleporter.java anyway. Thank you.
  25. @Chillbill It has 2GB. I´m sure that´s not the case @diesieben07 The failure seems to be somewhere in the onBlockActivated method in BlockPortalMinefields above. May you have a look at the class and tell me what could be wrong? I can´t see any problem of the ones you listed. Also it works fine when i comment this method out. It´s working too if i declare the method @SideOnly(Side.Server) but then crashes with a server tick loop error when loading a world.
×
×
  • Create New...

Important Information

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