Jump to content

Automatic Aiming Stutter


FreakzBoy

Recommended Posts

Hello, i was working on my minecraft client trying to make an automatic entity facing module and it works perfectly fine. The only problem that is bothering me is that there are stutters in between the yaw updating of the player which I don't know the reason to. The code is from this youtube video:  Facing smoothly

 

Here is a clip of it ingame to understand my problem more easily: Facing Stuttery (My version)

 

It's a bit strange, since for the guy in the video its running smoothly.

 

Here's the code:

 

	@EventTarget
	public void update(EventUpdate e) {
		
		
		ticks1 += 1;
		
		for(Iterator<Object> entities = mc.theWorld.loadedEntityList.iterator(); entities.hasNext();) {
            Object theObject = entities.next();
            if(theObject instanceof EntityLivingBase) {
	                EntityLivingBase entityplayer = (EntityLivingBase) theObject;
	               
	            if(entityplayer.getName() == mc.thePlayer.getName()){
	                continue;
	            }
	            
	            if(entityplayer instanceof EntityPig) {
	            
	            	if(mc.thePlayer.getDistanceSqToEntity(entityplayer) <= 10F) {
	            		
	            		this.faceEntity(entityplayer);
	            	}
	            		
	            }
            
            }	
		}
		
		
	}
	
	public static float[] getRotationsNeeded(Entity entity)
    {
        if(entity == null)
            return null;
        double diffX = entity.posX - Minecraft.getMinecraft().thePlayer.posX;
        double diffY;
        if(entity instanceof EntityLivingBase)
        {
            EntityLivingBase entityLivingBase = (EntityLivingBase)entity;
            diffY =
                entityLivingBase.posY
                    + entityLivingBase.getEyeHeight()
                    * 0.9
                    - (Minecraft.getMinecraft().thePlayer.posY + Minecraft
                        .getMinecraft().thePlayer.getEyeHeight());
        }else
            diffY =
                (entity.boundingBox.minY + entity.boundingBox.maxY)
                    / 2.0D
                    - (Minecraft.getMinecraft().thePlayer.posY + Minecraft
                        .getMinecraft().thePlayer.getEyeHeight());
        double diffZ = entity.posZ - Minecraft.getMinecraft().thePlayer.posZ;
        double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ);
        float yaw =
            (float)(Math.atan2(diffZ, diffX) * 180.0 / Math.PI) - 90.0F;
        float pitch = (float)-(Math.atan2(diffY, dist) * 180.0 / Math.PI);
        return new float[]{
            Minecraft.getMinecraft().thePlayer.prevCameraYaw
                + MathHelper.wrapAngleTo180_float(yaw
                    - Minecraft.getMinecraft().thePlayer.prevCameraYaw),
            Minecraft.getMinecraft().thePlayer.rotationPitch
                + MathHelper.wrapAngleTo180_float(pitch
                    - Minecraft.getMinecraft().thePlayer.rotationPitch)};
       
    }
   
    public static void faceEntity(EntityLivingBase entity)
      {
    	float[] rotations = getRotationsNeeded(entity);
        if (rotations != null)
        {
            Minecraft.getMinecraft().thePlayer.rotationYaw = rotations[0];
            Minecraft.getMinecraft().thePlayer.rotationPitch = rotations[1] + 1;
        }
    }

 

I would really appreciate it if someone would help me out with my problem!

The person that will help me gets a cookie ?

 

Best Regards,

Freakz :)

Link to comment
Share on other sites

You aren't properly handling "partial ticks." Remember, ticks (game processing) are 20 times per second, but the rendering can be anywhere from 30 to 120 times a second.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

You aren't properly handling "partial ticks." Remember, ticks (game processing) are 20 times per second, but the rendering can be anywhere from 30 to 120 times a second.

Thank you for your quick response, so the reason regarding to the stutter, is my update() method with the EventUpdate e that is calling my faceEntity only 20 times a second?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • when i do the same on my pc it works
    • Use your IDE for this. For example, if you are using "IntelliJ IDEA" and you correctly setup your project (jdk, forge mdk, gradle, parchment, etc.), then you can just use Ctrl + B with Block type selected. It will navigate you to class declaration.
    • I need help, my forge server crashes and i don't know where is the problem.    [25sep2023 14:24:30.772] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.4, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, /home/luka/.local/share/atlauncher/runtimes/minecraft/jre-legacy/linux/jre-legacy/bin/java nogui] [25sep2023 14:24:30.777] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_202 by Oracle Corporation [25sep2023 14:24:31.055] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [25sep2023 14:24:31.098] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/home/luka/.local/share/atlauncher/servers/Darksouls/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [25sep2023 14:24:32.824] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.performant.coremod.mixin.Connector] [25sep2023 14:24:32.835] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, ., /home/luka/.local/share/atlauncher/runtimes/minecraft/jre-legacy/linux/jre-legacy/bin/java nogui] [25sep2023 14:24:32.898] [main/INFO] [com.performant.coremod.Performant/]: Performant configs loaded [25sep2023 14:24:32.996] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/renderer/GameRenderer for invalid dist DEDICATED_SERVER [25sep2023 14:24:32.997] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/GameRenderer (java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/GameRenderer for invalid dist DEDICATED_SERVER) [25sep2023 14:24:32.999] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.renderer.GameRenderer was not found shouldersurfing.mixins.json:MixinGameRenderer [25sep2023 14:24:33.011] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/GameSettings for invalid dist DEDICATED_SERVER [25sep2023 14:24:33.011] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/GameSettings (java.lang.RuntimeException: Attempted to load class net/minecraft/client/GameSettings for invalid dist DEDICATED_SERVER) [25sep2023 14:24:33.012] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.GameSettings was not found shouldersurfing.mixins.json:MixinGameSettings [25sep2023 14:24:33.034] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/gui/IngameGui for invalid dist DEDICATED_SERVER [25sep2023 14:24:33.035] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/gui/IngameGui (java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/IngameGui for invalid dist DEDICATED_SERVER) [25sep2023 14:24:33.035] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.gui.IngameGui was not found shouldersurfing.mixins.json:MixinIngameGui [25sep2023 14:24:33.128] [main/WARN] [mixin/]: Error loading class: net/optifine/shaders/ShadersRender (java.lang.ClassNotFoundException: null) [25sep2023 14:24:33.130] [main/WARN] [mixin/]: @Mixin target net.optifine.shaders.ShadersRender was not found shouldersurfing.mixins.json:MixinShadersRender [25sep2023 14:24:33.678] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.forge.BasicEventHooksMixin as config disables it. [25sep2023 14:24:33.706] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.entity.LivingEntityUpdateEventMixin as config disables it. [25sep2023 14:24:33.796] [main/WARN] [mixin/]: @Mixin target net/minecraft/world/server/ChunkManager$EntityTracker is public in performant.mixins.json:world.chunk.ChunkManagerEntityTrackMixin and should be specified in value [25sep2023 14:24:34.092] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class com/teamderpy/shouldersurfing/config/Config$ClientConfig for invalid dist DEDICATED_SERVER [25sep2023 14:24:34.092] [main/WARN] [mixin/]: Error loading class: com/teamderpy/shouldersurfing/config/Config$ClientConfig (java.lang.RuntimeException: Attempted to load class com/teamderpy/shouldersurfing/config/Config$ClientConfig for invalid dist DEDICATED_SERVER) [25sep2023 14:24:35.634] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER [25sep2023 14:24:35.634] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/Minecraft (java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [25sep2023 14:24:35.637] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [25sep2023 14:24:35.637] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 7 more [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:223) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinTransformationHandler.processClass(MixinTransformationHandler.java:121) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.launch.MixinLaunchPlugin.processClass(MixinLaunchPlugin.java:131) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:154) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.block.Blocks.<clinit>(Blocks.java:30) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.world.gen.surfacebuilders.SurfaceBuilder.<clinit>(SurfaceBuilder.java:12) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilders.<clinit>(SourceFile:11) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.func_243674_g(WorldGenRegistries.java:33) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.func_243668_a(WorldGenRegistries.java:89) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.<clinit>(WorldGenRegistries.java:88) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.Registry.<clinit>(Registry.java:464) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.Bootstrap.func_151354_b(Bootstrap.java:38) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.server.Main.main(Main.java:92) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     ... 13 more [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]: Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: net.minecraft.client.Minecraft [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:741) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:726) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:297) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:267) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1271) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:287) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:569) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     ... 33 more
    • How can I see the Minecraft Blocks source code?
    • I have installed a minecraft 1.12.2 server and java 8, but the forge-blahblahblah.jar file isnt doing anything, the minecraft server file is opening the server but as expacted, it just launches a vanilla server
  • Topics

×
×
  • Create New...

Important Information

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