Jump to content

Recommended Posts

Posted
  On 7/23/2013 at 7:18 PM, hydroflame said:

debugging 101 how to use the overpowered println

 

System.out.println(Object); <- that method? yeah its op as F***

 

 

in the method TileEntitySolarPanelRendere.renderTileEntityAt(args) if you do a println() does anythgin show up at all in your console ?

 

NOTE: try to do thsi before coming to ask question because then I wont have to ask you to do it and youll get an answer faster. it can also tell you whats going on roughly, if nothing shows up that mean the code never calls this method (maybe its not registered correctly?) if it does print something it means your render code is wrong somehow

Thanks for the tip that I should do this before asking questions, but nothing showed up in the console that was really weird.

 

  Reveal hidden contents

 

The only thing that had to do with the Solar Panel was

2013-07-23 21:47:46 [sEVERE] [Minecraft-Client] Using missing texture, unable to load: minecraft:textures/blocks/MISSING_ICON_TILE_1004_solarpanel.png

 

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Posted
  Quote
nothing showed up

conclusion? you didnt rgister it correctly :) can we have the updated main mod class ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 7:51 PM, hydroflame said:

  Quote
nothing showed up

conclusion? you didnt rgister it correctly :) can we have the updated main mod class ?

 

  Reveal hidden contents

 

There you go :)

Posted

now lets use the same strategy and make a println before this:

 

"ClientRegistry.bindTileEntitySpecialRenderer("

 

in your client proxy

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:07 PM, hydroflame said:

now lets use the same strategy and make a println before this:

 

"ClientRegistry.bindTileEntitySpecialRenderer("

 

in your client proxy

 

So I did this in the clientproxy:

package assets.blutricity.client;

import assets.blutricity.common.CommonProxy;
import assets.blutricity.common.TileEntitySolarPanelRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy
{
@Override
public void registerRendering()
{
	System.out.println();
	ClientRegistry.bindTileEntitySpecialRenderer(assets.blutricity.common.TileEntitySolarPanel.class, new TileEntitySolarPanelRenderer());

}
}

That is correct right?

 

The console for that:

 

  Reveal hidden contents

 

Posted

always use something like

System.out.println("yes the coded executed this")

 

because System.out.println() will only appear like this "2013-07-23 22:14:05  [sTDOUT] " and then you dont know what is sending thsi line, while if you use System.out.println("yes the coded executed this") you know exactly which lines has printed this code

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:19 PM, hydroflame said:

always use something like

System.out.println("yes the coded executed this")

 

because System.out.println() will only appear like this "2013-07-23 22:14:05  [sTDOUT] " and then you dont know what is sending thsi line, while if you use System.out.println("yes the coded executed this") you know exactly which lines has printed this code

ah, I'll try that at the first spot you said I should do it first :)

Posted
  On 7/23/2013 at 8:22 PM, hydroflame said:

no it wont print anything trust me, do only the ClientRegistry thing

Here is the log with the string in the clientproxy

 

  Reveal hidden contents

 

I don't see the line I put in there :/

Posted
  On 7/23/2013 at 8:30 PM, hydroflame said:

  Quote
I don't see the line I put in there :/

 

what can you conclude ?

That the problem isn't in the Clientproxy....

Posted

not exactly

 

if you do  System.out.println("thsi code was executed") and "thsi code was executed" never shows up..... can you conclude that ....thsi code was NEVER executed ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:32 PM, hydroflame said:

not exactly

 

if you do  System.out.println("thsi code was executed") and "thsi code was executed" never shows up..... can you conclude that ....thsi code was NEVER executed ?

oh yeah, so the problem IS in there, isn't it?

Posted

well for this bug well just say that the code in execute in a serial manner so if theres no println that means theres no registration... that woudl also mean that nobody is calling your client proxy registerRendering()

 

because if something was calling your registerRendering then surelly there would be a print and you would register your tile entity renderer. but since theres no println, then NOTHING in this function is EVER executed

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:36 PM, hydroflame said:

well for this bug well just say that the code in execute in a serial manner so if theres no println that means theres no registration... that woudl also mean that nobody is calling your client proxy registerRendering()

I only followed a tutorial, so I don't know for sure what I need to change to call the registerRendering.

But if I'm correct, I have to put it on the bottom of this class:

package assets.blutricity.common;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;

import assets.blutricity.models.solarpanel;

public class TileEntitySolarPanelRenderer extends TileEntitySpecialRenderer{
 private static final ResourceLocation SolarPanel = new ResourceLocation("blutricity:textures/blocks/solarpanel.png");

//This method is called when minecraft renders a tile entity
    public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) {
    	 
    	GL11.glPushMatrix();
         //This will move our renderer so that it will be on proper place in the world
         GL11.glTranslatef((float)d, (float)d1, (float)d2);
         TileEntitySolarPanel tileEntitySolarPanel = (TileEntitySolarPanel)tileEntity;
         /*Note that true tile entity coordinates (tileEntity.xCoord, etc) do not match to render coordinates (d, etc) that are calculated as [true coordinates] - [player coordinates (camera coordinates)]*/
         renderBlockSolarPanel(tileEntitySolarPanel, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, Mainclass.SolarPanel);
        GL11.glPopMatrix();
        System.out.println();
    }
    //And this method actually renders your tile entity
    public void renderBlockSolarPanel(TileEntitySolarPanel tl, World world, int i, int j, int k, Block block) {
        Tessellator tessellator = Tessellator.instance;
        //This will make your block brightness dependent from surroundings lighting.
        float f = block.getBlockBrightness(world, i, j, k);
        int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        tessellator.setColorOpaque_F(f, f, f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); 
        
        /*This will rotate your model corresponding to player direction that was when you placed the block. If you want this to work, 
        add these lines to onBlockPlacedBy method in your block class.
        int dir = MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3;
        world.setBlockMetadataWithNotify(x, y, z, dir, 0);*/

        int dir = world.getBlockMetadata(i, j, k);
        
        GL11.glPushMatrix();
         GL11.glTranslatef(0.5F, 0, 0.5F);
         //This line actually rotates the renderer.
         GL11.glRotatef(dir * (-90F), 0F, 1F, 0F);
         GL11.glTranslatef(-0.5F, 0, -0.5F);
         func_110628_a(SolarPanel);
         /*
         Place your rendering code here.
         */
       final solarpanel model = new solarpanel();
         model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
         GL11.glPopMatrix();
       
    }
    
}

At the place your rendering code here... is that correct?

Posted

no, renderers are registered when the mod is loading aka in the init/load function of your main mod

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:41 PM, hydroflame said:

no, renderers are registered when the mod is loading aka in the init/load function of your main mod

I have this in my main mod class.

GameRegistry.registerTileEntity(TileEntitySolarPanel.class, "TileEntitySolarPanel");

 

And this is my TileEntitySolarPanel:

package assets.blutricity.common;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class TileEntitySolarPanel extends TileEntity{
   public int customField;
@Override
public void writeToNBT(NBTTagCompound par1)
{
   super.writeToNBT(par1);
   par1.setInteger("customField", customField);
}

@Override
public void readFromNBT(NBTTagCompound par1)
{
   super.readFromNBT(par1);
   this.customField = par1.getInteger("customField");
}
public Packet getDescriptionPacket() {
        NBTTagCompound nbtTag = new NBTTagCompound();
        this.writeToNBT(nbtTag);
        return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
        }

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
        readFromNBT(packet.customParam1);
        }


}


Posted

TileEntity and TileEntitySpecialRenderer are 2 different things, your registerRenderer method is never called in the main mod class so after loading your mod knows that theres a new tile entity, but he doesnt know that theres a special way to render it

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:45 PM, hydroflame said:

TileEntity and TileEntitySpecialRenderer are 2 different things, your registerRenderer method is never called in the main mod class so after loading your mod knows that theres a new tile entity, but he doesnt know that theres a special way to render it

So how do I do that?

Posted

you make a call to registerRenderers() im sure in the tutorial you have followed they are doing it and you simply missed it

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  Quote
To register the renderer in a proper way, you will need proxies. Put this line into the method you call in ClientProxy.

ClientRegistry.bindTileEntitySpecialRenderer(yourPackage.TileEntityYour.class, new TileEntityYourRenderer());

 

YOU have to manually call this said method, theres no magic

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:53 PM, hydroflame said:

  Quote
To register the renderer in a proper way, you will need proxies. Put this line into the method you call in ClientProxy.

ClientRegistry.bindTileEntitySpecialRenderer(yourPackage.TileEntityYour.class, new TileEntityYourRenderer());

 

YOU have to manually call this said method, theres no magic

But how do I do that? Sorry that I keep asking this, but it's really late at night for me :P

Posted

[lmgtfy]how to call a method in java[/lmgtfy]

 

im sorry but this basic java. :(

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 7/23/2013 at 8:58 PM, hydroflame said:

[lmgtfy]how to call a method in java[/lmgtfy]

 

im sorry but this basic java. :(

So, in the PreInit I did:

ClientProxy.registerRendering();

What else do I have to add to make it functional? Because now it is giving me an error and fixing it by changing the modifier of registerrendering to static. Which results in another error. Etc.

 

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.