Jump to content

Recommended Posts

Posted

Render Code:

package modularships.renderstuff;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;

import com.DEBmods.modularships.EntityShipBlock;
import com.DEBmods.modularships.modularshipsINIT;

import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import renderstuff.models.ModelShipBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderShipBlock extends Render
{
    private static final ResourceLocation texture = new ResourceLocation(modularshipsINIT.MODID + ":textures/entity/shipblockentity.png");
    /** instance of modelShipBlock for rendering */
    protected ModelShipBlock modelShipBlock;
    public RenderShipBlock()
    {
        this.shadowSize = 0.5F;
        this.modelShipBlock = new ModelShipBlock();
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probability, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(EntityShipBlock par1EntityShipBlock, double par2, double par4, double par6, float par8, float par9)
    {
    	if (par1EntityShipBlock.axisF == "x-") {
    		modelShipBlock.Block.setRotationPoint(par1EntityShipBlock.Xoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), par1EntityShipBlock.Zoff * 16);
        }else if (par1EntityShipBlock.axisF == "z-") {
        	modelShipBlock.Block.setRotationPoint(par1EntityShipBlock.Zoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), par1EntityShipBlock.Xoff * 16);
        }else if (par1EntityShipBlock.axisF == "x") {
        	modelShipBlock.Block.setRotationPoint(-par1EntityShipBlock.Xoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), -par1EntityShipBlock.Zoff * 16);
        }else if (par1EntityShipBlock.axisF == "z") {
        	modelShipBlock.Block.setRotationPoint(-par1EntityShipBlock.Zoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), -par1EntityShipBlock.Xoff * 16);
        }
    	
    	float EntityPitch = par1EntityShipBlock.rotationPitch;
    	float EntityRoll = par1EntityShipBlock.rotationRoll;
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2 - par1EntityShipBlock.Xoff, (float)par4 - par1EntityShipBlock.Yoff, (float)par6 - par1EntityShipBlock.Zoff);
        GL11.glRotatef(par8 - 180, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(EntityPitch, 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(EntityRoll, 1.0F, 0.0F, 0.0F);
        float f4 = 0.75F;
        GL11.glScalef(f4, f4, f4);
        GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4);
        this.bindEntityTexture(par1EntityShipBlock);
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelShipBlock.render(par1EntityShipBlock, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(EntityShipBlock par1EntityShipBlockShipBlock)
    {
        return texture;
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity par1EntityShipBlock)
    {
        return this.getEntityTexture((EntityShipBlock)par1EntityShipBlock);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1EntityShipBlock, double par2, double par4, double par6, float par8, float par9)
    {
        this.doRender((EntityShipBlock)par1EntityShipBlock, par2, par4, par6, par8, par9);
    }
}

Posted

I don't fully understand the issue here, is it that you get a "ghost" entity?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I guess so... what does that mean exactly. I wonder if it has something to do with the code that spawns it...

 

EntityShipBlock shipblockentity = new EntityShipBlock(world);
	shipblockentity.setPositionAndRotation(x + 0.5, y + 1.5, z + 0.5, controller.rotationYaw, controller.rotationPitch);
	shipblockentity.controller = controller;
	shipblockentity.Xoff = x - contX;
	shipblockentity.Yoff = y - contY;
	shipblockentity.Zoff = z - contZ;
	shipblockentity.axisF = axis;
	world.spawnEntityInWorld(shipblockentity);

Posted

Do you check if it's the server world you're spawning the entity (worldObj.isRemote == false)?

If not, that's the problem. You spawn a ghost entity on the client which does nothing.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Now they don't seem to render at all, probably something stupid, could you take a look? (the entity counter definitely gets set to three on both client and server)

 

package modularships.renderstuff;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;

import com.DEBmods.modularships.EntityShipBlock;
import com.DEBmods.modularships.modularshipsINIT;

import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import renderstuff.models.ModelShipBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderShipBlock extends Render
{
    private static final ResourceLocation texture = new ResourceLocation(modularshipsINIT.MODID + ":textures/entity/shipblockentity.png");
    /** instance of modelShipBlock for rendering */
    protected ModelShipBlock modelShipBlock;
    public RenderShipBlock()
    {
        this.shadowSize = 0.5F;
        this.modelShipBlock = new ModelShipBlock();
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probability, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(EntityShipBlock par1EntityShipBlock, double par2, double par4, double par6, float par8, float par9)
    {
    	System.out.println(par1EntityShipBlock.counter);
    	
    	if (par1EntityShipBlock.worldObj.isRemote == false) {
    		GL11.glPushMatrix();
    		
    		if (par1EntityShipBlock.counter == 3) {
    			GL11.glTranslatef((float)par2 - par1EntityShipBlock.Xoff, (float)par4 - par1EntityShipBlock.Yoff, (float)par6 - par1EntityShipBlock.Zoff);
        	
    			if (par1EntityShipBlock.axisF == "x") {
    				modelShipBlock.Block.setRotationPoint(par1EntityShipBlock.Xoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), par1EntityShipBlock.Zoff * 16);
    			}else if (par1EntityShipBlock.axisF == "z") {
    				modelShipBlock.Block.setRotationPoint(par1EntityShipBlock.Zoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), par1EntityShipBlock.Xoff * 16);
    			}else if (par1EntityShipBlock.axisF == "x-") {
    				modelShipBlock.Block.setRotationPoint(-par1EntityShipBlock.Xoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), -par1EntityShipBlock.Zoff * 16);
    			}else if (par1EntityShipBlock.axisF == "z-") {
    				modelShipBlock.Block.setRotationPoint(-par1EntityShipBlock.Zoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), -par1EntityShipBlock.Xoff * 16);
    			}
    	
    		float EntityPitch = par1EntityShipBlock.rotationPitch;
    		float EntityRoll = par1EntityShipBlock.rotationRoll;
        	GL11.glRotatef(par8 - 180, 0.0F, 1.0F, 0.0F);
        	GL11.glRotatef(EntityPitch, 0.0F, 0.0F, 1.0F);
        	GL11.glRotatef(EntityRoll, 1.0F, 0.0F, 0.0F);
        	float f4 = 0.75F;
        	GL11.glScalef(f4, f4, f4);
        	GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4);
        	this.bindEntityTexture(par1EntityShipBlock);
        	GL11.glScalef(-1.0F, -1.0F, 1.0F);
        	this.modelShipBlock.render(par1EntityShipBlock, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        	GL11.glPopMatrix();
    		}
    	}
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(EntityShipBlock par1EntityShipBlockShipBlock)
    {
        return texture;
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity par1EntityShipBlock)
    {
        return this.getEntityTexture((EntityShipBlock)par1EntityShipBlock);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1EntityShipBlock, double par2, double par4, double par6, float par8, float par9)
    {
        this.doRender((EntityShipBlock)par1EntityShipBlock, par2, par4, par6, par8, par9);
    }
}

Posted

Now they don't seem to render at all, probably something stupid, could you take a look? (the entity counter definitely gets set to three on both client and server)

 

package modularships.renderstuff;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;

import com.DEBmods.modularships.EntityShipBlock;
import com.DEBmods.modularships.modularshipsINIT;

import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import renderstuff.models.ModelShipBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderShipBlock extends Render
{
    private static final ResourceLocation texture = new ResourceLocation(modularshipsINIT.MODID + ":textures/entity/shipblockentity.png");
    /** instance of modelShipBlock for rendering */
    protected ModelShipBlock modelShipBlock;
    public RenderShipBlock()
    {
        this.shadowSize = 0.5F;
        this.modelShipBlock = new ModelShipBlock();
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probability, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(EntityShipBlock par1EntityShipBlock, double par2, double par4, double par6, float par8, float par9)
    {
    	System.out.println(par1EntityShipBlock.counter);
    	
    	if (par1EntityShipBlock.worldObj.isRemote == false) {
    		GL11.glPushMatrix();
    		
    		if (par1EntityShipBlock.counter == 3) {
    			GL11.glTranslatef((float)par2 - par1EntityShipBlock.Xoff, (float)par4 - par1EntityShipBlock.Yoff, (float)par6 - par1EntityShipBlock.Zoff);
        	
    			if (par1EntityShipBlock.axisF == "x") {
    				modelShipBlock.Block.setRotationPoint(par1EntityShipBlock.Xoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), par1EntityShipBlock.Zoff * 16);
    			}else if (par1EntityShipBlock.axisF == "z") {
    				modelShipBlock.Block.setRotationPoint(par1EntityShipBlock.Zoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), par1EntityShipBlock.Xoff * 16);
    			}else if (par1EntityShipBlock.axisF == "x-") {
    				modelShipBlock.Block.setRotationPoint(-par1EntityShipBlock.Xoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), -par1EntityShipBlock.Zoff * 16);
    			}else if (par1EntityShipBlock.axisF == "z-") {
    				modelShipBlock.Block.setRotationPoint(-par1EntityShipBlock.Zoff * 16, 16f - (par1EntityShipBlock.Yoff * 16), -par1EntityShipBlock.Xoff * 16);
    			}
    	
    		float EntityPitch = par1EntityShipBlock.rotationPitch;
    		float EntityRoll = par1EntityShipBlock.rotationRoll;
        	GL11.glRotatef(par8 - 180, 0.0F, 1.0F, 0.0F);
        	GL11.glRotatef(EntityPitch, 0.0F, 0.0F, 1.0F);
        	GL11.glRotatef(EntityRoll, 1.0F, 0.0F, 0.0F);
        	float f4 = 0.75F;
        	GL11.glScalef(f4, f4, f4);
        	GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4);
        	this.bindEntityTexture(par1EntityShipBlock);
        	GL11.glScalef(-1.0F, -1.0F, 1.0F);
        	this.modelShipBlock.render(par1EntityShipBlock, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        	GL11.glPopMatrix();
    		}
    	}
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(EntityShipBlock par1EntityShipBlockShipBlock)
    {
        return texture;
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity par1EntityShipBlock)
    {
        return this.getEntityTexture((EntityShipBlock)par1EntityShipBlock);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1EntityShipBlock, double par2, double par4, double par6, float par8, float par9)
    {
        this.doRender((EntityShipBlock)par1EntityShipBlock, par2, par4, par6, par8, par9);
    }
}

 

No, don't check if it's the server in your Render class. This is purely client-side. What I meant is when you spawn the entity, (through an item most likely), there you have to check if it's server-sided. (worldObj.isRemote == false)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.