Jump to content

Animation when Entity collides with Player


LevelBlock

Recommended Posts

Hi. I'm looking to display an animation when an entity collides with the Player, I'm using geckolib. I haven't find a properly way to implement this on the "event.getAnimatable()". Somebody can help with a tip?

 private <E extends Entity & IAnimatable> PlayState predicate(AnimationEvent<E> event) {

        LivingEntity livingEntity = event.getExtraDataOfType(LivingEntity.class).get(0);

        if (event.isMoving()) {
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.walk", true));
            return PlayState.CONTINUE;
        }
        if (event.getAnimatable().horizontalCollision){
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.attack", true));
            return PlayState.CONTINUE;
        }
        if(!event.isMoving())
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.idle", true));
        return PlayState.CONTINUE;
    }

 

Link to comment
Share on other sites

Entity.horizontalCollision is for colliding with blocks.

Minecraft doesn't really do entity/entity collision, except in special cases like item pickup. Those are not events with state stored in the entity, its a special process that uses one of the level.getEntities() search methods. Those won't be appropriate to call during rendering.

  • Like 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

4 hours ago, warjort said:

Entity.horizontalCollision is for colliding with blocks.

Minecraft doesn't really do entity/entity collision, except in special cases like item pickup. Those are not events with state stored in the entity, its a special process that uses one of the level.getEntities() search methods. Those won't be appropriate to call during rendering.

Thanks for the answer, so I should look for an EntityDataAccesor or try with another kind of event like distance between entities?

Link to comment
Share on other sites

I am saying there is no data to access for entity/entity collisions, minecraft does not track it.

And doing an entity search during rendering will likely affect fps.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

It looks like you really want to know when an entity is attacked from your code?

You might be able to do some tracking yourself with forge's LivingHurtEvent and looking at the DamageSource. Maybe storing the state using a Capability on the entity? 

Edited by warjort
  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

2 minutes ago, warjort said:

It looks like you really want to know when an entity is attacked from your code?

You might be able to do some tracking yourself with forge's LivingHurtEvent and looking at the DamageSource? Maybe storing the state using a Capability on the entity? 

I'm gonna try , thanks a lot.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried installing several mods that improves fps with other several gameplay mods that i have added previously and tested to be playable. But when I have added the new mods that improves the fps, Java crashes. (version is 1.20.1)   Here is the crash log:    ---- Minecraft Crash Report ---- // But it works on my machine. Time: 2023-12-08 17:22:22 Description: Initializing game java.lang.IncompatibleClassChangeError: class net.coderbot.iris.gui.option.ShadowDistanceOption cannot inherit from final class net.minecraft.client.OptionInstance     at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] {}     at java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:119) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) ~[securejarhandler-2.1.10.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?] {}     at net.coderbot.iris.config.IrisConfig.load(IrisConfig.java:142) ~[oculus-mc1.20.1-1.6.9.jar%23179!/:?] {re:classloading}     at net.coderbot.iris.config.IrisConfig.initialize(IrisConfig.java:58) ~[oculus-mc1.20.1-1.6.9.jar%23179!/:?] {re:classloading}     at net.coderbot.iris.Iris.onEarlyInitialize(Iris.java:146) ~[oculus-mc1.20.1-1.6.9.jar%23179!/:?] {re:mixin,re:classloading}     at net.minecraft.client.Options.handler$zgi000$iris$beforeLoadOptions(Options.java:1430) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.oculus.json:MixinOptions_Entrypoint,pl:mixin:APP:mixins.oculus.fixes.maxfpscrash.json:MixinMaxFpsCrashFix,pl:mixin:APP:mixins.oculus.json:sky.MixinOptions_CloudsOverride,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Options.m_92140_(Options.java) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.oculus.json:MixinOptions_Entrypoint,pl:mixin:APP:mixins.oculus.fixes.maxfpscrash.json:MixinMaxFpsCrashFix,pl:mixin:APP:mixins.oculus.json:sky.MixinOptions_CloudsOverride,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Options.<init>(Options.java:888) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.oculus.json:MixinOptions_Entrypoint,pl:mixin:APP:mixins.oculus.fixes.maxfpscrash.json:MixinMaxFpsCrashFix,pl:mixin:APP:mixins.oculus.json:sky.MixinOptions_CloudsOverride,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:425) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:rubidium_extras.mixins.json:FrameCounter.FpsAccessorMixin,pl:mixin:APP:rubidium.mixins.json:core.MinecraftClientMixin,pl:mixin:APP:mixins.oculus.json:MixinMinecraft_PipelineManagement,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:182) ~[1.20.1-forge-47.2.0.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) ~[fmlloader-1.20.1-47.2.0.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99) ~[fmlloader-1.20.1-47.2.0.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25) ~[fmlloader-1.20.1-47.2.0.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:108) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:78) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] {}     at java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[?:?] {}     at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:119) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) ~[securejarhandler-2.1.10.jar:?] {}     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) ~[securejarhandler-2.1.10.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?] {}     at net.coderbot.iris.config.IrisConfig.load(IrisConfig.java:142) ~[oculus-mc1.20.1-1.6.9.jar%23179!/:?] {re:classloading}     at net.coderbot.iris.config.IrisConfig.initialize(IrisConfig.java:58) ~[oculus-mc1.20.1-1.6.9.jar%23179!/:?] {re:classloading}     at net.coderbot.iris.Iris.onEarlyInitialize(Iris.java:146) ~[oculus-mc1.20.1-1.6.9.jar%23179!/:?] {re:mixin,re:classloading}     at net.minecraft.client.Options.handler$zgi000$iris$beforeLoadOptions(Options.java:1430) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.oculus.json:MixinOptions_Entrypoint,pl:mixin:APP:mixins.oculus.fixes.maxfpscrash.json:MixinMaxFpsCrashFix,pl:mixin:APP:mixins.oculus.json:sky.MixinOptions_CloudsOverride,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Options.m_92140_(Options.java) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.oculus.json:MixinOptions_Entrypoint,pl:mixin:APP:mixins.oculus.fixes.maxfpscrash.json:MixinMaxFpsCrashFix,pl:mixin:APP:mixins.oculus.json:sky.MixinOptions_CloudsOverride,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Options.<init>(Options.java:888) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.oculus.json:MixinOptions_Entrypoint,pl:mixin:APP:mixins.oculus.fixes.maxfpscrash.json:MixinMaxFpsCrashFix,pl:mixin:APP:mixins.oculus.json:sky.MixinOptions_CloudsOverride,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:425) ~[client-1.20.1-20230612.114412-srg.jar%23189!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:rubidium_extras.mixins.json:FrameCounter.FpsAccessorMixin,pl:mixin:APP:rubidium.mixins.json:core.MinecraftClientMixin,pl:mixin:APP:mixins.oculus.json:MixinMinecraft_PipelineManagement,pl:mixin:A,pl:runtimedistcleaner:A} -- Initialization -- Details:     Modules:  Stacktrace:     at net.minecraft.client.main.Main.main(Main.java:182) ~[1.20.1-forge-47.2.0.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) ~[fmlloader-1.20.1-47.2.0.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99) ~[fmlloader-1.20.1-47.2.0.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25) ~[fmlloader-1.20.1-47.2.0.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:108) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:78) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] {} -- System Details -- Details:     Minecraft Version: 1.20.1     Minecraft Version ID: 1.20.1     Operating System: Mac OS X (aarch64) version 14.1.2     Java Version: 17.0.8, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 285189552 bytes (271 MiB) / 536870912 bytes (512 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 8     Processor Vendor: Apple Inc.     Processor Name: Apple M1     Identifier: Apple Inc. Family 0x1b588bb3 Model 0 Stepping 0     Microarchitecture: ARM64 SoC: Firestorm + Icestorm     Frequency (GHz): 3.20     Number of physical packages: 1     Number of physical CPUs: 8     Number of logical CPUs: 8     Graphics card #0 name: Apple M1     Graphics card #0 vendor: Apple (0x106b)     Graphics card #0 VRAM (MB): 0.00     Graphics card #0 deviceId: unknown     Graphics card #0 versionInfo: unknown     Memory slot #0 capacity (MB): 0.00     Memory slot #0 clockSpeed (GHz): 0.00     Memory slot #0 type: unknown     Virtual memory max (MB): 11264.00     Virtual memory used (MB): 7656.59     Swap memory total (MB): 3072.00     Swap memory used (MB): 1509.94     JVM Flags: 7 total; -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Launched Version: 1.20.1-forge-47.2.0     Backend library: LWJGL version 3.3.1 build 7     Backend API: Unknown     Window size: <not initialized>     GL Caps: Using framebuffer using OpenGL 3.2     GL debug messages: <disabled>     Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'forge'     Type: Client (map_client.txt)     CPU: <unknown>
    • I have created a mod which applies x shader to the player after consuming x item for a certain time, but if the player presses f5 to change the camera the shader stops working. The only way I have found to prevent the shader from being deactivated is to load it on all ticks until it is disabled but this greatly reduces the performance of the game. I have also tried to cancel the event of changing the camera but this is not cancelable. Any advice, I've been trying to solve this for several days 😵‍💫  
    • Minecraft 1.20.1 Forge 47.2.0 log and crash report: https://pastebin.com/P7tQymQS ; (crash report) I launch the game and i got this error: Someone could help me please?  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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