Jump to content

Recommended Posts

Posted (edited)

Hey!

I keep taking glances at the Referenced Libraries and the code in them and they have a style that I personally adapted, but I just space everything out myself when coding. I was wondering if there is any way to have line breaks between the beginning and end of block codes. For instance:

	/* Event fired when an entity dies */
	@SubscribeEvent(priority = EventPriority.HIGHEST)
	public void onLivingDeath(LivingDeathEvent event)
	{
		if (event.getEntityLiving() instanceof EntityLiving)
		{
			EntityLiving entity = (EntityLiving) event.getEntityLiving();
			entity.playSound(SoundEvents.BLOCK_METAL_BREAK, 1.0F, 1.0F);
			
			for (int i = 0; i < 50; ++i) //line break above
			{
				entity.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, 
					  entity.posX, entity.posY + (entity.height - 0.25D), entity.posZ, 
					  Math.random() * 0.2D - 0.1D, Math.random() * 0.25D, Math.random() * 0.2D - 0.1D, 
					  Block.getIdFromBlock(Blocks.REDSTONE_BLOCK)
				   );
			}//line break below
          
			if (...)
			{
				...
			}
          
			try
			{

			}
			catch(...)
			{
				... 
			}
		}
	}

I've been trying to accomplish this for a lot of time, yet no success.

Any ideas?

Thanks!

Edited by Differentiation
Posted

I don't think that's something that can be controlled by automatic code formatting. :\

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.

Posted (edited)
3 minutes ago, Draco18s said:

I don't think that's something that can be controlled by automatic code formatting. :\

aw, that's a bummer, is there any other way to format it this way other than doing it manually? :/

It's a pain xD

Edited by Differentiation
Posted (edited)

Both Eclipse and IntelliJ can do a lot of automatic formatting. If modders want the formatter XML template file that does all the indenting and braces and stuff they can get it from the ForgeEssentials github project here: https://github.com/ForgeEssentials/ForgeEssentials/tree/develop/misc

 

Now the formmater doesn't cover the specific question for this thread about blank lines after a for loop. But that can be set in Window/Preferences/Java/Editor/Template settings. Just add a blank line at the end of the ones you want and make sure you enable them to insert automatically. Ideally you can name the templates something unique like "myIf" so then you just can hit CTRL+Space while typing and it will fill in for you.

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.

Announcements



×
×
  • Create New...

Important Information

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