Opps I just realized I was in the wrong method. Anyway I got it to work when it's daytime but it still works at night. I tried an else statment with power = 0; but that failed to work. Here is my code
In the updateEntity() method
if (this.worldObj != null && !this.worldObj.isRemote && this.worldObj.getTotalWorldTime() % 20L == 0L)
{
power = 1;
}
The actual burn time method
public static int getItemBurnTime(ItemStack itemstack){
return power;
}
Opps I just realized I was in the wrong method. Anyway I got it to work when it's daytime but it still works at night. I tried an else statment with power = 0; but that failed to work. Here is my code
In the updateEntity() method
if (this.worldObj != null && !this.worldObj.isRemote && this.worldObj.getTotalWorldTime() % 20L == 0L)
{
power = 1;
}
The actual burn time method
public static int getItemBurnTime(ItemStack itemstack){
return power;
}
The variable
public static int power;
Don't use static modifiers when making that block do something different every time. As I said before, please learn about static modifiers before using them.
Here is my Full UpdateEntity Method. I am using light value now and I made a print line to tell me what the blocks light value it. Uncovered at day it registers a 1.0 and at night or covered it registers a ~0.6.
public void updateEntity() {
if (this.worldObj != null && !this.worldObj.isRemote && this.worldObj.getLightBrightness(xCoord, yCoord, zCoord) == 1f)
{
power = 1;
}
if (this.worldObj != null && !this.worldObj.isRemote && this.worldObj.getLightBrightness(xCoord, yCoord, zCoord) != 1f){
power = 0;
}
boolean flag = this.furnaceBurnTime > 0;
boolean flag1 = false;
//if (this.furnaceBurnTime > 0) {
// --this.furnaceBurnTime;
//}
if (!this.worldObj.isRemote) {
if (this.furnaceBurnTime == 0 && this.canSmelt()) {
this.currentBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
if (this.furnaceBurnTime > 0) {
flag1 = true;
if (this.furnaceItemStacks[1] != null) {
--this.furnaceItemStacks[1].stackSize;
if (this.furnaceItemStacks[1].stackSize == 0) {
this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(this.furnaceItemStacks[1]);
}
}
}
}
if (this.isBurning() && this.canSmelt()) {
++this.furnaceCookTime;
if (this.furnaceCookTime == 200) {
this.furnaceCookTime = 0;
this.smeltItem();
flag1 = true;
}
} else {
this.furnaceCookTime = 0;
}
}
if (flag != this.furnaceBurnTime > 0) {
flag1 = true;
CocoaDryer.updateBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
if (flag1) {
this.markDirty();
}
}
The power int is supposed to represent the fuel amount does reach 0 but the furnace keeps on smelting.
Don't use static modifiers when making that block do something different every time. As I said before, please learn about static modifiers before using them.
Wouldn't you want to use static modifiers if it's night all around minecraft? Then if that static variable is true… then each individual furnace could cook it's own foods?
P.S. Please don't bad talk him either, don't make him seem like he's dumb… He's here for help… Thanks for replying anyway!
To spazzymigee: You could look at the TileEntityDaylightDetector.class in net.minecraft.tileentity package to see when Night time is! Then incorporate that into your updteEntity() method.
Quick Java Static Tutorial:
If something is labeled static, that means it is individual to it's "owner". What that means is it creates a new variable for every single instance of the class. Once again, simplified it means:
public class Foo
{
//This is the same value in every Foo class.
//This cannot be accessed because it is private.
private static int count = 0;
//On the Other Hand, this isn't the same value in every Foo instance.
//it will change when new Foo(); is called somewhere else
//This is always going to be different for every Foo instance.
public final int id;
public Foo()
{
//What this does is when the first time Foo() is called: it's id will be 1, and count will also be 1.
//The next time Foo() is called: it's id will be 2, and count will also be 2.
//But if you look at the first Foo() that was called: it's id will still be 1, but ID will be 2!
//This adds one to count and makes id equal count
id = count++;
}
}
Please let me know if this helps and/or you have any more questions about static variables or the mine craft code!
Thanks it works now except the fuel amount bar doesn't show up. ! would like the fuel amount bar to be 100% full at day and 0% at night. How would i accomplish this? Got it to work! yay
if((Minecraft.getMinecraft().theWorld.isDaytime() == true)) return 1;
if((Minecraft.getMinecraft().theWorld.isDaytime() == false)) return 0;
in the getItemBurnTime method but it didn't work.
You know, ?
Are you seriously asking me this question?
getWorldObj() for a tile-entity, gets the tile-entity's world. Meaning, not just that player's world, which you did in your current code.
*Face-palm*
First, do you know Java? And do you know how static modifiers work?
In the updateEntity() method
The actual burn time method
The variable
Don't use static modifiers when making that block do something different every time. As I said before, please learn about static modifiers before using them.
Then set it to zero.
The power int is supposed to represent the fuel amount does reach 0 but the furnace keeps on smelting.
Wouldn't you want to use static modifiers if it's night all around minecraft? Then if that static variable is true… then each individual furnace could cook it's own foods?
P.S. Please don't bad talk him either, don't make him seem like he's dumb… He's here for help… Thanks for replying anyway!
To spazzymigee: You could look at the TileEntityDaylightDetector.class in net.minecraft.tileentity package to see when Night time is! Then incorporate that into your updteEntity() method.
Quick Java Static Tutorial:
Please let me know if this helps and/or you have any more questions about static variables or the mine craft code!
Happy Modding :D!
Hello!
Hello!
Hello!
except the fuel amount bar doesn't show up. ! would like the fuel amount bar to be 100% full at day and 0% at night. How would i accomplish this?Got it to work! yayHello!