Jump to content

Recommended Posts

Posted

Hi, it´s DealerJoe again!  ::)

 

Okay guys, got a new problem. I´ve been looking around in other mod´s source for about 2 hours now, but I couldn´t

figure out what I´m doing wrong.

Now my Problem : I want to generate a config file, so I created a method called loadConfiguration, put @PreInit above and added the event. Then I created the variables for the id´s of items and blocks.

 

Here my Source :

 

@PreInit
public void loadConfiguration(FMLPreInitializationEvent evt) {
	Configuration config = new Configuration(new File(evt.getModConfigurationDirectory(),  "FarmersFriends.cfg"));
	config.load();

	blockChopperID = config.getOrCreateIntProperty("blockChopperID", Configuration.CATEGORY_BLOCK, 250).getInt();
	blockToasterID = config.getOrCreateIntProperty("blockToasterID", Configuration.CATEGORY_BLOCK, 251).getInt();

	chopperID = config.getOrCreateIntProperty("itemChopperID", Configuration.CATEGORY_ITEM, 5000).getInt();
	sawmealID = config.getOrCreateIntProperty("sawmealID", Configuration.CATEGORY_ITEM, 5001).getInt();
	scytheID = config.getOrCreateIntProperty("scytheID", Configuration.CATEGORY_ITEM, 5002).getInt();
	scytheBloodyID = config.getOrCreateIntProperty("bloodyScytheID", Configuration.CATEGORY_ITEM, 5003).getInt();
	toasterID = config.getOrCreateIntProperty("itemToasterID", Configuration.CATEGORY_ITEM, 5004).getInt();

	config.save();
}

 

I don´t now whats wrong with it. If you guys miss some parts of the src, I´m gonna post it.

Hope you can help me.

 

DealerJoe

Posted

Try using new File(Minecraft.getMinecraftDir(), "config/FarmersFriends.cfg")

Should work, byt don't use @preinit more than once in the mod class.

Read the EAQ before posting! OR ELSE!

 

This isn't building better software, its trying to grab a place in the commit list of a highly visible github project.

 

www.forgeessentials.com

 

Don't PM me, I don't check this account unless I have to.

Posted

Try using new File(Minecraft.getMinecraftDir(), "config/FarmersFriends.cfg")

Should work, byt don't use @preinit more than once in the mod class.

 

I cant do that because Minecraft.getMinecraftDir() doesn´t work on servers and this is an SMP mod, so thats not working.

And what do you mean with

 

don't use @preinit more than once in the mod class.

 

This is the only method I´m using this Flag.

 

Any other Idea ?

Posted

Step through it, see where it fails, it should attempt to create the file if it doesnt exist.

If it cant do that for some reason it'll exit earily, so, you should look into it.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Step through it, see where it fails, it should attempt to create the file if it doesnt exist.

If it cant do that for some reason it'll exit earily, so, you should look into it.

 

Okay, I did so.

When I set the breakpoint to the beginning of the loadConfiguration-Method, I noticed, that it´s not even called.

Do you know why or how I can fix it ?

 

DealerJoe

Posted

It would have to be in your mod class, and then logs would be needed, need a lot more information then you're giving.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

My mod Class

 

package farmersfriends.common;

import java.io.File;

import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="FarmersFriends", name="FarmersFriends", version="1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class mod_farmersfriends {

/** IDS **/

public static int blockChopperID;
public static int blockToasterID;

public static int chopperID;
public static int sawmealID;
public static int scytheID;
public static int scytheBloodyID;
public static int toasterID;

/** BLOCKS AND ITEMS **/

public static final Block blockChopper = (new BlockChopper(blockChopperID, TileEntityChopper.class)).setHardness(0.5F).setBlockName("chopperBlock");
public static final Block blockToaster = (new BlockToaster(blockToasterID, TileEntityToaster.class)).setHardness(0.5F).setBlockName("toasterBlock");

public static final Item chopper = (new ItemChopper(chopperID, blockChopper).setItemName("chopper").setIconIndex(0));
public static final Item sawmeal = (new ItemSawmeal(sawmealID).setItemName("sawmeal").setIconIndex(1));
public static final Item farmersScythe = (new ItemScythe(scytheID).setItemName("farmersScythe").setIconIndex(2));
public static final Item farmersScytheBloody = (new ItemScythe(scytheBloodyID).setItemName("farmersScytheBloody").setIconIndex(3));
public static final Item toaster = (new ItemToaster(toasterID, blockToaster).setItemName("toaster").setIconIndex(4));


@SidedProxy(clientSide = "farmersfriends.client.ClientProxyFm", serverSide = "farmersfriends.common.CommonProxyFm")
public static CommonProxyFm proxy;	


@PreInit
public void loadConfiguration(FMLPreInitializationEvent evt) {
	Configuration config = new Configuration(new File(evt.getModConfigurationDirectory(),  "FarmersFriends.cfg"));
	config.load();

	blockChopperID = config.getOrCreateIntProperty("blockChopperID", Configuration.CATEGORY_BLOCK, 250).getInt();
	blockToasterID = config.getOrCreateIntProperty("blockToasterID", Configuration.CATEGORY_BLOCK, 251).getInt();

	chopperID = config.getOrCreateIntProperty("itemChopperID", Configuration.CATEGORY_ITEM, 5000).getInt();
	sawmealID = config.getOrCreateIntProperty("sawmealID", Configuration.CATEGORY_ITEM, 5001).getInt();
	scytheID = config.getOrCreateIntProperty("scytheID", Configuration.CATEGORY_ITEM, 5002).getInt();
	scytheBloodyID = config.getOrCreateIntProperty("bloodyScytheID", Configuration.CATEGORY_ITEM, 5003).getInt();
	toasterID = config.getOrCreateIntProperty("itemToasterID", Configuration.CATEGORY_ITEM, 5004).getInt();

	config.save();
}


@Init
public void load(FMLInitializationEvent e){
	GameRegistry.registerFuelHandler(new FuelHandler());

	LanguageRegistry.addName(chopper, "Chopper");
	LanguageRegistry.addName(sawmeal, "Sawmeal");
	LanguageRegistry.addName(farmersScythe, "Farmers Scythe");
	LanguageRegistry.addName(farmersScytheBloody, "Farmers Bloody Scythe");
	LanguageRegistry.addName(toaster, "Toaster");

	GameRegistry.addRecipe(new ItemStack(chopper, 1), new Object[]{
		"  S","IIW","ILR", 'S', Item.stick, 'I', Item.ingotIron, 'W', Block.wood, 'R', Item.redstone, 'L', Item.leather
	});

	proxy.registerRenderThings();
}

}

 

Log / Exception:

 

2012-10-20 13:52:35 [iNFO] [ForgeModLoader] Forge Mod Loader version 3.1.35.394 for Minecraft client:1.3.2, server:1.3.2 loading
2012-10-20 13:52:37 [iNFO] [sTDOUT] 27 achievements
2012-10-20 13:52:37 [iNFO] [sTDOUT] 195 recipes
2012-10-20 13:52:37 [iNFO] [sTDOUT] Setting user: Player405, -
2012-10-20 13:52:37 [iNFO] [sTDERR] Client asked for parameter: server
2012-10-20 13:52:37 [iNFO] [sTDOUT] LWJGL Version: 2.4.2
2012-10-20 13:52:38 [iNFO] [ForgeModLoader] Attempting early MinecraftForge initialization
2012-10-20 13:52:38 [iNFO] [sTDOUT] MinecraftForge v4.2.5.303 Initialized
2012-10-20 13:52:38 [iNFO] [ForgeModLoader] MinecraftForge v4.2.5.303 Initialized
2012-10-20 13:52:38 [iNFO] [ForgeModLoader] Completed early MinecraftForge initialization
2012-10-20 13:52:38 [iNFO] [ForgeModLoader] Searching C:\Users\Toshiba\Desktop\Forge Modding\FarmersFriends\jars\mods for mods
2012-10-20 13:52:39 [iNFO] [ForgeModLoader] Attempting to reparse the mod container bin
2012-10-20 13:52:41 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 3 mods to load
2012-10-20 13:52:41 [iNFO] [sTDERR] Exception in thread "Minecraft main thread" java.lang.ExceptionInInitializerError
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at java.lang.Class.forName0(Native Method)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at java.lang.Class.forName(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:407)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:124)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:81)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.loadMods(Loader.java:466)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:146)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.startGame(Minecraft.java:416)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:748)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)
2012-10-20 13:52:41 [iNFO] [sTDERR] Caused by: java.lang.IllegalArgumentException: Slot 0 is already occupied by farmersfriends.common.BlockChopper@4b261b80 when adding farmersfriends.common.BlockToaster@32d7970b
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at net.minecraft.src.Block.<init>(Block.java:280)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at net.minecraft.src.BlockContainer.<init>(BlockContainer.java:7)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at farmersfriends.common.BlockToaster.<init>(BlockToaster.java:15)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	at farmersfriends.common.mod_farmersfriends.<clinit>(mod_farmersfriends.java:38)
2012-10-20 13:52:41 [iNFO] [sTDERR] 	... 28 more
2012-10-20 13:52:43 [iNFO] [sTDERR] Someone is closing me!

 

 

Thanks for your help !

Posted

Well no shit you're getting issues, this is a vary basic issue that you shouldn't of even came here asking about.

You're STATICALLY initalizing your blocks/items, which in of itself is stupid. But beyond that, happens BEFORE your config is loaded, so you can't use your config values -.-

there are different state events for a reason.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Oh Shit, you´re right.

Sorry for waisting your time  :'(, but I just didn´t see that issue. I should have had looked into the code much better.

But there is one more question, why is it stupid to add a static-modifier when initializing the blocks or items ?  :-\

 

But thank you anyway.

 

DealerJoe

Posted

statically declaring it isnt the issue, its the initalization in the static/constructor. Obviously it happens FIRST, which is bad because you can't do things before FIRST.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So, we have a 5 player server running the Hexxit modpack, with the sole addition of one extra mod, CustomNPCs. Something about CustomNPCs doesn't play nice with the server. Only three players are playing it, all of them have CustomNPCs installed in their own game files, and we have CustomNPCs installed in our server. We can all hold the tools and use the custom recipes added by the mod or by players using the NPC spawner tool. However, I'm the only one who can actually use them. If either other player uses them, they immediately crash and are booted off the server. I can make NPCs, the NPCs can detect them and attack them, all that, but they cannot see them, nor can they interact with them in any way. What could be causing this? I will add, as far as I know, I'm the only one to have run the modpack in single player as well as in multiplayer, I believe the other two have only run it in multiplayer for the server. Could this possibly be part of the problem? Any help would be appreciated.
    • Hello, Thank you so much for the suggestion, I will create a post.
    • You're using the wrong FACING property in Mechanism#getStateForPlacement, BlockStateProperties.FACING instead of Mechanism.FACING, HorizontalDirectionalBlock.FACING or BlockStateProperties.HORIZONTAL_FACING (which all refer to the same value). The former includes all six Direction values, the latter only includes the four horizontal values.
    • quiero que me digan como hago para instalar bien el java y forge nada mas hasta el momento lo hice pero java no ejecuta el forge   
    • Mod Idea: Server-Specific Mod Disabler & Anti-Cheat Helper Overview: This mod allows players to seamlessly play on Minecraft servers without worrying about banned or incompatible mods. It automatically disables specific mods based on the server's configuration, ensuring that players are only using allowed mods. Additionally, it provides a safeguard against hacking mods by instantly blocking them from being used, promoting fair gameplay on multiplayer servers. Key Features: 1. Server-Specific Mod Disabling: Automatic Mod Detection: The mod will automatically detect which mods are allowed or blocked on a particular server. Server Configurable Lists: Server admins can maintain a list of banned or whitelisted mods, which will be dynamically applied when a player joins. Player Customization: Players can choose whether the mod should automatically disable specific mods when joining servers, or allow them to be used based on the server's settings. 2. Anti-Cheat and Hack Protection: Instant Hack Detection: The mod will automatically identify and block known hacking mods when joining a server. If a player attempts to join with a hacking mod, the server can receive an alert, and the mod will prevent the player from joining until the mod is removed. Real-Time Monitoring: The mod will continuously monitor the player's mods while on the server, ensuring that no banned or suspicious mods are activated. 3. Community-Driven Mod Management: Custom Blocklists and Whitelists: Server admins can manage custom mod lists directly through a configuration file or via an in-game interface. These lists would allow mods to be either whitelisted, banned, or marked for temporary disabling. Integration with Modding Communities: The mod can gather mod compatibility reports from other players, sharing knowledge about which mods work together and which are problematic. 4. Player-Friendly Experience: Less Hassle for Players: With this mod, players no longer need to manually disable or enable mods when switching between servers. The mod takes care of everything for them. Seamless Gameplay: Players can freely switch between servers with different rules and mod requirements without worrying about compatibility issues or getting banned for using the wrong mods. 5. Open-Source and Extensible: Community Contributions: The mod will be open-source, allowing the Minecraft community to contribute by adding new features, bug fixes, and support for more mods. Customizable for Future Versions: The mod will be updated to support future Minecraft versions, ensuring long-term usability. Additional Ideas for Future Expansion: 1. Integration with Minecraft Servers (Optional): Server-Side Mod Configuration: In addition to client-side mod management, server owners can opt to install a server-side version of this mod, which can enforce mod restrictions for all players. Server Feedback System: When a mod is disabled, the server can automatically provide feedback to the player about why it was disabled and whether they need to install an alternative. 2. Donation and Support System: Monetization for Future Development: The mod could offer a donation-based system or a paid premium version with advanced features like real-time support or a larger mod compatibility database. Community Support: Players could report issues directly through the mod, ensuring faster resolutions and support from the mod development community. Benefits: 1. For Players: No Need for Constant Mod Configuration: Players no longer need to manually switch between different mod sets based on the server they join. Reduced Risk of Getting Banned: The mod automatically prevents the use of banned or incompatible mods, reducing the risk of being kicked or banned from servers. Hassle-Free Experience: The mod removes the need for players to learn about different server mod policies, providing a smoother experience overall. 2. For Server Owners: Simplified Server Management: Server admins no longer need to constantly monitor which mods players are using. The mod ensures players are only using compliant mods. Better Anti-Cheat Measures: Server owners can trust that hacking mods will be automatically blocked, improving server security. Easy Integration: With a simple configuration file, server owners can quickly set up their mod policies and get started. 3. For the Minecraft Community: Encourages Fair Play: The mod promotes fair gameplay by automatically preventing the use of cheating mods, ensuring a better multiplayer environment. Better Mod Compatibility: As the mod grows, it can help players and server owners discover which mods are compatible with others, making the modding ecosystem more reliable. Potential Challenges and Solutions: 1. Resistance from Players Using Hacking Mods: Solution: Allow server admins to configure a warning system where players can receive notifications about the mod being blocked before they are kicked. This gives them a chance to fix their setup. 2. Keeping Mod Lists Up-to-Date: Solution: Implement a community-driven reporting system where players and server owners can submit their mod lists, keeping the database current with new mods and changes in mod compatibility. 3. Cross-Platform Compatibility: Solution: Ensure that the mod is built to support both Java and Bedrock editions (if applicable) by using cross-platform modding tools and making the mod adaptable to both versions. Conclusion: This mod has the potential to significantly improve the Minecraft multiplayer experience by making it easier for players to manage mods and preventing hacks from ruining gameplay. By focusing on server-specific mod management and providing automated protection from cheating mods, this mod could change how Minecraft servers handle modding and create a safer, more enjoyable experience for everyone involved.
  • Topics

×
×
  • Create New...

Important Information

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