Jump to content

How to replace a minecraft class with my own class?? or replaceing methods


ismaeel96

Recommended Posts

hi,

 

im trying to make a mod, i used to be able to just edit the classes but now we cant edit the classes in the new forge gradle. i want to know how to replace a mc class with my own class and if we cant do that i want to know how to override a method in a different class?

 

i either have to override a whole bunch of methods or edit the class and replace the original with my own

 

 

here is how i was trying to override methods

 

 

package com.example.examplemod;

(all imports that i need)

@Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)

@SideOnly(Side.CLIENT)
public class ExampleMod extends RendererLivingEntity
{


 public static final String MODID = "examplemod";
 public static final String VERSION = "1.0";

public ExampleMod(ModelBase p_i1261_1_, float p_i1261_2_) 
        {
	super(p_i1261_1_, p_i1261_2_);
	// TODO Auto-generated constructor stub
}

    @Override
    protected void renderModel(EntityLivingBase p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_)
    {
       ...
    }


        // eclipse tells me to add this unimplemented method
@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
	// TODO Auto-generated method stub
	return null;
}
    
}

 

my question is: how do i go about replaceing a whole class with my own or how to override a method that is in a mc class?

 

 

when i run eclipse MC doesnt run, i get this VVV

 

 

[13:05:54] [main/INFO] [GradleStart]: No arguments specified, assuming client.

[13:05:54] [main/INFO] [GradleStart]: Extra: []

[13:05:54] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --username, ForgeDevName, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --accessToken, {REDACTED}, --assetIndex, 1.7.10, --assetsDir, C:/Users/IsMaEeL/.gradle/caches/minecraft/assets, --version, 1.7.10]

[13:05:54] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker

[13:05:54] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker

[13:05:54] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker

[13:05:54] [main/INFO] [FML]: Forge Mod Loader version 7.10.18.1180 for Minecraft 1.7.10 loading

[13:05:54] [main/INFO] [FML]: Java is Java HotSpot 64-Bit Server VM, version 1.7.0_65, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7

[13:05:54] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation

[13:05:54] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker

[13:05:54] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker

[13:05:54] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker

[13:05:54] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker

[13:05:54] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper

[13:05:55] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!

[13:05:56] [main/ERROR] [FML]: The minecraft jar file:/C:/Users/IsMaEeL/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.0.1180/forgeSrc-1.7.10-10.13.0.1180.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again!

[13:05:56] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem!

[13:05:56] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/C:/Users/IsMaEeL/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.0.1180/forgeSrc-1.7.10-10.13.0.1180.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it

[13:05:56] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing

[13:05:56] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper

[13:05:56] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker

[13:05:57] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}

[13:05:58] [main/INFO]: Setting user: ForgeDevName

[13:05:59] [Client thread/INFO]: LWJGL Version: 2.9.1

[13:06:00] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization

[13:06:00] [Client thread/INFO] [FML]: MinecraftForge v10.13.0.1180 Initialized

[13:06:00] [Client thread/INFO] [FML]: Replaced 182 ore recipies

[13:06:00] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization

[13:06:01] [Client thread/INFO] [FML]: Searching C:\Users\IsMaEeL\Desktop\Forge Mods 1.7.10\eclipse\mods for mods

[13:06:02] [Client thread/ERROR] [FML]: FML has detected a mod that is using a package name based on 'net.minecraft.src' : net.minecraft.src.FMLRenderAccessLibrary. This is generally a severe programming error.  There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into a new package. Go on. DO IT NOW!

[13:06:04] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load

[13:06:05] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from CONSTRUCTING to PREINITIALIZATION. Loading cannot continue

[13:06:05] [Client thread/ERROR] [FML]:

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{7.10.18.1180} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed

Forge{10.13.0.1180} [Minecraft Forge] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed

examplemod{1.0} [Example Mod] (bin) Unloaded->Errored

[13:06:05] [Client thread/ERROR] [FML]: The following problems were captured during this phase

[13:06:05] [Client thread/ERROR] [FML]: Caught exception from examplemod

java.lang.InstantiationException: com.example.examplemod.ExampleMod

at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_65]

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173) ~[forgeSrc-1.7.10-10.13.0.1180.jar:?]

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486) ~[forgeSrc-1.7.10-10.13.0.1180.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeSrc-1.7.10-10.13.0.1180.jar:?]

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeSrc-1.7.10-10.13.0.1180.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]

at cpw.mods.fml.common.Loader.loadMods(Loader.java:492) [Loader.class:?]

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:532) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:941) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]

at GradleStart.bounce(GradleStart.java:108) [start/:?]

at GradleStart.startClient(GradleStart.java:101) [start/:?]

at GradleStart.main(GradleStart.java:56) [start/:?]

---- Minecraft Crash Report ----

// But it works on my machine.

 

Time: 7/23/14 1:06 PM

Description: There was a severe problem during mod loading that has caused the game to fail

 

cpw.mods.fml.common.LoaderException: java.lang.InstantiationException: com.example.examplemod.ExampleMod

at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:502)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:532)

at net.minecraft.client.Minecraft.run(Minecraft.java:941)

at net.minecraft.client.main.Main.main(Main.java:164)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at GradleStart.bounce(GradleStart.java:108)

at GradleStart.startClient(GradleStart.java:101)

at GradleStart.main(GradleStart.java:56)

Caused by: java.lang.InstantiationException: com.example.examplemod.ExampleMod

at java.lang.Class.newInstance(Unknown Source)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:492)

... 17 more

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_65, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 756250328 bytes (721 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.05 FML v7.10.18.1180 Minecraft Forge 10.13.0.1180 4 mods loaded, 4 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{7.10.18.1180} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed

Forge{10.13.0.1180} [Minecraft Forge] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed

examplemod{1.0} [Example Mod] (bin) Unloaded->Errored

#@!@# Game crashed! Crash report saved to: #@!@# C:\Users\IsMaEeL\Desktop\Forge Mods 1.7.10\eclipse\.\crash-reports\crash-2014-07-23_13.06.05-client.txt

 

 

 

Link to comment
Share on other sites

Don't replace vanilla classes. It seems you are looking for the RenderLivingEvent.

 

i have to use event handler right? you know any good tutorials? and do i use it to call my class instead?

 

My tutorial on events might help: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

 

Basic idea is that you need a handler class that "subscribes" to the event, and you need to register that class as a handler.

 

When the event occurs, you can use the data passed in the event parameter to further determine what happened then do whatever you want.  Depending on the event, many are cancelable, meaning you can totally override what the vanilla code does.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Don't replace vanilla classes. It seems you are looking for the RenderLivingEvent.

 

ok so i read up on event handling and (from what i read) i cant edit or override (am i missing somthing?) the "func_96449_a" method in the "RendererLivingEntity" class

 

 

for example if i edit "func_96449_a" i can make the player nametag green instead of white. in mcp 903 (mc version 1.7.2) i edit the class and was able to run and everything (within eclipse), but it wasnt recompiling or reobfuscating. now i am using forge and want to edit or override that method (preferably from my mod class, i kind of dont want it to be a "coremod"), how do i do that?

 

 

Link to comment
Share on other sites

There are some times when you really need to do a base edit (replace and or modify a minecraft class).

Most of the time you can use events and other cool forge stuff...

 

If really need to edit something what you need to do is make a coremod.

I found is one good tutorial out there...

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571568-tutorial-1-6-2-changing-vanilla-without-editing

 

It is for 1.6.2, but there is still some good info in it!

 

One thing that I thing really helps it to have the forgeSrc not the forgeBin in the classpath thingy in eclipse (or what ever IDE you are using).

You can do this by running...

linux:

./gradlew setupDecompWorkspace

and then ./gradlew eclipse (to update the classpath)

windows:

gradlew setupDecompWorkspace

and then gradlew eclipse

 

and one more note! look at the code that forge uses to load coremods/mods (mostly the coremods part)

 

EDIT: fixed spelling error

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.

×
×
  • Create New...

Important Information

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