Jump to content

Recommended Posts

Posted

I am worrking on an addon for Botania.

The game does not crash and nothing appears in the log, but here it is anyway:

  Reveal hidden contents

Here is my Pylon tile entity(supplying power)

  Reveal hidden contents

and finally the user:

  Reveal hidden contents

What happens is, it just drops out, no log,mouse not working, nothing.

It always drops out right as the spawning finishes(update>isSpawning>mana_remove_left at the bottom of TileManaSpawner)

This is also a major setback, because most things use crystal pylons for power.

If you can help Thanks!  :D 

 

In action, right before crash:

2017-09-19_16_46_24.png.efb1b49856417e012f056781fb11d445.png

Posted

That means you have an infinite loop somewhere. Start using breakpoints.

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

No

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
  On 9/19/2017 at 11:48 PM, GiantNuker said:

do {

for (TileCrystalPylon pylon : pylons) {

if (!pylon.canDrawFrom(user)) {

pylons.remove(pylon);

continue;

}

mana = pylon.takeMana(1);

}

} while(mana > 0 && pylons.size() > 0);

Expand  

 

These loops are suspicious, esp since the takeMana method can return mana unchanged. Set a breakpoint entering the loop and step through.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted
  On 9/20/2017 at 7:08 PM, jeffryfisher said:

 

These loops are suspicious, esp since the takeMana method can return mana unchanged. Set a breakpoint entering the loop and step through.

Expand  
public boolean canDrawFrom(BlockPos pos) {
		updateUseability(true);
		if (this.activated != EnumActivation.OFF && this.centerPos != pos) return false;
		if (this.bind != EnumBinding.OUTPUT_ALL && this.boundPos != pos) return false;
		/*Look Here*/							if (this.getCurrentMana() <= 0) return false; //<--Look Here!
		//RayTraceResult res = this.world.rayTraceBlocks(new Vec3d(this.pos), new Vec3d(pos), false, true, false);
		//if (res != null)if (res.hitVec.x != pos.getX() || res.hitVec.y != pos.getY() || res.hitVec.z != pos.getZ()) return false;
		
		return true;
	}

Line 5 of canDrawFrom.

Posted

Ok, what about that line?

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)
  On 9/20/2017 at 7:08 PM, jeffryfisher said:

Set a breakpoint entering the loop and step through.

Expand  

You haven't done this yet.

Edited by Draco18s

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

You should eliminate the case where nothing changes during the loop which calls for the infinite loop.

Here, takeMana can return mana unchanged in the loop. It shouldn't be doing that.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 9/21/2017 at 12:29 AM, Abastro said:

You should eliminate the case where nothing changes during the loop which calls for the infinite loop.

Here, takeMana can return mana unchanged in the loop. It shouldn't be doing that.

Expand  
if (!pylon.canDrawFrom(user)) {
					pylons.remove(pylon);
					continue;
				}

canDrawFrom has this line

if (this.getCurrentMana() <= 0) return false;

getCurrenMana & hasPool

public boolean hasPool() {
		return world.getTileEntity(pos.down()) instanceof IManaPool;
	}
	
	public int getCurrentMana() {
		if (!hasPool()) return 0;
		return ((IManaPool)world.getTileEntity(pos.down())).getCurrentMana();
	}

 

Posted
  On 9/20/2017 at 11:36 PM, Draco18s said:
  On 9/20/2017 at 7:08 PM, jeffryfisher said:

Set a breakpoint entering the loop and step through.

Expand  

You haven't done this yet.

Expand  

I'll keep quoting this until you do it.

 

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
  On 9/21/2017 at 1:50 AM, Draco18s said:

I'll keep quoting this until you do it.

 

Expand  

Did It.

I also changed method contents to

List<TileCrystalPylon> a = new ArrayList();
		a.addAll(pylons);
		do {
			for (TileCrystalPylon pylon : a) {
				if (pylons.size() < 1) return mana;
				if (mana < 0) break;
				if (!pylon.canDrawFrom(user)) {
					pylons.remove(pylon);
					continue;
				}
				mana = pylon.takeMana(1);
			}
		} while(mana > 0);
		/*do {
			for (TileCrystalPylon pylon : pylons) {
				if (!pylon.canDrawFrom(user)) {
					pylons.remove(pylon);
					continue;
				}
				mana = pylon.takeMana(mana);
			}
		} while(mana > 0 && pylons.size() > 0);*/
		return mana;

It still is not working.

Posted (edited)

Then there's still a problem and you still need to debug it.
"Not working" tells us nothing.

Edited by Draco18s

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
  On 9/21/2017 at 1:27 AM, GiantNuker said:
if (!pylon.canDrawFrom(user)) {
					pylons.remove(pylon);
					continue;
				}

canDrawFrom has this line

if (this.getCurrentMana() <= 0) return false;

getCurrenMana & hasPool

public boolean hasPool() {
		return world.getTileEntity(pos.down()) instanceof IManaPool;
	}
	
	public int getCurrentMana() {
		if (!hasPool()) return 0;
		return ((IManaPool)world.getTileEntity(pos.down())).getCurrentMana();
	}

 

Expand  

What do you want to say by that? Still the takeMana method can return unchanged value, e.g. when the pylon is off.

I guess there could be more bugs causing strange effects. So you should know how to debug, which is basic java skill as well.

So. Do you know basic java?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 9/21/2017 at 6:26 AM, Abastro said:

What do you want to say by that? Still the takeMana method can return unchanged value, e.g. when the pylon is off.

I guess there could be more bugs causing strange effects. So you should know how to debug, which is basic java skill as well.

So. Do you know basic java?

Expand  

Yes, but I've never used eclipse debug tools, always System.out.println()

 

What I've been trying to get at is, the output of takemana should not mean anything, because every iteration, canDrawFrom is called, and that checks if there is any mana left in the pool, if not it returns false, and when that returns false, it is removed from the pylons list, when that list is empty, the method exits(if (pylons.size() < 1) return mana;)

Posted
  On 9/21/2017 at 4:12 PM, GiantNuker said:

Yes, but I've never used eclipse debug tools, always System.out.println()

 

What I've been trying to get at is, the output of takemana should not mean anything, because every iteration, canDrawFrom is called, and that checks if there is any mana left in the pool, if not it returns false, and when that returns false, it is removed from the pylons list, when that list is empty, the method exits(if (pylons.size() < 1) return mana;)

Expand  

also,  don't think that's the problem because It did not work with this algorithm either.

do {
			for (TileCrystalPylon pylon : pylons) {
				if (!pylon.canDrawFrom(user)) {
					pylons.remove(pylon);
					continue;
				}
				mana = pylon.takeMana(mana);
			}
		} while(mana > 0 && pylons.size() > 0);

 

Posted
  On 9/21/2017 at 4:12 PM, GiantNuker said:

I've never used eclipse debug tools, always System.out.println()

Expand  

Well then it's time for you to become familiar and comfortable with the debugger. Force yourself to dive in, play with step, step-into and step-over. Look at local variables and class fields as they change. Set breakpoints so you can skip ahead. Figure out where your program is getting stuck by sneaking up on it.

 

PS: Is it kosher to remove a pylon from pylons while iterating the list? I vaguely recall that there's a right way and a wrong way to do it. Make sure you're doing it the right way.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted
  On 9/21/2017 at 6:08 PM, jeffryfisher said:

Well then it's time for you to become familiar and comfortable with the debugger. Force yourself to dive in, play with step, step-into and step-over. Look at local variables and class fields as they change. Set breakpoints so you can skip ahead. Figure out where your program is getting stuck by sneaking up on it.

 

PS: Is it kosher to remove a pylon from pylons while iterating the list? I vaguely recall that there's a right way and a wrong way to do it. Make sure you're doing it the right way.

Expand  

I got a concurrent modifocation exception, so I created another list, then iterated through that, but I think it would be faster if I just did a for(int i = 0; i < pylons.size(); i++).

 

Thanks!

Posted

If you iterate from 0 to size, and remove one, you'll skip over another.

If you want to be able to modify the list while you're looping over it, you should use an iterator.

  • Like 1

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.

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.