Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

It's not location specific.  This isn't like BC or IC.  Different power system.  Decentralized.  The "power" variable starts at 0 and changes based on structures that need power or produce 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.

  • Author

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.

Probably the "power" value is always 0.

All the power variables things shouldn't be in a block class.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.