Started by
Darkblue0511
on
Topic category: Help with Minecraft modding (Java Edition)
https://blog.naver.com/dohan0511/221317781519
visit my blog to see the screenshot.
NO VIRUSES.Please visit and see the screenshot.
(Can you tell me how to upload a picture? I don't know..)
This code makes error.. how can I fix it?
I want to make this procedure:
heal
wait 1 second
heal
wait 1 second
heal
wait 1 second
heal
wait 1 second
heal
Edited by Darkblue0511 on Thu, 07/12/2018 - 09:16
First of all... if you everytime when you have some error, PASTE THE LOG. That is why the log exist.
Also never use just Thread.sleep(), unless you want to freeze the whole game!e for the time specified, as you are running it from the same thread that controls most of the game. If you want to use that, look into multithreading or make some sort of simple timer or use for example TickHandler.
Also even if I don't know the error you got and I don't use the procedures at all as that can't offer me anything beneficial, the code snippet has wrong formatting - there is a missing semicolon, most likely.
Thank you so much for reply my question.
I recieved your advice.
But.. how can I wait 1 seconds???
:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_bandageelement.java:34: error: ';' expected
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH,(int) 1,(int) 1));Thread.sleep(100)if(entity instanceof EntityLivingBase)
^
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_bandageelement.java:35: error: ';' expected
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH,(int) 1,(int) 1));Thread.sleep(100)if(entity instanceof EntityLivingBase)
^
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_bandageelement.java:36: error: ';' expected
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH,(int) 1,(int) 1));Thread.sleep(100)if(entity instanceof EntityLivingBase)
^
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_bandageelement.java:37: error: ';' expected
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH,(int) 1,(int) 1));Thread.sleep(100)if(entity instanceof EntityLivingBase)
^
4 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.458 secs
C:\Pylo\MCreator179\forge>
Task completed with return code 0 in 11919 milliseconds
You have to use this code:
try{Thread.sleep(100);} catch (InterruptedException e) {e.printStackTrace();}
Basically you can:
it does not work without the try and catch and you forgot the semicolon.
The thing is that if you use it this way, you will prevent the main thread from doing anything, except things like rendering. It can be good when you do some stuffslike reading files on start up but it is definitely not something you want to use in game.
I now.
*know