Very Nice Fuel Handling, By: CBG

Discussion in 'Mod Development' started by CarbonBasedGhost, Sep 28, 2014.

  1. CarbonBasedGhost

    CarbonBasedGhost New Member

    Hiya,

    Today I bring you a very nice fuel handling system I made that is extremely light weight(compared to what people normally do).

    And going on a stretch I say this should be implemented to forge just to make everything so much simpler. @GregoriousT (screw the spelling) helped me out a bit to make it more efficient but other than that it is all mine.

    So In order for this to work you need the handler (feel free to suggest things to make it more efficient or to ask questions)
    Code:
    public class VinillaFurnaceFuelHandler implements IFuelHandler{
       
        public static HashMap<Item, Integer> FurnaceFuel = new HashMap<Item, Integer>();
    
       
        public static void RegisterFurnaceFuel(Item fuel, Integer burnTime){
           
            FurnaceFuel.put(fuel, burnTime);
        }
        @Override
        public int getBurnTime(ItemStack fuel) {
           
            Item ItemInFuelSlot = fuel.getItem();
            Integer BurnTime = FurnaceFuel.get(ItemInFuelSlot);
           
            if (BurnTime == null) return 0; else return BurnTime;   
        }
    }
    Now you can directly input items to be made fuels into this but I for blocks I had to make a method, and to make the code look clean I made a method for items too.

    Code:
    public static void addItemFurnaceFuel(Item fuel, Integer burnTime){
           
            VinillaFurnaceFuelHandler.RegisterFurnaceFuel(fuel, burnTime);
           
        }
    
        public static void addBlockFurnaceFuel (Block fuel, Integer burnTime){
           
            VinillaFurnaceFuelHandler.RegisterFurnaceFuel(Item.getItemFromBlock(fuel), burnTime);
           
        }
    and all you have to do now is register the fuel handler in preInit

    Code:
    @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
           
            GameRegistry.registerFuelHandler(new VinillaFurnaceFuelHandler());
           
        }
     
  2. MigukNamja

    MigukNamja New Member

    Vinilla ?
     
    1SDAN and pc_assassin like this.
  3. CarbonBasedGhost

    CarbonBasedGhost New Member

    Yes I know and I refuse to fix it. :p XD
     
    1SDAN and MigukNamja like this.
  4. MigukNamja

    MigukNamja New Member

    Must be rollin' in your 5.0 with your ragtop down so your hair can blow

    :p
     
    1SDAN and CarbonBasedGhost like this.
  5. Strikingwolf

    Strikingwolf New Member

    OoooOOooO seems nice
     
  6. immibis

    immibis New Member

    If that's extremely lightweight, I want to know what the heck everyone else does.
     
  7. CarbonBasedGhost

    CarbonBasedGhost New Member

    If I want to add 30 fuels I just register them in there. If someone uses the traditional way there will be thirty if statements all lined up next to each other.
     
  8. SephirothJ

    SephirothJ New Member

    You forgot to add a check for registered fuel. Also, don't forget about naming convention.
     
  9. CarbonBasedGhost

    CarbonBasedGhost New Member

    Sorry about the late reply. This is just an outline however that is something that should be implemented. If I were to make a check I would make it so I look at the conflicting fuel then, delete my registration (unless said otherwise, probably by a priority 1 byte variable). The reason I would not re-register the fuel through my own methods is because that would make it even more laggy with the most efficient method of withholding a recipe from being registered.

    Hopefully that makes some sense
    -CBG
     
    1SDAN and jedi13 like this.

Share This Page