Thread: Blast Furnace

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 Blast Furnace 
    Registered Member

    Join Date
    Jan 2011
    Posts
    1,945
    Thanks given
    1,215
    Thanks received
    548
    Rep Power
    607
    not worth using
    Reply With Quote  
     

  2. #2  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Eh, could use a lot of improvement. Missing a ton of detail (Objects breaking, pressure gauge (interface), actions (shoveling coal, pedalling), actual ores movement on the conveyor belt, overheating and whatnot). Some parts could also be improved upon instead of writing the same thing over and over with a couple changed numbers.

    PS: Naming conventions.

    Thank you for contributing regardless.
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Jan 2011
    Posts
    1,945
    Thanks given
    1,215
    Thanks received
    548
    Rep Power
    607
    Quote Originally Posted by Kris View Post
    Eh, could use a lot of improvement. Missing a ton of detail (Objects breaking, pressure gauge (interface), actions (shoveling coal, pedalling), actual ores movement on the conveyor belt, overheating and whatnot). Some parts could also be improved upon instead of writing the same thing over and over with a couple changed numbers.

    PS: Naming conventions.

    Thank you for contributing regardless.
    Yeah, don't know how all of Blast Furnace works in the first place. This just allows depositing ore and retrieving them as bars.
    Reply With Quote  
     

  4. #4  
    Registered Member Serp Helm's Avatar
    Join Date
    May 2017
    Posts
    93
    Thanks given
    34
    Thanks received
    28
    Rep Power
    0
    Pretty good for someone to work on! Great work dude.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    978
    Thanks given
    684
    Thanks received
    449
    Rep Power
    672
    A few improvements:

    If you're not going to extend upon a class (which in this case you're not), declare it "public final class BlastFurnace"

    Code:
    public static final int[] ores = { 436, 438, 440, 453, 444, 442, 447, 449, 451 };
    This should probably be private static final int[] ORES instead.

    Code:
    oreDeposit.remove((Integer)number);
    I don't see why casting to an Integer here is necessary.

    Code:
        public void CreateBar() {
            // Runite
            while (oreDeposit.contains(451) && removeSpecifiedAmount(453, 4, oreDeposit) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 12));
                oreDeposit.remove(new Integer(451));
                player.getInventory().addItem(new Item(2363, 1));
                player.getSkill().addExp(Skill.SMITHING, 50);
            }
            //Adamantite
            while (oreDeposit.contains(449) && removeSpecifiedAmount(453, 3, oreDeposit) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 8));
                oreDeposit.remove(new Integer(449));
                player.getInventory().addItem(new Item(2361, 1));
                player.getSkill().addExp(Skill.SMITHING, 38);
            }
            //Mithril
            while (oreDeposit.contains(447) && removeSpecifiedAmount(453, 2, oreDeposit) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 5));
                oreDeposit.remove(new Integer(447));
                player.getInventory().addItem(new Item(2359, 1));
                player.getSkill().addExp(Skill.SMITHING, 30);
            }
            //Steel
            while (oreDeposit.contains(440) && oreDeposit.contains(453) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 4));
                oreDeposit.remove(new Integer(440));
                oreDeposit.remove(new Integer(453));
                player.getInventory().addItem(new Item(2353, 1));
                player.getSkill().addExp(Skill.SMITHING, 18);
            }
            //Iron
            while (oreDeposit.contains(440) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 2));
                oreDeposit.remove(new Integer(440));
                player.getInventory().addItem(new Item(2351, 1));
                player.getSkill().addExp(Skill.SMITHING, 13);
            }
            //Copper
            while (oreDeposit.contains(436) && oreDeposit.contains(438) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 1));
                oreDeposit.remove(new Integer(436));
                oreDeposit.remove(new Integer(438));
                player.getInventory().addItem(new Item(2349, 1));
                player.getSkill().addExp(Skill.SMITHING, 6);
            }
            //Gold
            while (oreDeposit.contains(444) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 3));
                oreDeposit.remove(new Integer(444));
                player.getInventory().addItem(new Item(2357, 1));
                player.getSkill().addExp(Skill.SMITHING, 23);
            }
            //Silver
            while (oreDeposit.contains(442) && player.getInventory().getItemContainer().freeSlots() > 0) {
                player.getInventory().addItem(new Item(nuggets, 2));
                oreDeposit.remove(new Integer(442));
                player.getInventory().addItem(new Item(2355, 1));
                player.getSkill().addExp(Skill.SMITHING, 14);
            }
            if (player.getInventory().getItemContainer().freeSlots() <= 0)
                player.getActionSender().sendMessage("Your inventory is too full to hold anymore bars.");
            else
                player.getActionSender().sendMessage("There's no ore to be smelted.");
        }

    I think this method literally gave me cancer lol.

    Make an enum with all this data so you can do this in a much more concise manner.

    Code:
    private int nuggets = 680;
    This is a constant and should be declared as one.

    You should also consider reading up on java conventions because there was a lot of really bad naming practices in here.
    There's more but that's all I could write in school atm.
    Reply With Quote  
     

  6. Thankful users:


  7. #6  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    24
    Posts
    538
    Thanks given
    216
    Thanks received
    98
    Rep Power
    113
    I honestly don't even understand how that #depositOre method is working properly. Must be buggy as hell at the least.

    It would take far too long to list all the things wrong with this, and how it should be done properly..
    But something I think you should know is that;

    Code:
    			for (int id : ores) { // id == id's in ores array
    				if (ores != null && ore != null)
    					if (ore.getId() == id) { // if item id in inventory matches id in array, deposit will be success
    						if (!SkillHandler.hasRequiredLevel(player, Skill.SMITHING, getLevelReq(id), "smelt this")) {
    							return;
    						}
    						if (player.getInventory().playerHasItem(id))
    							oreDeposit.add(id);
    						player.getInventory().removeItem(new Item(id));
    						continue;
    					}
    			}
    The lines colored in blue, are single line statement blocks.
    For example;

    Code:
    			if (player.getRights().isStaff())
    				player.forceChat("I am staff!");
    It isn't enclosed in brackets, so the block ends with the first line after the if statement. A single line statement block.
    So, if you placed code after that, no matter what it is, if they are staff, or aren't staff doesn't matter either, it will continue on whatever is next.

    Code:
    			if (player.getRights().isStaff())
    				player.forceChat("I am staff!");
    
    			player.forceChat("I am not staff!");
    If you were to initiate that in a method or whatever it may be ^
    If the player was staff, and only if they were staff, they would be forced to say "I am staff!"
    Then, it would continue, and force the player to say "I am not staff!"..
    You'll notice, if the player is staff, they are forced to say both, "I am staff!" and "I am not staff!";
    because you've only created a single line statement block with the condition that, if the player is staff, force a chat, and nothing else.

    To make that work properly, you would need to add a return, which means, you would need to enclose that statement block in brackets to use multiple lines.
    Code:
    			if (player.getRights().isStaff()) {
    				player.forceChat("I am staff!");
    				return;
    			}
    			player.forceChat("I am not staff!");
    The point of this information is that.. You more than likely have bugs with this you don't even realize, and I can point one out on the topic of this information;
    Code:
    						if (player.getInventory().playerHasItem(id))
    							oreDeposit.add(id);
    						player.getInventory().removeItem(new Item(id));
    						continue;
    With that bit of code, if the player has the ore id in their inventory, add it to the list. That's all that if statement does.
    So, if they don't have the ore id in their inventory, it wont add the id to the oreDeposit list, but it will continue to whatever is next.
    Which would then delete the ore from the players inventory, and the loop continue will be completely pointless without enclosing in that statement
    The oreId wont be added to the list, but the player will have the ore removed from their inventory, resulting in basically trashing the item for nothing.

    Now, this bit;
    Code:
    				if (ores != null && ore != null)
    					if (ore.getId() == id) { // if item id in inventory matches id in array, deposit will be success
    This might work, because it's reading the next if statement on the next line, but I am honestly unsure of how that would work.
    Let's be honest though, it'd probably just be easier combine those two if statements, rather than worry about enclosing the first if statement.
    Code:
    				if (ores != null && ore != null && ore.getId() == id) {
    This is the only statement you should NOT have enclosed, to save a couple lines and for in my opinion, easier readability in some cases.
    Code:
    			for (int id : ores) { // id == id's in ores array
    				if (ores != null && ore != null && ore.getId() == id) {
    						
    					if (!SkillHandler.hasRequiredLevel(player, Skill.SMITHING, getLevelReq(id), "smelt this")) 
    						return;
    					
    					if (player.getInventory().playerHasItem(id)) {
    						oreDeposit.add(id);
    						player.getInventory().removeItem(new Item(id));
    						continue;
    					}
    				}
    			}
    I even enclosed the other statements correctly for ya there

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  8. Thankful users:


  9. #7  
    Registered Member

    Join Date
    Jan 2011
    Posts
    1,945
    Thanks given
    1,215
    Thanks received
    548
    Rep Power
    607
    Thanks a lot for the detailed post!
    Reply With Quote  
     

  10. #8  
    Registered Member

    Join Date
    Dec 2012
    Posts
    3,006
    Thanks given
    899
    Thanks received
    929
    Rep Power
    2548
    It also shouldn't be instanced per player..too much code to critique bro
    Reply With Quote  
     

  11. Thankful user:


  12. #9  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    978
    Thanks given
    684
    Thanks received
    449
    Rep Power
    672
    Quote Originally Posted by Kaleem View Post
    It also shouldn't be instanced per player..too much code to critique bro
    There's nothing wrong with that really. I actually usually prefer that over static methods
    Reply With Quote  
     

  13. #10  
    Registered Member

    Join Date
    Dec 2012
    Posts
    3,006
    Thanks given
    899
    Thanks received
    929
    Rep Power
    2548
    Quote Originally Posted by Andys1814 View Post
    There's nothing wrong with that really. I actually usually prefer that over static methods
    Blast furnace is a member of the world, not player

    players submit their ores to the conveyer belt, so it doesn't make sense
    Reply With Quote  
     

  14. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Blast Furnace
    By Jaegon in forum Selling
    Replies: 9
    Last Post: 11-16-2012, 06:47 AM
  2. Interbellum; Blast Furnace
    By brkownz in forum Show-off
    Replies: 19
    Last Post: 07-21-2012, 10:16 AM
  3. BLast Furnace Xfer
    By Zahhak in forum Guides
    Replies: 6
    Last Post: 01-22-2010, 09:54 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •