Jump to content

[1.6.4] Some code isn't accessed


hotrods20

Recommended Posts

So, when I'm trying to add "power" to the overall power, the code just skips the adding part and just does as it pleases.

 

BlockPowerProducer

public boolean onBlockActivated(World world, int par2, int par3, int par4, EntityPlayer player, int par6, float par7, float par8, float par9)
{
	if(this.ownerNeedSet)
	{
		this.playerOwner = player.username;
		PlayerPower prop = PlayerPower.get(player);
		prop.addPower(power);
		this.ownerNeedSet = false;
	}
	if(player.username.equals(this.playerOwner))
		if(!world.isRemote)
		{
			TileEntityPP pp = (TileEntityPP) world.getBlockTileEntity(par2, par3, par4);
			pp.outputPower(player, world);
		}
	player.addChatMessage("Owner is: " + this.playerOwner);
	return true;
}

 

The problem in here is that the owner is set but the "power" is never added.

 

PlayerPower.class implements IExtendedEntityProperties

public void addPower(long power)
{
	this.currentPower = this.currentPower + power;
}

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

Extensive testing shows that the code does get called but the power never gets added even though power can be removed and without putting prop.addPower(int) in the if statement in the BlockPowerProducer lets power be generated.  The question seems to be is why doesn't the power work when used in the if statement?

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

this.currentPower = this.currentPower + power;

More efficient code:

this.currentPower += power;

 

Usually the two compile to the same thing.  += is faster to type though.

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

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.