Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to change Base Class code at runtime?


_vertig0
 Share

Recommended Posts

Ok, I will preface this by saying I know ASM and coremods should only be used when absolutely necessary. I've been trying to remove air resistance from arrows on my server, and this pesky bit of code is always eluding me:

float f2 = 0.99F;
if (this.isInWater()) {
    for(int j = 0; j < 4; ++j) {
        float f4 = 0.25F;
        this.world.addParticle(ParticleTypes.BUBBLE, d5 - d3 * 0.25D, d1 - d4 * 0.25D, d2 - d0 * 0.25D, d3, d4, d0);
    }

    f2 = this.getWaterDrag();
}

this.setMotion(vec3d.scale((double)f2));

float f2 is basically how drag is implemented in arrows. If I could simply delete the line f2 = this.getWaterDrag() and set float f2 = 1.0F, I'd have removed air resistance

 

The problem is that the f2 variable isn't defined in the class, it's defined in the method block. Instantly that completely makes reflection useless. I can't replace AbstractArrowEntity.java with my own Arrow Entity either, because it's a base class diverging out to many different Arrow subclasses. If I did that the server would crash every time a tipped arrow was shot. And I've also tried reverting the drag using LivingUpdateEvent at both end and start phases, and even both phases at once, but all that did was make arrows unusable because they'd fly around randomly after being shot. It seems ASM is my only way forward unfortunately, but Forge has switched the Coremod system and I'm not too sure how to use it

Link to comment
Share on other sites

11 minutes ago, _vertig0 said:

I know ASM and coremods should only be used when absolutely necessary

This doesn't seem like a good use case for ASM.

 

11 minutes ago, _vertig0 said:

LivingUpdateEvent

Thing about this for a second, are arrows living? Of course they aren't, arrows extend Entity and implement IProjectile.

In my opinion you should cancel one of the many events (maybe ArrowLooseEvent?) that references arrows and implement your own physics there.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

3 minutes ago, Novârch said:

This doesn't seem like a good use case for ASM.

 

Thing about this for a second, are arrows living? Of course they aren't, arrows extend Entity and implement IProjectile.

In my opinion you should cancel one of the many events (maybe ArrowLooseEvent?) that references arrows and implement your own physics there.

I'll try that and see if it works, but I suspect it's just going to clash with the base physics in AbstractArrowEntity anyway and go all wonky

 

 

Ah well, who else to blame but Mojang haha

Link to comment
Share on other sites

3 minutes ago, _vertig0 said:

clash with the base physics in AbstractArrowEntity anyway and go all wonky

Maybe you could replace all of the arrow entities entirely? Canceling either the usage of the bow or the spawning of the arrows.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I am trying to add a custom fluid to minecraft in 1.17.1 I need some help and I have asked and searched as many places I could for help on this topic. I made the classes and properties for the fluids but I can't add them to a tag.
    • Would you mind providing me with an example of using the function. I have attached what I tried below, and it just will not show anything on the screen, and will not join the server at all. Just immetitely calls WorldEvent.Unload.   // Try Logging in LoginMod.LOGGER.info("LoginMod is trying to login to " + domain + ":" + port + "!"); ConnectScreen.startConnecting(Minecraft.getInstance().screen, Minecraft.getInstance(), new ServerAddress(domain, port), null);  I believe it does try to connect, I just can't see anything, and I can tell it doesn't actually login. Any clue as to why not? Am I misunderstanding the function?   Also, thanks so much for your help, I have been getting a lot farther than I would have otherwise. Much appreciated!
    • I've been trying to install forge 39.0.6 for a 1.18.1 hosted server, but all the tutorials I found require uploading 3 files (libraries folder, "forge-1.36.5-36.2.20" for example and "minecraft_server.1.16.5" for example, but in 1.18.1 version) that appear when I install forge as a server in a folder. But the problem is, when installing forge 39.0.6 or above in a folder, i don't get that files, so I can't upload them into the server files
    • Is that supposed to happen or...
    • Well, basically every time I open my minecraft to play, this message pops up: I miss playing my game ;-;. I've been trying to solve it for days but I don't know about it. I'll show you the complicated stuff.   Time: 18/01/2022 20:08 Description: Rendering overlay net.minecraftforge.fml.config.ConfigFileTypeHandler$ConfigLoadingException: Failed loading config file forge-common.toml of type COMMON for modid forge     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:61) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:74) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:64) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {}     at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2093) ~[?:?] {}     at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:64) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.core.ModStateProvider.lambda$new$3(ModStateProvider.java:48) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading}     at net.minecraftforge.fml.ModLoader.lambda$dispatchAndHandleError$20(ModLoader.java:200) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at java.util.Optional.ifPresent(Optional.java:178) ~[?:?] {}     at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:200) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.ModLoader.lambda$loadMods$14(ModLoader.java:184) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {}     at net.minecraftforge.fml.ModLoader.loadMods(ModLoader.java:184) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fmlclient.ClientModLoader.lambda$startModLoading$5(ClientModLoader.java:138) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fmlclient.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:129) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fmlclient.ClientModLoader.startModLoading(ClientModLoader.java:138) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fmlclient.ClientModLoader.lambda$onResourceReload$2(ClientModLoader.java:120) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fmlclient.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:129) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading,pl:runtimedistcleaner:A}     at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1800) ~[?:?] {}     at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1792) ~[?:?] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295) ~[?:?] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016) ~[?:?] {}     at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665) ~[?:?] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598) ~[?:?] {}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) ~[?:?] {} Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available     at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.3.jar%238!:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.3.jar%238!:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.3.jar%238!:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.3.jar%238!:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.3.jar%238!:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.3.jar%237!:?] {}     at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.3.jar%237!:?] {}     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:57) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     ... 24 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:61) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:74) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:64) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {}     at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2093) ~[?:?] {}     at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:64) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {}     at net.minecraftforge.fml.core.ModStateProvider.lambda$new$3(ModStateProvider.java:48) ~[forge-1.17.1-37.1.1-universal.jar%2385!:?] {re:classloading}     at net.minecraftforge.fml.ModLoader.lambda$dispatchAndHandleError$20(ModLoader.java:200) ~[fmlcore-1.17.1-37.1.1.jar%2382!:?] {} -- Overlay render details -- Details:     Overlay name: net.minecraft.client.gui.screens.LoadingOverlay Stacktrace:     at net.minecraft.client.renderer.GameRenderer.m_109093_(GameRenderer.java:877) ~[client-1.17.1-20210706.113038-srg.jar%2381!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1039) ~[client-1.17.1-20210706.113038-srg.jar%2381!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:659) ~[client-1.17.1-20210706.113038-srg.jar%2381!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:186) ~[client-1.17.1-20210706.113038-srg.jar%2381!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.1.1.jar%2323!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} -- Last reload -- Details:     Reload number: 1     Reload reason: initial     Finished: No     Packs: Mod Resources, Default -- System Details -- Details:     Minecraft Version: 1.17.1     Minecraft Version ID: 1.17.1     Operating System: Windows 10 (amd64) version 10.0     Java Version: 16.0.1, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 720146952 bytes (686 MiB) / 1375731712 bytes (1312 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 4     Processor Vendor: GenuineIntel     Processor Name: Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz     Identifier: Intel64 Family 6 Model 158 Stepping 9     Microarchitecture: Kaby Lake     Frequency (GHz): 2,50     Number of physical packages: 1     Number of physical CPUs: 4     Number of logical CPUs: 4     Graphics card #0 name: NVIDIA GeForce GTX 1050     Graphics card #0 vendor: NVIDIA (0x10de)     Graphics card #0 VRAM (MB): 4095,00     Graphics card #0 deviceId: 0x1c8d     Graphics card #0 versionInfo: DriverVersion=27.21.14.5167     Graphics card #1 name: Intel(R) HD Graphics 630     Graphics card #1 vendor: Intel Corporation (0x8086)     Graphics card #1 VRAM (MB): 1024,00     Graphics card #1 deviceId: 0x591b     Graphics card #1 versionInfo: DriverVersion=27.20.100.9664     Memory slot #0 capacity (MB): 8192,00     Memory slot #0 clockSpeed (GHz): 2,40     Memory slot #0 type: DDR4     Virtual memory max (MB): 16033,20     Virtual memory used (MB): 7939,68     Swap memory total (MB): 10240,00     Swap memory used (MB): 382,97     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Launched Version: 1.17.1-forge-37.1.1     Backend library: LWJGL version 3.2.2 SNAPSHOT     Backend API: Intel(R) HD Graphics 630 GL version 3.2.0 - Build 27.20.100.9664, Intel     Window size: 854x480     GL Caps: Using framebuffer using OpenGL 3.2     GL debug messages:      Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'forge'     Type: Client (map_client.txt)     Graphics mode: fast     Resource Packs: vanilla     Current Language: English (US)     CPU: 4x Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz     ModLauncher: 9.0.7+91+master.8569cdf     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:           mixin PLUGINSERVICE           eventbus PLUGINSERVICE           object_holder_definalize PLUGINSERVICE           runtime_enum_extender PLUGINSERVICE           capability_token_subclass PLUGINSERVICE           capability_inject_definalize PLUGINSERVICE           accesstransformer PLUGINSERVICE           runtimedistcleaner PLUGINSERVICE           mixin TRANSFORMATIONSERVICE           fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         javafml@null     Mod List:          client-1.17.1-20210706.113038-srg.jar             |Minecraft                     |minecraft                     |1.17.1              |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f         Serene Seasons (Temporadas da vida real no Minecra|Serene Seasons                |sereneseasons                 |1.17.1-5.0.0.7      |COMMON_SET|Manifest: NOSIGNATURE         Lajes Duplas.jar                                  |Double Slabs                  |doubleslabs                   |4.0.0               |COMMON_SET|Manifest: NOSIGNATURE         Placa de sinalização.jar                          |Signpost                      |signpost                      |1.17.1-2.00.4       |COMMON_SET|Manifest: NOSIGNATURE         Domador de animais.jar                            |Animal Tamer                  |rabbit_tamer                  |1.0                 |COMMON_SET|Manifest: NOSIGNATURE         Cinto de ferramentas.jar                          |Tool Belt                     |toolbelt                      |1.17.3              |COMMON_SET|Manifest: NOSIGNATURE         Portas da Arara.jar                               |Macaw's Doors                 |mcwdoors                      |1.0.5               |COMMON_SET|Manifest: NOSIGNATURE         Catálogo.jar                                      |Catalogue                     |catalogue                     |1.5.0               |COMMON_SET|Manifest: NOSIGNATURE         Apenas itens suficientes (JEI).jar                |Just Enough Items             |jei                           |8.3.1.62            |COMMON_SET|Manifest: NOSIGNATURE         Encantamento floral.jar                           |Floral Enchantment            |floralench                    |1.17.1-1.3.1        |COMMON_SET|Manifest: NOSIGNATURE         Flores com sementes.jar                           |Flower Seeds                  |flowerseeds                   |1.17.1-2.0.0        |COMMON_SET|Manifest: NOSIGNATURE         janelas de arara.jar                              |Macaw's Windows               |mcwwindows                    |2.0.2               |COMMON_SET|Manifest: NOSIGNATURE         forge-1.17.1-37.1.1-universal.jar                 |Forge                         |forge                         |37.1.1              |COMMON_SET|Manifest: 22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         AppleSkin.jar                                     |AppleSkin                     |appleskin                     |2.2.0               |COMMON_SET|Manifest: NOSIGNATURE         Aldeões fáceis.jar                                |Easy Villagers                |easy_villagers                |1.17.1-1.0.9        |COMMON_SET|Manifest: NOSIGNATURE         Painel no vidro.jar                               |Pane In The Glass             |pitg                          |1.17.1-2.0.1        |COMMON_SET|Manifest: NOSIGNATURE         Deterioração Rápida das Folhas.jar                |FastLeafDecay                 |fastleafdecay                 |26.2                |COMMON_SET|Manifest: NOSIGNATURE         Acorrentado.jar                                   |Leashed                       |leashed                       |1.2.2               |COMMON_SET|Manifest: NOSIGNATURE         Baús de Ferro.jar                                 |Iron Chests                   |ironchest                     |1.17.1-12.0.2       |COMMON_SET|Manifest: NOSIGNATURE         Apenas mais um mod de carne podre para couro.jar  |JRFTL                         |jrftl                         |1.3                 |COMMON_SET|Manifest: NOSIGNATURE         Sentar em lajes e escadas como cadeiras.jar       |Sit                           |sit                           |1.3.1               |COMMON_SET|Manifest: NOSIGNATURE     Crash Report UUID: aff87ccb-2016-45da-9ffc-a5768134151b     FML: 37.1     Forge: net.minecraftforge:37.1.1
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.