Jump to content

Lycanus Darkbinder

Members
  • Posts

    118
  • Joined

  • Last visited

Posts posted by Lycanus Darkbinder

  1. Hmm, looks like I might have asked too soon. After reviewing GuiSlider.java a bit more, it appears this is handled within the mouseDragged() method which needs to be overridden:

     

                    if (this.sliderValue < 0.0F)
                    {
                        this.sliderValue = 0.0F;
                    }
    
                    if (this.sliderValue > 1.0F)
                    {
                        this.sliderValue = 1.0F;
                    }
    

     

    I've been spoiled by developing in languages where the control managed these bounds that I forgot to look in the "drag handler" before posting.

     

  2. I've been working on my block's GUI and decided using a slider in place of a text input field would be more user friendly. Trouble is, the slider doesn't seem to be developer friendly.

     

    I haven't been able to find a method that sets the min / max value of the slider. I only want it to go from 0 to 15 but the constructor only asks for a "value". There is a method to set / get the value but nothing to limit the min / max, that I could find.

     

    Any advice?

     

    Thanks!

     

  3. Since this isn't a coding question I thought it would do better inGeneral:

     

    Are there any "best practices" when designing a GUI?

     

    I spent some time learning how to program a GUI but it looks bad. In other languages I've been spoiled with a "form designer" that lets you simply add the controls you need from a "toolbox" and then write the code underneath.

     

    In Minecraft, I seem to have the most trouble positioning the controls on the screen. My GUI isn't really complex but it's got enough to be annoying:

     

    • 3 Input fields (text)
    • 3 Labels (next to each text box)
    • 1 Yes / No
    • 2 Buttons

    When you design a GUI, what workflow do you use? Do you use something like Photoshop to draw a background with cutouts for each control? Do you "bake" the text onto a background (ie: text tool in Photoshop) rather than use font rendering in the game? Do you just render rectangles in Minecraft and skip the background completely?

     

    I'm just gathering information as to what would be the easisest way to position the controls properly while leaving room for modifications in the future.

     

     

    Thanks!

     

  4. So I guess it's settled then as is the question of GUI tutorials ? :D

     

    Well not really. I still haven't found a GUI tutorial that deals with a simple GUI that itsn't a container. Basically all I want to have is a textbox where the player enters a number and a checkbox. These values get written to the TileEntity as "lightValue" and "isLit", respectively.

     

    So far the tutorials I've seen extend GuiContainer. I'm pretty sure I all I need is GuiScreen but still looking into it.

     

    PS:

     

    Not to beat a dead horse but I posted a definition of deprecated so I don't see how you could say it lacked actual definition. So far it seems nobody subscribes to that definition: the method of coding with proxies has been superceded by the method of coding without them. That is a valid application of the word deprecated.

     

    Even the 1.5.2 examples in the wiki don't use them anymore.

  5. Proxies are helper classes, they were never compulsory. Thus can't be deprecated unless Mojang provides a better system.

     

    I guess it's a matter of opinion then. When most of the earlier 1.3.x and 1.4.x tutorials go through great lengths explaining proxies and how to set them up, it feels a bit compulsory. None that I saw in that generation ever said "don't bother with proxies, they're not necessary".

     

    Naturally when several 1.5.x tutorials arrive and tell you not to bother with proxies, it feels a bit deprecated, as in "not necessary".

  6. Hehe well interface has more than one meaning ;)

     

    Anyways enjoy those courses and uhm ClientProxy and CommonProxy can't be depracted, CommonProxy extends nothing and therefore it's impossible for it to be depracted as it's a self made class ;)

     

    I can also assure you that they work in 1.6.X just like they did in 1.5 and 1.4 :)

     

    Deprecated has nothing to do with it extending anything or being a "self made class", it simply means it's been superceded or replaced. The process of using CommonProxy has been superceded by the process of not using CommonProxy.

     

    Deprecation is a status applied to a computer software feature, characteristic, or practice indicating it should be avoided, typically because of it being superseded

     

    As I linked a few posts above, Wuppy explains in a 1.5.1 video that they're not necessary. I don't use them and haven't run into any issues with my 1.5.2 mod.

  7. Courses.vswe.se has courses which deals with intermediate and advance GUI's which deals with a lot of different inputs in the GUI which in turn is saved in the TE on the server side :)

     

    Thanks, I'll check it out. I posted his Minecraft series on the wiki but it didn't include GUIs. On his YouTube channel I saw the "Climbing the Interface Ladder" playlist but didn't bother clicking on it because there was no description and I thought it was about implementing interfaces in Java.

  8. You have GOT to be joking... Since when did CommonProxy / ClientProxy become depracted?!?!?!?!?!!?!?!?!?

     

    I don' t know when exactly but every tutorial I watched for 1.5.2 and 1.6.2 says you no longer need to muck around with the CommonProxy crap. My SmartLights mod works just fine without it anyway.

     

    Edit: In

    for 1.5.1, Wuppy explains (at around 25 seconds) that you don't need CommonProxy anymore.

     

    I believe you MAY have read my tutorial.. Probably not though. I don't get into any of the interesting GUI stuff, but it gets a basic GUI working.

     

    I can give you some pointers if you want, just PM me or ask via this thread. ( I can't be bothered to type it all out if you don't want it xD )

     

    Can you link to your tutorial? I'm not sure if it is one that I found or not.

  9. Greetings,

     

    I'm looking to create a GUI that allows users to make changes to the block's TileEntity data. For example, the user right-clicks my block and the GUI provides them a text field for entering a number and a check box to simulate a boolean. When they close the GUI these values get written to the block's TileEntity.

     

    Unfortunately the only GUI tutorials I've found (on the wiki and minecraft forums) are either too old and use the deprecated "CommonProxy" and / or they demonstrate a GUI container such as an extended chest.

     

    Are there any tutorials out there that pertain to a GUI interface that allows users to enter data? Right now my block is fully functional but I wanted to give the user access to change some fields without having to exit the game and modify the config file.

     

    Thanks

     

    PS:

     

    All I really need is something to point me in the direction of setting up the GUI for input. I can figure out the TileEntity portion on my own, I think.

  10. I was thinking about List, Map, Arrays or other data structure rather than a simple int.

     

    Oh, I don't store anything that complex.

     

    I only track the owner of the block (string) so not just anyone can fiddle with it as well as a few integers and floats. That's why I was surprised when it crashed after making a change.

     

    More than likely I did something I shouldn't but I'll have to wait until next time because once I remade the world it stopped crashing. I'm certain it had to do with my TileEntity though because the offending class is the only one that makes use of it.

  11. Well, it is likely that you tried to use or load data that didn't exist the first time you placed the block and saved it.

    You would need to catch those cases and save some default value.

     

    NBT returns zero on an attempt to retrieve a value for a key that has not been saved. None of the fields in my TileEntity would cause a crash with a value of zero. Worst case is the block would display the wrong texture or light value, or allow someone who is not the block's owner to interact with it.

  12. I don't have a crash log at the moment but if I get another I'll definitely post it.

     

    I'm not using ASM but there are TileEntities involved. What I did was place a block to see if the TileEntity's fields were set properly, then I quit the game and added a couple new methods to the block's class file and I think one new method to the TileEntity.

     

    When I started the world again it crashed instantly with that "error ticking block". I had to delete the world and recreate it.

     

    I was under the impression that the TileEntity would still function because Minecraft doesn't save the actual TileEntity but rather it's fields. When you load your world it calls createNewTileEntity which returns a blank TileEntity that is then populated from readNBT(). This should allow you to add new features without breaking existing worlds.

  13. I noticed while debugging and testing that if you add methods to a block's class and then load a world where blocks have already been placed, it will crash:

     

    "error while ticking block"

     

    I'm not talking about changing block IDs or anything crazy like that, simply adding a few new methods (no, not removing methods). How does one go about updating their mod or adding new features after it's been released to the public without breaking the worlds people have built?

     

    I can't put my finger on it yet but sometimes I have to delete my test world or it simply crashes over and over after making changes. I assumed that as long as you weren't deleting methods then it would be fine.

  14. I have overridden getBlockColor like this:

     public int getBlockColor()
           {
           if(blockToCopy != null) {
                return blockToCopy.getBlockColor();
           }
                   return 16777215;
           }
    

    Where blockToCopy is the block whose texture I'm using.

    Also: Leaves do the same thing as grass.  Plus it makes Ice opaque and some blocks (tall grass) use the wrong render type.

     

    Did you override or edit the function directly? You shouldn't see any changes to default blocks if you put it in your block class file with the @Override annotation.

  15. This works for the textures but the colors dont show up (grass is gray).  I think I need to override the getRenderColor method in Block

     

    Grass has its own functions for determining color:

     

    BlockGrass.java

        public int getBlockColor()
        {
            double d0 = 0.5D;
            double d1 = 1.0D;
            return ColorizerGrass.getGrassColor(d0, d1);
        }
    

     

    ColorizerGrass.java

        /**
         * Gets grass color from temperature and humidity. Args: temperature, humidity
         */
        public static int getGrassColor(double par0, double par2)
        {
            par2 *= par0;
            int i = (int)((1.0D - par0) * 255.0D);
            int j = (int)((1.0D - par2) * 255.0D);
            return grassBuffer[j << 8 | i];
        }
    

     

    Try implementing those in your block. If you can get the temp and humidity you should be able to mimic the grass color.

     

    Hint:

     

    BiomeGenBase.java

            double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
            double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
    

  16. Well, you could make an educated guess using player statistics.

     

    Chances are if these statistics or a combination of them are zero, they've not logged in before:

     

    Times played - The number of times Minecraft has been loaded

    Multiplayer joins - The number of times a multiplayer server was successfully joined

    Minutes Played - The total amount of time played

    Distance Walked - The total distance walked

     

    Granted, these stats are tracked across all worlds so you would need to create some sort of weighted result if any of them are not zero. If you decide to consider them a "first timer" then you could place some sort of "cookie" for the next time.

  17. Already figured out  8) I did smth like this : got world obj , got all tiles in that world obj , listed through to my one (instance) than

    checked for enique endentifier (that i had set before) if equals == happiness  ;D

     

    Do you realize the performance hit this will cause on a heavy population server? The amount of TileEntities that can exist in a single world are enormous.

     

    You might want to limit the search to the chunk the player is in but even that has the potential to be a lot of TileEntities.

  18. Try using config.get() instead of config.getBlock or config.getItem:

     

    myBlockID = config.get(config.CATEGORY_BLOCK, "myBlockID", 1000).getInt();
    

     

    The methods you're using are expecting a String comment parameter that you're not passing which might be problematic.

     

        public Property getItem(String category, String key, int defaultID, String comment)
        {
            Property prop = get(category, key, -1, comment);
    

  19. As mentioned above, it's much simpler to use an array. The way I handle it is to use the mod name as part of the registration process:

     

    // Define the names for our metadata. Remember, each item is limited to 16 meta blocks
    
    private static final String[] metaBlockNames = {
      "First Block", "Second Block", "Third Block", "Fourth Block"
    };
    
    private static final String modName = "MyMod";
    public static Block myBlock;
    private static int blockID;  // this gets read in from the config
    
    public void modLoad(FMLInitializationEvent event)
    {
        // Create an instance of our block and register it
    
        myBlock = new BlockMyBlock(blockID).setUnlocalizedName("myblockBlock");
        GameRegistry.registerBlock(myBlock, ItemBlockMyBlock.class, myBlock.getUnlocalizedName2());
    
        // Register the different meta blocks
    
        for (int a = 0; a < metaBlockNames.length; x++)
        {
            LanguageRegistry.addName(new ItemStack(myBlock, 1, a), modName + metaBlockNames[a]);
        }
    
    }
    
    protected String getModName()
    {
        // Provides access to the mod name for use in sub classes such 
        // such as BlockMyBlock for regestering Icons
    
        return modName;
    }
    

  20. Heh, yeah I know. I was just trying to figure a way around sending so many packets, but I guess there's no help for it in this situation.

    "So many packets"? As in one packet per keypress? What is wrong with that?

     

    In regards to this, in the Minecraft I use to play (not develop) which has around 45 mods in it including heavy hitters such as Mo'Creatures, I often see something such as this:

     

    "Memory connection overburdened after processing packets with 2500 still to go"

     

    Isn't this an artifact of modders spamming too many packets as coolAlias was indicating?

     

     

    Note: I'm not blaming Mo'Creatures, just illustrating that the mods I use don't just add a block.

×
×
  • Create New...

Important Information

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