Jump to content

thisisatest

Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

thisisatest's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thank for you for your response; I followed your advice. On execution, however, the while loop produced, for a few seconds before crashing, a 1.57GB file filled with lines stating the player's initial assigned velocity (2.0). To fix this, I think I would like to have this velocity measurement run every 5 ticks or so. I've read about Forge's TickEvent - I frankly don't know how to use it though. Here is my code: public void onLanded(World worldIn, Entity entityIn) { if (entityIn.isSneaking()) { super.onLanded(worldIn, entityIn); } else if (entityIn.motionY < 0.0D) { entityIn.motionY = 2; entityIn.motionX = 0; try{ File file = new File("data_log.txt"); if(!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file); PrintWriter pw = new PrintWriter(fw); double start = worldIn.getTotalWorldTime(); while(entityIn.collidedVertically != true) { if(worldIn != null && (worldIn.getWorldTime() - start) % 5 == 0) { pw.println(entityIn.motionY); } } pw.close(); } catch(IOException e) {e.printStackTrace();} if (!(entityIn instanceof EntityLivingBase)) { entityIn.motionY *= 0.0D; } } }
  2. I've made a player "springboard" that launches them into the air. I want to log the player's velocity every 5 ticks and log it all neatly in a text file after which you could plug the data in Logger Pro and graph it. I am having trouble doing this and as a novice programmer have this mess below: public void onLanded(World worldIn, Entity entityIn) { if (entityIn.isSneaking()) { super.onLanded(worldIn, entityIn); } else if (entityIn.motionY < 0.0D) { entityIn.motionY = 2; entityIn.motionX = 0; try{ File file = new File("data_log.txt"); if(!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file); PrintWriter pw = new PrintWriter(fw); pw.println(entityIn.motionY); //World world = Minecraft.getMinecraft().world; //double start = world.getTotalWorldTime(); //while(entityIn.motionY != 0) { //if(world != null && (world.getWorldTime() - start) % 5 == 0) { pw.println(entityIn.motionY); //} //} pw.close(); } catch(IOException e) {e.printStackTrace();} if (!(entityIn instanceof EntityLivingBase)) { entityIn.motionY *= 0.0D; }}} ~The commented sections cause a crash~
×
×
  • Create New...

Important Information

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