Skip to content

Instantly share code, notes, and snippets.

@Cendrb
Created March 30, 2016 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cendrb/e20f364cc32d239aec594d2f83aa1e12 to your computer and use it in GitHub Desktop.
Save Cendrb/e20f364cc32d239aec594d2f83aa1e12 to your computer and use it in GitHub Desktop.
[1.9] registering event handlers
package com.mandatoryfun.ultramegafactory.proxy;
import com.mandatoryfun.ultramegafactory.Core;
import com.mandatoryfun.ultramegafactory.client.gui.GuiHandler;
import com.mandatoryfun.ultramegafactory.creativetab.ModCreativeTabs;
import com.mandatoryfun.ultramegafactory.handler.ConfigurationHandler;
import com.mandatoryfun.ultramegafactory.handler.TooltipHandler;
import com.mandatoryfun.ultramegafactory.init.ModBlocks;
import com.mandatoryfun.ultramegafactory.init.ModItems;
import com.mandatoryfun.ultramegafactory.world.ModWorld;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
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;
/**
* Created by cendr_000 on 25.03.2016.
*/
public class CommonProxy {
public void preInit(FMLPreInitializationEvent e) {
ModCreativeTabs.init();
ModItems.init();
ModBlocks.init();
// config
ConfigurationHandler.init(e.getSuggestedConfigurationFile());
NetworkRegistry.INSTANCE.registerGuiHandler(Core.instance, new GuiHandler());
}
public void init(FMLInitializationEvent e) {
ModWorld.init();
FMLCommonHandler.instance().bus().register(new ConfigurationHandler());
// REGISTERING THE HANDLER
MinecraftForge.EVENT_BUS.register(new TooltipHandler());
}
public void postInit(FMLPostInitializationEvent e) {
}
}
21:27:09: Executing external task 'runClient'...
#################################################
ForgeGradle 2.1-SNAPSHOT-2c720a8
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava UP-TO-DATE
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\ConfigurationHandler.java:31: error: modID has private access in ConfigChangedEvent
if(event.modID.equalsIgnoreCase(RefStrings.MODID))
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:17: error: toolTip has private access in ItemTooltipEvent
tooltipEvent.toolTip.add("John Cena");
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:23: error: player has private access in ItemTossEvent
EntityTNTPrimed tntPrimed = new EntityTNTPrimed(tossEvent.player.worldObj, tossEvent.player.posX, tossEvent.player.posY, tossEvent.player.posZ, tossEvent.player);
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:23: error: player has private access in ItemTossEvent
EntityTNTPrimed tntPrimed = new EntityTNTPrimed(tossEvent.player.worldObj, tossEvent.player.posX, tossEvent.player.posY, tossEvent.player.posZ, tossEvent.player);
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:23: error: player has private access in ItemTossEvent
EntityTNTPrimed tntPrimed = new EntityTNTPrimed(tossEvent.player.worldObj, tossEvent.player.posX, tossEvent.player.posY, tossEvent.player.posZ, tossEvent.player);
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:23: error: player has private access in ItemTossEvent
EntityTNTPrimed tntPrimed = new EntityTNTPrimed(tossEvent.player.worldObj, tossEvent.player.posX, tossEvent.player.posY, tossEvent.player.posZ, tossEvent.player);
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:23: error: player has private access in ItemTossEvent
EntityTNTPrimed tntPrimed = new EntityTNTPrimed(tossEvent.player.worldObj, tossEvent.player.posX, tossEvent.player.posY, tossEvent.player.posZ, tossEvent.player);
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:24: error: player has private access in ItemTossEvent
tossEvent.player.worldObj.spawnEntityInWorld(tntPrimed);
^
D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\handler\TooltipHandler.java:29: error: entity has private access in EntityEvent
if (e.entity instanceof EntityPlayer)
^
Note: D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\proxy\CommonProxy.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Documents\Minecraft\ModsDevelopment\forge-1.9-12.16.0.1804-1.9-mdk\build\sources\main\java\com\mandatoryfun\ultramegafactory\world\OreGenerator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
9 errors
1 warning
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15.689 secs
Compilation failed; see the compiler error output for details.
21:27:25: External task execution finished 'runClient'.
package com.mandatoryfun.ultramegafactory.handler;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
/**
* Created by cendr_000 on 28.03.2016.
*/
public class TooltipHandler {
@SubscribeEvent
public void onItemTooltipEvent(ItemTooltipEvent tooltipEvent) {
// error: toolTip has private access in ItemTooltipEvent
tooltipEvent.toolTip.add("random tooltip");
}
@SubscribeEvent
public void onItemTossEvent(ItemTossEvent tossEvent) {
// error: player has private access in ItemTossEvent
EntityTNTPrimed tntPrimed = new EntityTNTPrimed(tossEvent.player.worldObj, tossEvent.player.posX, tossEvent.player.posY, tossEvent.player.posZ, tossEvent.player);
tossEvent.player.worldObj.spawnEntityInWorld(tntPrimed);
}
@SubscribeEvent
public void onEntityGetHurt(LivingHurtEvent e) {
// error: entity has private access in EntityEvent
if (e.entity instanceof EntityPlayer)
e.setCanceled(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment