Try world.provider.isDaytime in the blocks update tick
Not sure why you quoted me, but World#isDaytime does exactly the same thing, and you still have to schedule block update ticks...
Anyway, @OP: 1.8 Daylight Detectors use a ticking TileEntity to update the block's power state every 20 ticks, so that is also a solution, though I think since you only care about day vs. night without any intermediate steps, scheduling a block update could be viable as well.
In your code, you set the block to the same exact block no matter what the state should be, so of course nothing happens. Furances have TWO blocks, one that is 'active' and one that is not, but you probably don't need to use 2 blocks since your block isn't using metadata for anything anyway, you can use metadata instead.
1. Register 2 block icons for one block.
2. Keep your TileEntity updating the block state, but instead of setting the block, set the metadata to 0 for inactive (default) and 1 for active
3. In the getIcon method, you are given the metadata as one of the parameters - "return (meta ? activeIcon : inactiveIcon)" should be all you need there
in my get icon i have put return (meta ? active: unActive); and it says that meta needs to be a boolean
So make it a boolean... 'meta > 0' resolves to a boolean.
You didn't mention before that your block had subtypes - is that new? That will complicate matters, as subtypes require the use of metadata. Still, your code betrays a fundamental lack of understanding:
// direction? what direction? Is your block directional, too, or are you just copy-pasting?
int direction = world.getBlockMetadata(x, y, z);
// you get the tile entity, but do nothing with it - I assume it's just left over from testing other things
TileEntity tileentity = world.getTileEntity(x, y, z);
// HERE!!!!! You are setting the block to EXACTLY the SAME block no matter the condition... and you don't even bother to set the metadata
// if that was your solution of choice
if (burning) {
world.setBlock(x, y, z, ModBlocks.EssenceStone);
} else {
world.setBlock(x, y, z, ModBlocks.EssenceStone);
}
// AND HERE: you set the metadata to the exact same value that it already had... why? This makes no sense.
world.setBlockMetadataWithNotify(x, y, z, direction, 2);
In short, your code seems awfully careless, but it's probably just a lack of experience. You can improve your code immensely by spending time analyzing what it is doing, or even writing down what you want it to do in English (and comparing after you're done coding), e.g.:
1. I want my block to change icon based upon some condition, e.g. day vs. night
2. I have a TileEntity that has an #updateEntity method called every tick
3. I can use that method to check whether it is day or night, and / or to call methods in my Block class
4. When that condition is met, something about the Block needs to change:
a. The actual Block at that location (this will automatically give me a new icon), or
b. The metadata state of the current block (in which case proceed to #5)
5. Return the correct icon based on a. the block (automatic), or b. metadata via the #getIcon method
Now look at your code. Does it fulfill all 5 of those steps? At which step(s) does it fail? Why does it fail? Figure that out, and you have solved your issue.
The Meaning of Life, the Universe, and Everything.
Join Date:
1/18/2011
Posts:
810
Minecraft:
mightydanp
Member Details
No i didn't mean that i needed that i just ran into a problem that i couldn't fix myself.... I Chose a simple way that mighty work, but i can figure out how to fix my problem .. my problem is after i place the first block with the metadata :0 , then i place the block that has the metadata :1 , it turns the block that i placed that is sepost to return a block with the metadata :1 but places a block with metadata :0... in sort terms when i place a block that sepost the be Air it returns the first block magic
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
i am confused now, i understand that but what am o doing wrong ?
In regards to...? Your latest code doesn't even attempt to resolve the issue that you originally posted about, i.e. changing icons between day and night.
If you are referring to your block not placing with the correct metadata, you need to register your block using an ItemBlock that respects metadata values such as ItemMetadataBlock:
What the... ?! Do you know what the substring method does? If so, why would you ever use it with the length of an array as input? What happens if you change the number of array elements? Bad things.
Please look up method documentation before using - you can usually do so just by hovering over the method in your IDE, or Ctrl-clicking on the method to view its implementation. If both of those fail (due to the Java docs not being installed or whatever), you can always view them online.
Also, I just explained how you need to use ItemMetadataBlock for your ItemBlock - you are not using that, and your custom class (which you don't need at all, as it does nothing ItemMetadataBlock doesn't do), extends ItemBlock when it should extend ItemMetadataBlock.
Finally, why do you have @SideOnly(Side.CLIENT) above #getMetaData?!?!?! For one, that's not even a super-class method - put @Override above it and you'll see - which means that your method is likely not being used anywhere and not doing what you think. For another, you should NEVER use the @SideOnly annotation unless the parent method does so.
The Meaning of Life, the Universe, and Everything.
Join Date:
1/18/2011
Posts:
810
Minecraft:
mightydanp
Member Details
ok so i redid the tile-entity . i am trying to figure out what i have done wrong. I look at the furnace code as reference but could not get it to work,
I do have one question. since i am using metadata on the blocks do i have to get and save the the metadata of the block for it to use later because some of the ids are 506, 506:1 .... 509, 509:1 an i think if i did it like this without the world.setBlockMetadataWithNotify(int, int, int, int, int); instead i wouldnt be able to change it to the block it needs to be it would just switch from 506:2 to : 509 to 506 and that would mess up the meaning of the block
Not sure why you quoted me, but World#isDaytime does exactly the same thing, and you still have to schedule block update ticks...
Anyway, @OP: 1.8 Daylight Detectors use a ticking TileEntity to update the block's power state every 20 ticks, so that is also a solution, though I think since you only care about day vs. night without any intermediate steps, scheduling a block update could be viable as well.
should i try the method as if it was a furnace being activated or should i use metadata on the block?
i came up with this but still no luck on my side,
http://pastebin.com/UihqVjzM
http://pastebin.com/exMxhhb4
In your code, you set the block to the same exact block no matter what the state should be, so of course nothing happens. Furances have TWO blocks, one that is 'active' and one that is not, but you probably don't need to use 2 blocks since your block isn't using metadata for anything anyway, you can use metadata instead.
1. Register 2 block icons for one block.
2. Keep your TileEntity updating the block state, but instead of setting the block, set the metadata to 0 for inactive (default) and 1 for active
3. In the getIcon method, you are given the metadata as one of the parameters - "return (meta ? activeIcon : inactiveIcon)" should be all you need there
in my get icon i have put return (meta ? active: unActive); and it says that meta needs to be a boolean
i am having trouble with metadata. when i place the block down it turn the block to 0 in the beta data
http://pastebin.com/mLekqYw0
http://pastebin.com/sYKvBHrT
So make it a boolean... 'meta > 0' resolves to a boolean.
You didn't mention before that your block had subtypes - is that new? That will complicate matters, as subtypes require the use of metadata. Still, your code betrays a fundamental lack of understanding:
In short, your code seems awfully careless, but it's probably just a lack of experience. You can improve your code immensely by spending time analyzing what it is doing, or even writing down what you want it to do in English (and comparing after you're done coding), e.g.:
1. I want my block to change icon based upon some condition, e.g. day vs. night
2. I have a TileEntity that has an #updateEntity method called every tick
3. I can use that method to check whether it is day or night, and / or to call methods in my Block class
4. When that condition is met, something about the Block needs to change:
a. The actual Block at that location (this will automatically give me a new icon), or
b. The metadata state of the current block (in which case proceed to #5)
5. Return the correct icon based on a. the block (automatic), or b. metadata via the #getIcon method
Now look at your code. Does it fulfill all 5 of those steps? At which step(s) does it fail? Why does it fail? Figure that out, and you have solved your issue.
No i didn't mean that i needed that i just ran into a problem that i couldn't fix myself.... I Chose a simple way that mighty work, but i can figure out how to fix my problem .. my problem is after i place the first block with the metadata :0 , then i place the block that has the metadata :1 , it turns the block that i placed that is sepost to return a block with the metadata :1 but places a block with metadata :0... in sort terms when i place a block that sepost the be Air it returns the first block magic
http://pastebin.com/XKw7SwjS
http://pastebin.com/MwLbqMkh
isRemote is true on the client side and false on the server side. It's set in the World constructor, used by WorldClient and WorldServer.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
i am confused now, i understand that but what am o doing wrong ?
In regards to...? Your latest code doesn't even attempt to resolve the issue that you originally posted about, i.e. changing icons between day and night.
If you are referring to your block not placing with the correct metadata, you need to register your block using an ItemBlock that respects metadata values such as ItemMetadataBlock:
yea i have that in my block class
but it still doesnt work even if i remove the .substring(subBlocks.length) at the end
http://pastebin.com/XKw7SwjS
http://pastebin.com/MwLbqMkh
What the... ?! Do you know what the substring method does? If so, why would you ever use it with the length of an array as input? What happens if you change the number of array elements? Bad things.
Please look up method documentation before using - you can usually do so just by hovering over the method in your IDE, or Ctrl-clicking on the method to view its implementation. If both of those fail (due to the Java docs not being installed or whatever), you can always view them online.
Also, I just explained how you need to use ItemMetadataBlock for your ItemBlock - you are not using that, and your custom class (which you don't need at all, as it does nothing ItemMetadataBlock doesn't do), extends ItemBlock when it should extend ItemMetadataBlock.
Finally, why do you have @SideOnly(Side.CLIENT) above #getMetaData?!?!?! For one, that's not even a super-class method - put @Override above it and you'll see - which means that your method is likely not being used anywhere and not doing what you think. For another, you should NEVER use the @SideOnly annotation unless the parent method does so.
ok so i redid the tile-entity . i am trying to figure out what i have done wrong. I look at the furnace code as reference but could not get it to work,
I do have one question. since i am using metadata on the blocks do i have to get and save the the metadata of the block for it to use later because some of the ids are 506, 506:1 .... 509, 509:1 an i think if i did it like this without the world.setBlockMetadataWithNotify(int, int, int, int, int); instead i wouldnt be able to change it to the block it needs to be it would just switch from 506:2 to : 509 to 506 and that would mess up the meaning of the block
http://pastebin.com/Y6kwxpBc
http://pastebin.com/zpdmACmL