Jump to content

Recommended Posts

Posted

Hi, working on a compatibliy method to interface with SmartMoving Mod.

 

Normally I use this line of code when using Modloader. Works like a charm and allow my mod to hook in. "Btw when I program with Modloader I use only .txt not eclipse"

net.minecraft.src.BaseMod mod = (BaseMod)iterator.next();

 

However, while using eclipse and Forge. That line of code is red D:

net.minecraft.src.BaseMod mod = (BaseMod)iterator.next();

 

Which states: BaseMod cannot be resolved to a type.

 

Any solutions?

 

Just for added help, here is the rest of the code... for this method.

 

 

java.util.List list = net.minecraft.src.ModLoader.getLoadedMods();
			java.util.Iterator iterator = list.iterator();
			while(iterator.hasNext())
			{
				net.minecraft.src.BaseMod mod = (BaseMod)iterator.next();

				if("mod_SmartMoving".equals(mod.getName()))
				{
       					 try
        				{
       						 java.lang.Class modType = mod.getClass();

         					 java.lang.reflect.Method getInstance = modType
         					       .getMethod("getInstance", net.minecraft.src.EntityPlayer.class);

        					 java.lang.Object instance = getInstance
         					       .invoke(mod, Minecraft.getMinecraft().thePlayer);

       						 java.lang.Class type = instance.getClass();

         					 java.lang.reflect.Method getExhaustion = type
        					        .getMethod("getExhaustion");
       						 java.lang.reflect.Method addExhaustion = type
        					        .getMethod("addExhaustion", float.class);
      						 java.lang.reflect.Method setMaxExhaustionForAction = type
         					       .getMethod("setMaxExhaustionForAction", float.class);
       						 java.lang.reflect.Method setMaxExhaustionToStartAction = type
       						         .getMethod("setMaxExhaustionToStartAction", float.class);

       						 // the current exhaustion
       						 float currentExhaustion = (Float)getExhaustion.invoke(instance);

       						 //ActivateSmartMoving for AsgardShield
       						 mod_AsgardShield.smartMovingModActive = true;
       						 //asgardShieldExhaustion = currentExhaustion;
       						 if (mod_AsgardShield.EnableSmartMovingGuardID == true && mod_AsgardShield.smartMovingModActive == true)
       						 {

       							 // for checking whether a specific
       							 // action/activity is possible right now
       							 if(currentExhaustion <= 100F)
       							 {
       								 if (p.isBlocking())
       								 {
       									 if(ItemAsgardShield.asgardShieldActive == true || ItemZedSword.zedSwordActive == true)
       									 {
       										 // additional exhaustion per tick for the current
       										 // action/activity (may be completely consumed by
       										 // 'exhaustion loss per tick' if too small)
       										 addExhaustion.invoke(instance, .37F); 

       										 // set display to how high the exhaustion may get until
       										 // the current activity can not be continued any more
       										 setMaxExhaustionForAction.invoke(instance, 100F);

       										 // set display to how low the exhaustion need to be for
       										 // the current action/activity to be restarted again
       										 // (should really really be lower than the number above)
       										 setMaxExhaustionToStartAction.invoke(instance, 11.11F);
       									 }
       								 }
       							 }
       							 if (mod_AsgardShield.shieldBroke == false)
       							 {
       								 if (currentExhaustion >= 66.66F){mod_AsgardShield.guardTired = true; p.stopUsingItem();}
       								 if (currentExhaustion <= 33.33F && mod_AsgardShield.guardTired == true){mod_AsgardShield.guardTired = false;}
       							 }
       						 }
        				}
       					catch(java.lang.Exception e)
       					{
       					}

       					break;
				}
			}

 

 

Posted

Full SmartMoving Interface Code. That was said to place anywhere long as it ran every tick.

 

 

 

//****************************************************************			
			java.util.List list = net.minecraft.src.ModLoader.getLoadedMods();
			java.util.Iterator iterator = list.iterator();
			while(iterator.hasNext())
			{
				net.minecraft.src.BaseMod mod = (BaseMod)iterator.next();
				System.out.println(mod.getName());

				if("mod_SmartMoving".equals(mod.getName()))
				{
       					 try
        				{
       						 java.lang.Class modType = mod.getClass();

         					 java.lang.reflect.Method getInstance = modType
         					       .getMethod("getInstance", net.minecraft.src.EntityPlayer.class);

        					 java.lang.Object instance = getInstance
         					       .invoke(mod, Minecraft.getMinecraft().thePlayer);

       						 java.lang.Class type = instance.getClass();

         					 java.lang.reflect.Method getExhaustion = type
        					        .getMethod("getExhaustion");
       						 java.lang.reflect.Method addExhaustion = type
        					        .getMethod("addExhaustion", float.class);
      						 java.lang.reflect.Method setMaxExhaustionForAction = type
         					       .getMethod("setMaxExhaustionForAction", float.class);
       						 java.lang.reflect.Method setMaxExhaustionToStartAction = type
       						         .getMethod("setMaxExhaustionToStartAction", float.class);

       						 // the current exhaustion
       						 float currentExhaustion = (Float)getExhaustion.invoke(instance);

       						 //ActivateSmartMoving for AsgardShield
       						 mod_AsgardShield.smartMovingModActive = true;
       						 //asgardShieldExhaustion = currentExhaustion;
       						 if (mod_AsgardShield.EnableSmartMovingGuardID == true && mod_AsgardShield.smartMovingModActive == true)
       						 {

       							 // for checking whether a specific
       							 // action/activity is possible right now
       							 if(currentExhaustion <= 100F)
       							 {
       								 if (p.isBlocking())
       								 {
       									 if(ItemAsgardShield.asgardShieldActive == true || ItemZedSword.zedSwordActive == true)
       									 {
       										 // additional exhaustion per tick for the current
       										 // action/activity (may be completely consumed by
       										 // 'exhaustion loss per tick' if too small)
       										 addExhaustion.invoke(instance, .37F); 

       										 // set display to how high the exhaustion may get until
       										 // the current activity can not be continued any more
       										 setMaxExhaustionForAction.invoke(instance, 100F);

       										 // set display to how low the exhaustion need to be for
       										 // the current action/activity to be restarted again
       										 // (should really really be lower than the number above)
       										 setMaxExhaustionToStartAction.invoke(instance, 11.11F);
       									 }
       								 }
       							 }
       							 if (mod_AsgardShield.shieldBroke == false)
       							 {
       								 if (currentExhaustion >= 66.66F){mod_AsgardShield.guardTired = true; p.stopUsingItem();}
       								 if (currentExhaustion <= 33.33F && mod_AsgardShield.guardTired == true){mod_AsgardShield.guardTired = false;}
       							 }
       						 }
        				}
       					catch(java.lang.Exception e)
       					{
       					}

       					break;
				}
			}
//*****************************************************************			

 

 

 

I have no more errors, however no response with SmartMoving either =/.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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