Jump to content

[1.10.2] Convert a piece of code form v1.7.10


DoubleSix6

Recommended Posts

 public void init(net.minecraftforge.fml.common.event.FMLInitializationEvent event)
    {

        proxy.init();
        ModRecipes.init();

        ModWorldGen.init();
        //GUIs
        guiHandler = new GuiHandler();
        net.minecraftforge.fml.common.network.NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler);
    }

I have error in net.minecraftforge.fml.common.network.NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler);.

Link to comment
Share on other sites

package com.darkona.adventurebackpack;

import com.darkona.adventurebackpack.config.ConfigHandler;
import com.darkona.adventurebackpack.fluids.FluidEffectRegistry;
import com.darkona.adventurebackpack.handlers.ClientEventHandler;
import com.darkona.adventurebackpack.handlers.GeneralEventHandler;
import com.darkona.adventurebackpack.handlers.GuiHandler;
import com.darkona.adventurebackpack.handlers.PlayerEventHandler;
import com.darkona.adventurebackpack.init.*;
import com.darkona.adventurebackpack.proxy.IProxy;
import com.darkona.adventurebackpack.reference.ModInfo;
import com.darkona.adventurebackpack.util.LogHelper;
import com.darkona.adventurebackpack.util.Utils;
import com.darkona.adventurebackpack.util.calendar.ChineseCalendar;
import com.darkona.adventurebackpack.util.calendar.JewishCalendar;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;

import java.util.Calendar;

/**
 * Created on 10/10/2014
 *
 * @author Javier Darkona
 */
@Mod(modid = ModInfo.MOD_ID,
        name = ModInfo.MOD_NAME,
        version = ModInfo.MOD_VERSION,
        guiFactory = ModInfo.GUI_FACTORY_CLASS
)
public class AdventureBackpack
{

    @SidedProxy(clientSide = ModInfo.MOD_CLIENT_PROXY, serverSide = ModInfo.MOD_SERVER_PROXY)
    public static IProxy proxy;
    @Mod.Instance(ModInfo.MOD_ID)
    public static AdventureBackpack instance;

    //Static things
    public static CreativeTabAB creativeTab = new CreativeTabAB();


    public boolean chineseNewYear;
    public boolean hannukah;
    public String Holiday;
    PlayerEventHandler playerEventHandler;
    ClientEventHandler clientEventHandler;
    GeneralEventHandler generalEventHandler;

    GuiHandler guiHandler;

    @Mod.EventHandler
    public void preInit(net.minecraftforge.fml.common.event.FMLPreInitializationEvent event)
    {

        int year = Calendar.getInstance().get(Calendar.YEAR), month = Calendar.getInstance().get(Calendar.MONTH) + 1, day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

        //Configuration
        net.minecraftforge.fml.common.FMLCommonHandler.instance().bus().register(new ConfigHandler());
        ConfigHandler.init(event.getSuggestedConfigurationFile());
        chineseNewYear = ChineseCalendar.isChineseNewYear(year, month, day);
        hannukah = JewishCalendar.isHannukah(year, month, day);
        Holiday = Utils.getHoliday();

        //ModStuff
        ModItems.init();
        ModBlocks.init();
        ModFluids.init();
        FluidEffectRegistry.init();
        ModEntities.init();
        ModNetwork.init();
        proxy.initNetwork();
        // EVENTS
        playerEventHandler = new PlayerEventHandler();
        generalEventHandler = new GeneralEventHandler();
        clientEventHandler = new ClientEventHandler();


        MinecraftForge.EVENT_BUS.register(generalEventHandler);
        MinecraftForge.EVENT_BUS.register(clientEventHandler);
        MinecraftForge.EVENT_BUS.register(playerEventHandler);

        net.minecraftforge.fml.common.FMLCommonHandler.instance().bus().register(playerEventHandler);

    }

    @Mod.EventHandler
    public void init(net.minecraftforge.fml.common.event.FMLInitializationEvent event)
    {

        proxy.init();
        ModRecipes.init();

        ModWorldGen.init();
        //GUIs
        guiHandler = new GuiHandler();
        net.minecraftforge.fml.common.network.NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler);
    }

    @Mod.EventHandler
    public void postInit(net.minecraftforge.fml.common.event.FMLPostInitializationEvent event)
    {

        ConfigHandler.IS_TINKERS = Loader.isModLoaded("TConstruct");
        ConfigHandler.IS_THAUM = Loader.isModLoaded("Thaumcraft");
        ConfigHandler.IS_TWILIGHT = Loader.isModLoaded("TwilightForest");
        ConfigHandler.IS_ENVIROMINE = Loader.isModLoaded("EnviroMine");
        ConfigHandler.IS_BUILDCRAFT = Loader.isModLoaded("BuildCraft|Core");
        ConfigHandler.IS_RAILCRAFT = Loader.isModLoaded("Railcraft");


        if (ConfigHandler.IS_BUILDCRAFT)
        {
            LogHelper.info("Buildcraft is present. Acting accordingly");
        }

        if (ConfigHandler.IS_TWILIGHT)
        {
            LogHelper.info("Twilight Forest is present. Acting accordingly");
        }

        ConditionalFluidEffect.init();
        ModItems.conditionalInit();
        ModRecipes.conditionalInit();


        /*
        LogHelper.info("DUMPING FLUID INFORMATION");
        LogHelper.info("-------------------------------------------------------------------------");
        for(Fluid fluid : FluidRegistry.getRegisteredFluids().values())
        {

            LogHelper.info("Unlocalized name: " + fluid.getUnlocalizedName());
            LogHelper.info("Name: " + fluid.getName());
            LogHelper.info("");
        }
        LogHelper.info("-------------------------------------------------------------------------");
        */
        /*
        LogHelper.info("DUMPING TILE INFORMATION");
        LogHelper.info("-------------------------------------------------------------------------");
        for (Block block : GameData.getBlockRegistry().typeSafeIterable())
        {
            LogHelper.info("Block= " + block.getUnlocalizedName());
        }
        LogHelper.info("-------------------------------------------------------------------------");
        */
    }

}

 

Link to comment
Share on other sites

package com.darkona.adventurebackpack.handlers;

import com.darkona.adventurebackpack.block.TileAdventureBackpack;
import com.darkona.adventurebackpack.client.gui.GuiAdvBackpack;
import com.darkona.adventurebackpack.client.gui.GuiCopterPack;
import com.darkona.adventurebackpack.client.gui.GuiSteamJetpack;
import com.darkona.adventurebackpack.inventory.*;
import com.darkona.adventurebackpack.util.Wearing;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

/**
 * Created on 12/10/2014
 *
 * @author Darkona
 */
public class GuiHandler implements IGuiHandler
{
    public static final byte JETPACK_WEARING = 6;
    public static final byte JETPACK_HOLDING = 5;
    public static final byte COPTER_WEARING = 4;
    public static final byte COPTER_HOLDING = 3;
    public static final byte BACKPACK_HOLDING = 2;
    public static final byte BACKPACK_WEARING = 1;
    public static final byte BACKPACK_TILE = 0;


    public GuiHandler()
    {
    }

    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        switch (ID)
        {
            case BACKPACK_TILE:
                if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack)
                {
                    return new ContainerBackpack(player, (TileAdventureBackpack) world.getTileEntity(x, y, z), ContainerBackpack.SOURCE_TILE);
                }
                break;
            case BACKPACK_WEARING:
                if (Wearing.isWearingBackpack(player))
                {
                    return new ContainerBackpack(player, new InventoryBackpack(Wearing.getWearingBackpack(player)), ContainerBackpack.SOURCE_WEARING);
                }
                break;
            case BACKPACK_HOLDING:
                if (Wearing.isHoldingBackpack(player))
                {
                    return new ContainerBackpack(player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), ContainerBackpack.SOURCE_HOLDING);
                }
                break;
            case COPTER_HOLDING:
                if (Wearing.isHoldingCopter(player))
                {
                    return new ContainerCopter(player, new InventoryCopterPack(Wearing.getHoldingCopter(player)),false);
                }
                break;
            case COPTER_WEARING:
                if (Wearing.isWearingCopter(player))
                {
                    return new ContainerCopter(player, new InventoryCopterPack(Wearing.getWearingCopter(player)), true);
                }
                break;
            case JETPACK_HOLDING:
                if (Wearing.isHoldingSteam(player))
                {
                    return new ContainerJetpack(player, new InventorySteamJetpack(Wearing.getHoldingSteam(player)),false);
                }
                break;
            case JETPACK_WEARING:
                if (Wearing.isWearingSteam(player))
                {
                    return new ContainerJetpack(player, new InventorySteamJetpack(Wearing.getWearingSteam(player)), true);
                }
                break;
            default:
                player.closeScreen();
                break;
        }

        return null;

    }

    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        switch (ID)
        {
            case BACKPACK_TILE:
                if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack)
                {
                    return new GuiAdvBackpack(player, (TileAdventureBackpack) world.getTileEntity(x, y, z));
                }
                break;
            case BACKPACK_WEARING:
                if (Wearing.isWearingBackpack(player))
                {
                    return new GuiAdvBackpack(player, new InventoryBackpack(Wearing.getWearingBackpack(player)), true);
                }
                break;
            case BACKPACK_HOLDING:
                if (Wearing.isHoldingBackpack(player))
                {
                    return new GuiAdvBackpack(player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), false);
                }
                break;
            case COPTER_HOLDING:
                if (Wearing.isHoldingCopter(player))
                {
                    return new GuiCopterPack(player, new InventoryCopterPack(Wearing.getHoldingCopter(player)),false);
                }
                break;
            case COPTER_WEARING:
                if (Wearing.isWearingCopter(player))
                {
                    return new GuiCopterPack(player, new InventoryCopterPack(Wearing.getWearingCopter(player)), true);
                }
                break;
            case JETPACK_HOLDING:
                if (Wearing.isHoldingSteam(player))
                {
                    return new GuiSteamJetpack(player, new InventorySteamJetpack(Wearing.getHoldingSteam(player)),false);
                }
                break;
            case JETPACK_WEARING:
                if (Wearing.isWearingSteam(player))
                {
                    return new GuiSteamJetpack(player, new InventorySteamJetpack(Wearing.getWearingSteam(player)), true);
                }
                break;
            default:
                player.closeScreen();
                break;
        }
        return null;
    }
}

 

Link to comment
Share on other sites

Please learn to use code or spoiler tags to encapsulate long patches of code. Also learn how to use your IDE to trace simple semantic errors like using the wrong arguments to a method. This is a Forge forum, not a Java hand-holding class.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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