Jump to content

Recommended Posts

Posted

So, I have a solar panel with a GUI. Everything is working apart from one thing, theres a blank space for a sun in the GUI. That blank space is ment to go yellow when it can see the sun. Well, if there is a block covering it, it will go blank and visa versa. However, if it's nighttime, it will stay yellow. Is there any fixes? !isRemote just makes it go blank completely.

 

TileEntitySolar:

 

 

  Reveal hidden contents

 

 

 

GUISolar:

 

 

  Reveal hidden contents

 

Posted

So I do !world.isRemote? If so it dosen't work when I wrap the gen sees sun method in it. I did this though and it still dosent work:

 

public boolean genSeesSun(){

if(!worldObj.isRemote){

if(worldObj.isDaytime()){

return (((!worldObj.isRaining() && !worldObj.isThundering() && worldObj.isDaytime()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord));

}

 

 

}else{

return ( worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering() && worldObj.isDaytime()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord));

}

return  ( worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering() && worldObj.isDaytime()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord));

}

Posted

> genSeesSun() is running only server side, GUI is client-side.

 

Just do this:

 

if(worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord));
{
this.drawTexturedModalRect(guiLeft + 117, guiTop + 63, 176, 50, 14, 14);
}

or insert the function in the GUI.. or make a class with some "generic" functions to use around your mod...

 

or change getSeesSun() (probably it will fix too):

 

public boolean genSeesSun()
{
      return (worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord));

}

 

 

Using "side filters" ("world.isremote()", etc) can make some problems depending what you change.

// BSc CIS, hardcore gamer and a big fan of Minecraft.

 

TmzOS ::..

Posted

> fixed the bold tag inside the first code

 

--

 

There are any exception in the log?

 

Did you adapted the code from the TE to the GUI (that means, "isdesert()" for example is local to the TE but not to the GUI)?

 

 

Show me what you changed exactly and what is happening with the changes.

 

 

// BSc CIS, hardcore gamer and a big fan of Minecraft.

 

TmzOS ::..

Posted

I changed:

 

What I had before in the GUI to:

 

 

  Reveal hidden contents

(Ill add isDesert() later)

 

I changed the tileentity to:

 

 

  Reveal hidden contents

 

Posted

If you look into isDaytime, you find that it operates on light level. Unless you care about weather effects (which can turn day into night), use world time to get canonical sunrise and sunset. There are 24000 ticks in a day, starting with dawn at time=0 on the 1st day. From that you can calculate using modulo (and remainder) arithmetic, and it even works in the nether and end (unless you test for those and rule them out).

 

On the other hand, if your solar panel needs to respond to light levels, then you should probably use skylight directly.

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 3/25/2016 at 7:01 PM, jeffryfisher said:

On the other hand, if your solar panel needs to respond to light levels, then you should probably use skylight directly.

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.