The Meaning of Life, the Universe, and Everything.
Join Date:
10/26/2014
Posts:
205
Minecraft:
TheBoeing767fan
Member Details
Hello everyone,
I posted a thread about this issue a while back and it was successfully resolved. Unfortunately, I am having the same issue as before due to numerous changes to my code. The changing texture of this block now uses set and get methods for the variables. My process before involved using a public static variable, but this caused problems because it changed the texture of every version of the block in the world. I was told that using set and get methods would fix this problem, however the textures do not change at all now :(. I cannot spot anything in my code so I need someone else to take a look and see what is going on.
Anyways, you forgot to override the writetonbt and readfromnbt methods, that might be why the value isn't actually getting changed within the TE. However, you most likely do not need to store that data if you only change the texture if regarding the power level. You can access that data through this snippet:
It will avoid you having to save and write data all the time and willbe overall more effective.
I think the variable method is more efficient, the variable will be updated only when a neighbour block updates.
World interaction usually are a bit more slow than the variable reading
The Meaning of Life, the Universe, and Everything.
Join Date:
10/26/2014
Posts:
205
Minecraft:
TheBoeing767fan
Member Details
So basically, the variable has to be written to an NBT? If so, how would I do this? I looked around the forums, but I do not seem to understand it fully.
If you are overriding the writeToNBT and readFromNBT methods, you should put this.markDirty() in every setter method so any changes are saved.
Besides that, here is why your texture is not changing:
public TileEntityVerticalTrafficLight te = new TileEntityVerticalTrafficLight();
You put this in your Block class. Two things: All Blocks are a single instance, so you are accessing a single instance of your TileEntity. However, all Entity classes (including TileEntity) are initialized separately by using the createNewTileEntity method you override. Basically, you're setting the values for te but accessing the values from another instance.
Do not do that. You can access the actual TileEntity, the one that the Renderer checks for values, with this:
Use that in onNeighborBlockChange instead of making a class variable to hold one universal TileEntity that, as far as the game is concerned, has no location and therefore does not exist in the world. You may also consider casting to TileEntityVerticalTrafficLight only after an instanceof check.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Aha got it! You made the same mistake in the Renderer by accessing a TileEntity instance that is never changed:
public TileEntityVerticalTrafficLight te = new TileEntityVerticalTrafficLight();
.......
// then in your renderTileEntityAt method you're given tileentity but use te
if (te.getPower() == 0)
.....
You need to learn about casting. Up-casting is when you tell Java to assume that the TileEntity passed in by renderTileEntityAt is actually a TileEntityVerticalTrafficLight. That will let you access getPower() by using the actual TileEntity that the renderer is checking
I do this at the beginning of my methods:
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par5)
{
final float SC = 0.0625F;
if(te instanceof TETesla)
{
TETesla tesla = (TETesla)te; // now you can use it!
GL11.glPushMatrix();
// bind texture
int frame = getFrame(tesla.getTicks()); // here I use the casted version
this.bindTexture(textures[frame]);
// set location
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
// rotate so it's not upside down
GL11.glPushMatrix();
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
this.model.render(null, 0, 0, 0, 0, 0, SC);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
What's your new Block class? In particular I need to make sure you did onNeighborBlockChange right. You should be using something like this to set the TileEntity power level:
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityVerticalTrafficLight)
{
TileEntityVerticalTrafficLight tevtl = (TileEntityVerticalTrafficLight)te;
if (world.isBlockIndirectlyGettingPowered(x, y, z))
{
tevtl.setPower(1);
}
else
{
tevtl.setPower(0);
System.out.println("Power should be 0");
System.out.println("TE power returns " + tevtl.getPower());
}
}
If the TileEntity has the right information, your Renderer should now work perfectly. Only thing I can think of is that the TileEntity has the wrong information somehow.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
I had something similar to yours, but I copied over your code and still no avail...
What could be wrong?
Does it need a method to initiate a render update?
Oh, good point. I don't think you need to send a packet for client-side stuff, though. I have one block model that changes texture each tick (not each render frame) and it works just fine. All it does is occasionally change what texture it binds before rendering the model.
If none of my last post fixed it, I don't know. Maybe you should just come back to it later -- you might get an idea randomly.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Hello everyone,
I posted a thread about this issue a while back and it was successfully resolved. Unfortunately, I am having the same issue as before due to numerous changes to my code. The changing texture of this block now uses set and get methods for the variables. My process before involved using a public static variable, but this caused problems because it changed the texture of every version of the block in the world. I was told that using set and get methods would fix this problem, however the textures do not change at all now :(. I cannot spot anything in my code so I need someone else to take a look and see what is going on.
Relevant snippets of code...
Block Class
Tile Entity Class
Render Class
Link to old thread http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2615474-1-7-10-how-to-re-render-custom-rendered-block
Thank you
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
Can you show us the complete TE class?
Check out my mod, Placeable Items!
If my comment helped you or you just like me, hit the green arrow down there!
That is the full TE class.
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
Damn sorry I got confused.
Anyways, you forgot to override the writetonbt and readfromnbt methods, that might be why the value isn't actually getting changed within the TE. However, you most likely do not need to store that data if you only change the texture if regarding the power level. You can access that data through this snippet:
It will avoid you having to save and write data all the time and willbe overall more effective.
Check out my mod, Placeable Items!
If my comment helped you or you just like me, hit the green arrow down there!
I think the variable method is more efficient, the variable will be updated only when a neighbour block updates.
World interaction usually are a bit more slow than the variable reading
sorry for my bad english I'm Italian
So basically, the variable has to be written to an NBT? If so, how would I do this? I looked around the forums, but I do not seem to understand it fully.
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
Look at the facing variable in the following code I use: https://github.com/Ferdzz/PlaceableItems/blob/master/src/main/java/com/stuntmania/placeableitems/tileentity/TEPlaceableItems.java#L41-L51 it's just a matter of storing the data in the nbt tag. That might be the problem.
Check out my mod, Placeable Items!
If my comment helped you or you just like me, hit the green arrow down there!
Thanks for the reply. I tried storing it in the NBT but the texture still does not change. Here are the full classes.
Tile Entity
Block
Renderer
Cheers!
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
If you are overriding the writeToNBT and readFromNBT methods, you should put this.markDirty() in every setter method so any changes are saved.
Besides that, here is why your texture is not changing:
You put this in your Block class. Two things: All Blocks are a single instance, so you are accessing a single instance of your TileEntity. However, all Entity classes (including TileEntity) are initialized separately by using the createNewTileEntity method you override. Basically, you're setting the values for te but accessing the values from another instance.
Do not do that. You can access the actual TileEntity, the one that the Renderer checks for values, with this:
Use that in onNeighborBlockChange instead of making a class variable to hold one universal TileEntity that, as far as the game is concerned, has no location and therefore does not exist in the world. You may also consider casting to TileEntityVerticalTrafficLight only after an instanceof check.
Thank you very much for explaining that.
I added what you told me and it still does not want to change. Could something be wrong in the render class?
Thanks!
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
What do your printouts say the values are?
Add a printout to onNeighborBlockChange to state what the power level is AND what TileEntityVerticalTrafficLight#getPower returns.
Also add a printout to the renderer to see what it thinks the TileEntity power level is (warning: printouts in the renderers spam the console logs)
The oonNeighborBlockChange method changes the variable, but im getting no response from the renderer...
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
Hmmmm... I'm at a loss. Experiment while I think of something and one of us will solve it
Indeed. I have spent a large quantity of time trying to solve this myself so it would be nice to finally be able to move on
Anyway I really do appreciate your help and if something does come to your mind please do post it
Cheers!
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
Aha got it! You made the same mistake in the Renderer by accessing a TileEntity instance that is never changed:
You need to learn about casting. Up-casting is when you tell Java to assume that the TileEntity passed in by renderTileEntityAt is actually a TileEntityVerticalTrafficLight. That will let you access getPower() by using the actual TileEntity that the renderer is checking
I do this at the beginning of my methods:
I tried that and guess what..... still won't change I may have put something incorrectly in the render class once again so ill link that.
**Here is what I did Renderer Class (NEW VERSION)
Thank you so much for the help
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
What's your new Block class? In particular I need to make sure you did onNeighborBlockChange right. You should be using something like this to set the TileEntity power level:
If the TileEntity has the right information, your Renderer should now work perfectly. Only thing I can think of is that the TileEntity has the wrong information somehow.
I had something similar to yours, but I copied over your code and still no avail...
Also the values are coming up in the console.
What could be wrong?
Does it need a method to initiate a render update?
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard
Oh, good point. I don't think you need to send a packet for client-side stuff, though. I have one block model that changes texture each tick (not each render frame) and it works just fine. All it does is occasionally change what texture it binds before rendering the model.
If none of my last post fixed it, I don't know. Maybe you should just come back to it later -- you might get an idea randomly.
I agree I should back off from this for now. Thanks a bunch for your help.
If anyone else has any other ideas please do chime in.
Cheers!!
CPU Cooler: Corsair H100i 77.0 CFM Liquid CPU Cooler
Motherboard: Asus Maximus V Extreme
Memory: G.Skill Ripjaws Z Series 32GB @1866 MHz
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 250GB
Storage: Samsung 840 EVO 500GB
Video Card: Asus GeForce GTX 780 3GB
Case: Corsair Obsidian Series 800D ATX Full Tower Case
Power Supply: Corsair AX1200i
Sound Card: Creative Labs Sound Blaster Zx 24-bit 192 KHz Sound Card
Wireless Network Adapter: Netgear WNDA4100-100NAS 802.11a/b/g/n USB 2.0 Wi-Fi Adapter
Mouse: Corsair Vengeance M95 Wired Laser Mouse
Keyboard: Corsair Gaming K95 RGB Cherry MX Brown Fully Mechanical Gaming Keyboard