Hello,
I'm having problems with two things in Forge 1.7.2.
First, the usual way to add names was completely scrapped, we are forced to use the lang file. I created my lang file according to this tutorial http://www.minecraft...wiki/Localizing
And pasted it to src/main/resources/assets/mymodid/lang/en_US.lang
but I still cannot see the names (textures in src/main/resources/assets/mymodid/textures work fine though).
Any advice where should it be located or where might be the problem?
Second, I used custom CraftingHandler for adding achievement when player crafted certain item. This was scrapped too, insted we should use Forge event bus.
Now I have instance of my crafting handler
private static CraftingHandler craftHandler = new CraftingHandler();
and in preInit method, I have
MinecraftForge.EVENT_BUS.register(craftHandler);
and here is the crafting handler class
public class CraftingHandler
{
/**
* Adds Coffee achievement after crafting mug of coffee
*/
@SubscribeEvent
public void onCrafting(ItemCraftedEvent event)
{
System.out.println("event launched");
if (event.crafting.getItem() == CocoaCraft.mugCoffee)
{
event.player.addStat(CocoaCraft.coffeeAchievement, 1);
}
}
}
Yet I don't get the achievement, nor see "event launched" in console.
You might have put the .lang file in the wrong directory. Try moving it around a bit. I always put mine in /resources/assets/[modid]/lang/ and it is always read.
As for the event, I have never used that specific one, so I don't know whether it even works. You should check the call hierarchy to discover when that event is ever even launched. Other than that, you could try the code below instead of what you're using. I doubt it'll make a difference, but you never know.
I've learned a bit, everything I'm saying applies to 1.7.10 - it may also apply to 1.7.2.
Language files don't go in resources anymore, they go in src\main\java\assets\[modid]\lang - this is obviously a 1.7.10 thing as Agadar says /resources/ works for 1.7.2.
For the events, it's changed a bit. PlayerEvents go in the EVENT_BUS, as mentioned above already. But Log-out events - and I'm 99% sure this applies to 1.7.2+ - only go in PlayerEvents for dedicated servers. For integrated servers (also applies to single player) you have to hook FMLServerStoppingEvent in your main mod class. But this event also fires if a dedicated server is shutdown, so you'll have to do some Sided checks if that's required.
This code makes little sense (you'd want to save all your custom player data regardless of server type) but shows the example well enough:
@EventHandler
public void onServerStopping(FMLServerStoppingEvent event) {
if(FMLCommonHandler.instance().getSide() == Side.CLIENT) {
// Do stuff only for Single Player / integrated server
MinecraftServer mc = FMLClientHandler.instance().getServer();
String allNames[] = mc.getAllUsernames().clone();
for(int i = 0; i < allNames.length; i++) {
// For 1.7.10, func_152612_a = getPlayerForUsername
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(allNames[i]);
PlayerData.savePlayerData((EntityPlayerMP)player);
}
} else {
// Do stuff only for dedicated server *shutdown*, for individual players logging out hook PlayerLoggedOutEvent in an EventBus subscription instead
}
}
Not exactly in the scope of the original poster's question but I thought I'd share
I'm having problems with two things in Forge 1.7.2.
First, the usual way to add names was completely scrapped, we are forced to use the lang file. I created my lang file according to this tutorial http://www.minecraft...wiki/Localizing
And pasted it to src/main/resources/assets/mymodid/lang/en_US.lang
but I still cannot see the names (textures in src/main/resources/assets/mymodid/textures work fine though).
Any advice where should it be located or where might be the problem?
Second, I used custom CraftingHandler for adding achievement when player crafted certain item. This was scrapped too, insted we should use Forge event bus.
Now I have instance of my crafting handler
and in preInit method, I have
and here is the crafting handler class
Yet I don't get the achievement, nor see "event launched" in console.
Any help would be appreciated
Divine smoker mod - Hookah in Minecraft: http://www.minecraftforum.net/topic/1689980-172splanspdivine-smoker-water-pipe-modhookahshisha-11/
Divine smoker mod - Hookah in Minecraft: http://www.minecraftforum.net/topic/1689980-172splanspdivine-smoker-water-pipe-modhookahshisha-11/
For FML events:
FMLCommonHandler.instance().bus().register(new MyPlayerEventHandler());
In that handler :
@SubscribeEvent
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent event)
{
}
There are also other player event that you can add here, but some seem not to work like onPlayerLogout
to regiter the handler
My modding project, just credit me and let me know if you borrow my code: https://github.com/FinalKill9175/WSBIM-NEW/
THIS. I thought I was going insane!
EDIT: We have to use PlayerLoggedOutEvent apparently heh
As for the event, I have never used that specific one, so I don't know whether it even works. You should check the call hierarchy to discover when that event is ever even launched. Other than that, you could try the code below instead of what you're using. I doubt it'll make a difference, but you never know.
My mods: Archmagus, BetterBoneMeal, BetterVanilla, Brewing-API, NaturalArmors, and PluckableChickens!
Language files don't go in resources anymore, they go in src\main\java\assets\[modid]\lang - this is obviously a 1.7.10 thing as Agadar says /resources/ works for 1.7.2.
For the events, it's changed a bit. PlayerEvents go in the EVENT_BUS, as mentioned above already. But Log-out events - and I'm 99% sure this applies to 1.7.2+ - only go in PlayerEvents for dedicated servers. For integrated servers (also applies to single player) you have to hook FMLServerStoppingEvent in your main mod class. But this event also fires if a dedicated server is shutdown, so you'll have to do some Sided checks if that's required.
This code makes little sense (you'd want to save all your custom player data regardless of server type) but shows the example well enough:
Not exactly in the scope of the original poster's question but I thought I'd share