Jump to content

Rendering a 3D item as a throwable item


Thornack

Recommended Posts

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Some of my other methods dont work in other versions yet so I havent upgraded. I fixed the error in the change but minecraft still crashes with the following errors.

 

 

 

 

-- Head --

Stacktrace:

at soccer.render.RenderBall.doRender(RenderBall.java:73)

 

-- Entity being rendered --

Details:

Entity Type: Ball (soccer.entity.EntityBall)

Entity ID: 422

Entity Name: entity.Ball.name

Entity's Exact location: -82.47, 72.50, 223.56

Entity's Block location: World: (-83,72,223), Chunk: (at 13,4,15 in -6,13; contains blocks -96,0,208 to -81,255,223), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Entity's Momentum: 1.12, -0.60, 0.83

 

-- Renderer details --

Details:

Assigned renderer: soccer.render.RenderBall@139365e

Location: -0.12,-0.12,0.11 - World: (-1,-1,0), Chunk: (at 15,-1,0 in -1,0; contains blocks -16,0,0 to -1,255,15), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Rotation: 53.458286

Delta: 0.2963667

Stacktrace:

at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:310)

at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:279)

at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:508)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1150)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Thornack'/272, l='MpServer', x=-82.34, y=72.62, z=223.45]]

Chunk stats: MultiplayerChunkCache: 135

Level seed: 0

Level generator: ID 01 - flat, ver 0. Features enabled: false

Level generator options:

Level spawn location: World: (-42,4,163), Chunk: (at 6,0,3 in -3,10; contains blocks -48,0,160 to -33,255,175), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 41044 game time, 9991 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 135 total; [EntityClientPlayerMP['Thornack'/272, l='MpServer', x=-82.34, y=72.62, z=223.45], EntitySheep['Sheep'/29, l='MpServer', x=-160.72, y=63.00, z=261.16], EntityCow['Cow'/31, l='MpServer', x=-162.13, y=64.00, z=293.97], EntitySheep['Sheep'/30, l='MpServer', x=-161.94, y=64.00, z=273.94], EntitySkeleton['Skeleton'/34, l='MpServer', x=-156.50, y=39.00, z=199.50], EntityBat['Bat'/35, l='MpServer', x=-148.88, y=40.10, z=198.56], EntityCreeper['Creeper'/33, l='MpServer', x=-158.50, y=39.00, z=201.50], EntitySheep['Sheep'/38, l='MpServer', x=-145.80, y=64.00, z=237.39], EntityCow['Cow'/39, l='MpServer', x=-158.44, y=64.00, z=266.13], EntitySkeleton['Skeleton'/36, l='MpServer', x=-158.50, y=39.00, z=202.50], EntityCow['Cow'/37, l='MpServer', x=-157.84, y=63.00, z=237.09], EntitySheep['Sheep'/42, l='MpServer', x=-156.53, y=62.00, z=276.09], EntityPig['Pig'/43, l='MpServer', x=-150.91, y=65.00, z=283.25], EntityCreeper['Creeper'/40, l='MpServer', x=-155.03, y=35.00, z=284.59], EntityCreeper['Creeper'/41, l='MpServer', x=-149.50, y=34.00, z=281.50], EntityCow['Cow'/44, l='MpServer', x=-156.34, y=64.00, z=297.75], EntitySheep['Sheep'/45, l='MpServer', x=-153.19, y=64.00, z=297.91], EntitySheep['Sheep'/51, l='MpServer', x=-141.28, y=63.00, z=226.41], EntitySheep['Sheep'/50, l='MpServer', x=-133.78, y=63.00, z=222.25], EntityCreeper['Creeper'/49, l='MpServer', x=-141.88, y=39.00, z=198.72], EntitySheep['Sheep'/55, l='MpServer', x=-141.81, y=65.00, z=266.25], EntityCow['Cow'/54, l='MpServer', x=-143.97, y=65.00, z=255.91], EntitySheep['Sheep'/53, l='MpServer', x=-128.75, y=64.00, z=230.41], EntitySheep['Sheep'/52, l='MpServer', x=-141.94, y=63.00, z=225.16], EntitySheep['Sheep'/59, l='MpServer', x=-142.81, y=64.00, z=290.19], EntitySheep['Sheep'/58, l='MpServer', x=-143.44, y=64.00, z=296.75], EntitySheep['Sheep'/57, l='MpServer', x=-139.22, y=64.00, z=280.97], EntityMinecartChest['entity.MinecartChest.name'/56, l='MpServer', x=-135.50, y=34.85, z=273.50], EntityBat['Bat'/63, l='MpServer', x=-117.58, y=14.20, z=147.81], EntitySquid['Squid'/68, l='MpServer', x=-116.95, y=61.00, z=166.25], EntitySquid['Squid'/69, l='MpServer', x=-127.34, y=61.37, z=161.11], EntityZombie['Zombie'/70, l='MpServer', x=-112.50, y=42.00, z=179.50], EntitySheep['Sheep'/71, l='MpServer', x=-116.97, y=63.00, z=205.88], EntityBat['Bat'/64, l='MpServer', x=-118.54, y=14.20, z=148.87], EntityCreeper['Creeper'/65, l='MpServer', x=-121.50, y=22.00, z=175.50], EntitySquid['Squid'/66, l='MpServer', x=-115.00, y=61.00, z=166.65], EntitySquid['Squid'/67, l='MpServer', x=-114.53, y=60.54, z=171.62], EntityZombie['Zombie'/76, l='MpServer', x=-121.44, y=34.00, z=271.00], EntityBat['Bat'/77, l='MpServer', x=-113.50, y=34.20, z=282.23], EntitySkeleton['Skeleton'/78, l='MpServer', x=-119.50, y=33.00, z=297.50], EntityCow['Cow'/72, l='MpServer', x=-116.53, y=63.00, z=207.09], EntitySheep['Sheep'/73, l='MpServer', x=-126.09, y=63.00, z=216.19], EntitySheep['Sheep'/74, l='MpServer', x=-121.06, y=63.00, z=242.88], EntitySheep['Sheep'/75, l='MpServer', x=-123.91, y=67.00, z=251.06], EntityZombie['Zombie'/85, l='MpServer', x=-111.50, y=39.00, z=187.50], EntityZombie['Zombie'/84, l='MpServer', x=-104.50, y=35.00, z=191.69], EntityMinecartChest['entity.MinecartChest.name'/87, l='MpServer', x=-107.50, y=35.85, z=194.50], EntityMinecartChest['entity.MinecartChest.name'/86, l='MpServer', x=-102.50, y=35.85, z=194.50], EntityCreeper['Creeper'/93, l='MpServer', x=-108.41, y=35.00, z=215.00], EntityZombie['Zombie'/92, l='MpServer', x=-102.50, y=6.00, z=210.50], EntityCreeper['Creeper'/95, l='MpServer', x=-103.69, y=35.00, z=210.91], EntityCreeper['Creeper'/94, l='MpServer', x=-101.50, y=35.00, z=215.50], EntityZombie['Zombie'/89, l='MpServer', x=-104.50, y=35.00, z=192.69], EntityZombie['Zombie'/88, l='MpServer', x=-107.50, y=35.00, z=192.50], EntitySheep['Sheep'/91, l='MpServer', x=-100.81, y=63.00, z=197.19], EntitySheep['Sheep'/90, l='MpServer', x=-97.78, y=63.00, z=194.22], EntitySpider['Spider'/102, l='MpServer', x=-106.28, y=37.00, z=250.13], EntitySpider['Spider'/103, l='MpServer', x=-103.03, y=34.00, z=246.16], EntityZombie['Zombie'/100, l='MpServer', x=-102.50, y=35.00, z=232.50], EntitySpider['Spider'/101, l='MpServer', x=-102.50, y=35.00, z=226.50], EntityZombie['Zombie'/98, l='MpServer', x=-103.50, y=39.00, z=237.50], EntityZombie['Zombie'/99, l='MpServer', x=-101.50, y=35.00, z=230.50], EntitySpider['Spider'/96, l='MpServer', x=-102.00, y=35.00, z=209.00], EntityWartortle['Wartortle'/97, l='MpServer', x=-97.09, y=65.00, z=214.78], EntityZombie['Zombie'/110, l='MpServer', x=-94.50, y=20.00, z=188.50], EntityBat['Bat'/111, l='MpServer', x=-93.06, y=18.09, z=188.24], EntitySheep['Sheep'/109, l='MpServer', x=-83.84, y=63.00, z=172.16], EntityMinecartChest['entity.MinecartChest.name'/104, l='MpServer', x=-110.50, y=37.85, z=261.50], EntityZombie['Zombie'/119, l='MpServer', x=-88.97, y=37.00, z=242.47], EntityZombie['Zombie'/118, l='MpServer', x=-82.97, y=49.00, z=234.50], EntityCreeper['Creeper'/117, l='MpServer', x=-89.34, y=37.00, z=225.97], EntityZombie['Zombie'/116, l='MpServer', x=-84.84, y=37.00, z=238.38], EntitySkeleton['Skeleton'/115, l='MpServer', x=-80.34, y=34.00, z=234.53], EntityCreeper['Creeper'/114, l='MpServer', x=-80.97, y=37.00, z=228.63], EntitySheep['Sheep'/113, l='MpServer', x=-84.34, y=69.00, z=209.78], EntityBat['Bat'/112, l='MpServer', x=-86.75, y=28.27, z=193.14], EntitySheep['Sheep'/127, l='MpServer', x=-77.38, y=64.00, z=176.53], EntitySheep['Sheep'/126, l='MpServer', x=-67.50, y=66.00, z=176.72], EntitySpider['Spider'/122, l='MpServer', x=-84.47, y=63.00, z=244.72], EntitySkeleton['Skeleton'/121, l='MpServer', x=-86.88, y=47.00, z=243.50], EntityZombie['Zombie'/120, l='MpServer', x=-91.13, y=47.00, z=243.50], EntitySpider['Spider'/137, l='MpServer', x=-73.28, y=46.00, z=224.59], EntitySkeleton['Skeleton'/136, l='MpServer', x=-67.66, y=29.00, z=237.34], EntityBat['Bat'/139, l='MpServer', x=-66.98, y=37.00, z=230.08], EntityBat['Bat'/138, l='MpServer', x=-65.15, y=37.60, z=224.41], EntityZombie['Zombie'/141, l='MpServer', x=-67.50, y=12.00, z=241.50], EntityZombie['Zombie'/140, l='MpServer', x=-74.50, y=48.00, z=229.50], EntityBat['Bat'/143, l='MpServer', x=-65.26, y=32.58, z=249.31], EntityBat['Bat'/142, l='MpServer', x=-79.03, y=30.10, z=252.31], EntitySkeleton['Skeleton'/129, l='MpServer', x=-75.91, y=41.00, z=215.59], EntityZombie['Zombie'/128, l='MpServer', x=-77.70, y=45.00, z=220.31], EntityZombie['Zombie'/131, l='MpServer', x=-73.50, y=29.00, z=230.50], EntityCreeper['Creeper'/130, l='MpServer', x=-73.50, y=29.00, z=227.69], EntityCreeper['Creeper'/133, l='MpServer', x=-65.50, y=29.00, z=239.50], EntitySpider['Spider'/132, l='MpServer', x=-70.38, y=29.00, z=231.19], EntityCreeper['Creeper'/135, l='MpServer', x=-67.50, y=29.00, z=239.50], EntityBat['Bat'/134, l='MpServer', x=-73.35, y=28.45, z=236.63], EntitySheep['Sheep'/152, l='MpServer', x=-74.50, y=71.00, z=294.59], EntityZombie['Zombie'/154, l='MpServer', x=-51.56, y=53.00, z=183.00], EntitySheep['Sheep'/155, l='MpServer', x=-54.54, y=70.00, z=197.30], EntitySkeleton['Skeleton'/156, l='MpServer', x=-63.31, y=23.00, z=234.66], EntityBat['Bat'/157, l='MpServer', x=-55.75, y=38.10, z=228.13], EntityZombie['Zombie'/158, l='MpServer', x=-63.50, y=29.00, z=244.50], EntityBat['Bat'/159, l='MpServer', x=-57.26, y=33.00, z=248.25], EntityBat['Bat'/144, l='MpServer', x=-77.63, y=42.10, z=254.13], EntityBat['Bat'/145, l='MpServer', x=-59.98, y=33.07, z=253.28], EntityBat['Bat'/146, l='MpServer', x=-68.09, y=40.28, z=238.46], EntityZombie['Zombie'/147, l='MpServer', x=-64.50, y=28.00, z=262.50], EntityBat['Bat'/148, l='MpServer', x=-70.08, y=53.39, z=261.53], EntitySkeleton['Skeleton'/149, l='MpServer', x=-73.50, y=53.00, z=272.50], EntityPig['Pig'/150, l='MpServer', x=-67.72, y=70.00, z=282.15], EntitySheep['Sheep'/151, l='MpServer', x=-73.66, y=71.00, z=299.97], EntitySkeleton['Skeleton'/169, l='MpServer', x=-39.50, y=54.00, z=279.50], EntityZombie['Zombie'/168, l='MpServer', x=-43.69, y=56.00, z=232.31], EntityZombie['Zombie'/175, l='MpServer', x=-23.50, y=29.00, z=243.50], EntitySheep['Sheep'/174, l='MpServer', x=-31.91, y=67.00, z=197.94], EntitySheep['Sheep'/173, l='MpServer', x=-27.81, y=67.00, z=200.34], EntitySheep['Sheep'/172, l='MpServer', x=-20.59, y=64.00, z=170.52], EntityBat['Bat'/163, l='MpServer', x=-48.42, y=26.60, z=261.03], EntitySheep['Sheep'/162, l='MpServer', x=-52.44, y=66.00, z=243.34], EntitySheep['Sheep'/161, l='MpServer', x=-54.56, y=67.00, z=255.84], EntitySheep['Sheep'/160, l='MpServer', x=-57.13, y=58.00, z=253.47], EntitySheep['Sheep'/167, l='MpServer', x=-46.19, y=68.00, z=214.59], EntityZombie['Zombie'/166, l='MpServer', x=-45.50, y=37.00, z=208.50], EntitySheep['Sheep'/165, l='MpServer', x=-46.13, y=69.00, z=176.06], EntitySheep['Sheep'/164, l='MpServer', x=-36.19, y=70.00, z=183.19], EntitySlime['Slime'/186, l='MpServer', x=-10.69, y=31.95, z=235.69], EntityBat['Bat'/187, l='MpServer', x=-7.19, y=31.00, z=235.75], EntitySheep['Sheep'/185, l='MpServer', x=-15.81, y=68.00, z=204.66], EntityCreeper['Creeper'/189, l='MpServer', x=-6.50, y=17.00, z=303.50], EntitySheep['Sheep'/178, l='MpServer', x=-29.50, y=69.00, z=257.50], EntitySkeleton['Skeleton'/179, l='MpServer', x=-21.56, y=66.00, z=275.94], EntityCreeper['Creeper'/176, l='MpServer', x=-27.49, y=29.00, z=243.48], EntityCreeper['Creeper'/177, l='MpServer', x=-24.75, y=26.00, z=243.94], EntityBall['entity.Ball.name'/422, l='MpServer', x=-82.47, y=72.50, z=223.56]]

Retry entities: 0 total; []

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:441)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2414)

at net.minecraft.client.Minecraft.run(Minecraft.java:776)

at java.lang.Thread.run(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.5.2

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_07, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode, sharing), Oracle Corporation

Memory: 106220952 bytes (101 MB) / 259522560 bytes (247 MB) up to 259522560 bytes (247 MB)

JVM Flags: 0 total;

AABB Pool Size: 18435 (1032360 bytes; 0 MB) allocated, 1871 (104776 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v7.51 FML v5.2.23.737 Minecraft Forge 7.8.1.737 4 mods loaded, 4 mods active

mcp{7.51} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{5.2.23.737} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{7.8.1.737} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Soccer{0.0.1} [soccer Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

LWJGL: 2.4.2

OpenGL: Intel® HD Graphics 4000 GL version 4.0.0 - Build 9.17.10.2843, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Texture Pack: Default

Profiler Position: N/A (disabled)

Vec3 Pool Size: 3574 (200144 bytes; 0 MB) allocated, 542 (30352 bytes; 0 MB) used

 

java.lang.NullPointerException

at soccer.render.RenderBall.doRender(RenderBall.java:73)

at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:310)

at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:279)

at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:508)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1150)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:991)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:871)

at net.minecraft.client.Minecraft.run(Minecraft.java:760)

at java.lang.Thread.run(Unknown Source)

--- END ERROR REPORT f6339370 ----------

 

And the Hyperlinked code at soccer.render.RenderBall.doRender(RenderBall.java:73)

 

	icon=Soccer.ball.getIconFromDamage(0);

Link to comment
Share on other sites

Ok, that's my fault. Change

public static CustomItem ball;
        @Init
        public void load(FMLInitializationEvent event) {
        ball = new Ball(5000);
        LanguageRegistry.addName(ball, "Ball");
        GameRegistry.registerItem(ball, "Soccer"+ball.getUnlocalizedName2());
        //ItemStack diamondsStack = new ItemStack(Item.diamond, 64);
        MinecraftForgeClient.registerItemRenderer(5000+256, (IItemRenderer)new ItemRenderBall());
        registerTileEntity();

  }

to

public static CustomItem ball=new Ball(5000);
        @Init
        public void load(FMLInitializationEvent event) {
        LanguageRegistry.addName(ball, "Ball");
        GameRegistry.registerItem(ball, "Soccer"+ball.getUnlocalizedName2());
        //ItemStack diamondsStack = new ItemStack(Item.diamond, 64);
        MinecraftForgeClient.registerItemRenderer(5000+256, (IItemRenderer)new ItemRenderBall());
        registerTileEntity();

  }

Link to comment
Share on other sites

That is because it seems your render class is for rendering icons. You are probably going to have to use a different render class.

I made one that should help you, but it uses 1.7 code, so you might have to change up the methods.

ackage Movillagers.entities.render;

import Movillagers.entities.model.ModelSentry;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;


import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBoat;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class RenderBall extends Render
{
    private static final ResourceLocation BallTextures = new ResourceLocation("YourTextureHere");
    /**
     * instance of ModelBoat for rendering
     */
    protected ModelBase modelBall;
    private static final String __OBFID = "CL_00000981";

    public RenderBall()
    {
        this.shadowSize = 0.5F;
        this.modelBall = new modelBall();
    }

    /**
     * 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 doRender(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 par1EntityBoat, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
        this.bindEntityTexture(par1EntityBoat);
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelBall.render(par1EntityBoat, 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(Entity par1Entity)
    {
        return this.BallTextures;
    }

}

You will also need to revert your

RenderingRegistry.registerEntityRenderingHandler(EntityBall.class, new RenderBall([insert item here])

in your client proxy back to

]RenderingRegistry.registerEntityRenderingHandler(EntityBall.class, new RenderBall()

Link to comment
Share on other sites

Part 1 SOLVED here is the code for the renderer that worked in rendering the ball midflight.

 

package soccer.render;


import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;



import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;

import soccer.model.ItemModelBall;

@SideOnly(Side.CLIENT)
public class RenderBall extends Render
{
   /**
     * instance of ModelBoat for rendering
     */
    protected ModelBase modelBall;
    public RenderBall()
    {
        this.shadowSize = 0.5F;
        this.modelBall = new ItemModelBall();
    }

    /**
     * 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 doRender(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 par1EntityBoat, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
        Minecraft.getMinecraft().renderEngine
	.bindTexture("/mods/soccer/textures/items/Ball3D.png");
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelBall.render(par1EntityBoat, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
    }

   
    

}

Link to comment
Share on other sites

  • 1 month later...

I have now upgraded my code to 1.7.2 and alot of stuff broke. The renderers included. I am not sure how to get the textures for my ball in 1.7.2. It renders in my hand in 3D and as a dropped item but the texture is missing and it does not render when thrown. I have managed to get rid of all of the errors by commenting out 

 

 

 
Minecraft.getMinecraft().renderEngine
	.bindTexture("/mods/soccer/textures/items/Ball3D.png");

in both renderers (the one that handles in flight rendering and the one that handles the rest)

 

 

Renderer for midflight

@SideOnly(Side.CLIENT)
public class RenderBall extends Render
{
   /**
     * instance of Model for rendering
     */
    protected ModelBase modelBall;
    public RenderBall()
    {
        this.shadowSize = 0.5F;
        this.modelBall = new ItemModelBall();
    }

    /**
     * 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 doRender(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 par1EntityBall, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
         // Minecraft.getMinecraft().renderEngine
//	.bindTexture("/mods/soccer/textures/items/Ball3D.png");
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelBall.render(par1EntityBall, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
    }

}

 

Renderer for the rest

 

public class ItemRenderBall implements IItemRenderer {

protected ItemModelBall modelBall;
//private static final ResourceLocation itemTexture = new ResourceLocation("");

public ItemRenderBall() {
	modelBall = new ItemModelBall();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
	case ENTITY:
		return true;
	default:
		return false;
	}
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	return false;
}
//Renders the Ball in your hand
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
		GL11.glPushMatrix();
		// rotates the item
		GL11.glRotatef(90, 0, 0, 1);
		GL11.glRotatef(90, 0, 1, 0);
		GL11.glRotatef(230, 1, 0, 0);
		GL11.glTranslatef(0, 0.2f, -0.6f);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();

	default:
		break;
		//Renders the Ball on ground
	}
	switch (type) {
	case ENTITY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, 0f, 0f);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}

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

 

 

and I registered the item in my main mod class as so

@EventHandler Public void preInit(FMLPreInitializationEvent preEvent) {
Item ball = new Ball(5000).setUnlocalizedName("Ball");
			GameRegistry.registerItem(ball,
			"Ball");
	MinecraftForgeClient.registerItemRenderer(Ball,
			(IItemRenderer) new ItemRenderBall());
	registerTileEntity();
}

Also Client Proxy didnt change and Common Proxy didnt change

and I know that to the inflight renderer I have to add

 

 

private static final ResourceLocation itemTexture = new ResourceLocation("");

and

protected ResourceLocation getEntityTexture(Entity Ball)
    {
        return this.itemTexture;
    }

but im not sure how to specify the resource locations and I dont know what to add to the other renderer that implements IItemRenderer. I have an assets package

assets.soccer.textures.items

and I have set up the lang file but im not sure how to proceed and get the ball to render with its texture and render in flight. It currently renders in my hand and on the ground as a 3D object but without its proper texture.

 

Link to comment
Share on other sites

public class RenderBall extends Render
{
    private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"textures/items/Ball3D.png");

    protected ModelBase modelBall;
    
    public RenderBall()
    {
        this.shadowSize = 0.5F;
        this.modelBall = new ModelBall();
    }


     

    /**
     * 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 doRender(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 par1EntityBoat, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4+1.5f, (float)par6);

        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
        this.bindEntityTexture(par1EntityBoat);
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelBall.render(par1EntityBoat, 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(Entity par1Entity)
    {
        return this.BallTextures;
    }

public class ItemRenderBall implements IItemRenderer {

protected ItemModelBall modelBall;
private static final ResourceLocation itemTexture = new ResourceLocation("yourmod.modid+"textures/items/Ball3D.png");

public ItemRenderBall() {
	modelBall = new ItemModelBall();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
	case ENTITY:
		return true;
	default:
		return false;
	}
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	return false;
}
//Renders the Ball in your hand
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
		GL11.glPushMatrix();
		// rotates the item
		GL11.glRotatef(90, 0, 0, 1);
		GL11.glRotatef(90, 0, 1, 0);
		GL11.glRotatef(230, 1, 0, 0);
		GL11.glTranslatef(0, 0.2f, -0.6f);
                        Minecraft.getMinecraft().renderEngine.bindTexture(this.itemTexture );
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();

	default:
		break;
		//Renders the Ball on ground
	}
	switch (type) {
	case ENTITY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, 0f, 0f);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}

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

 

Link to comment
Share on other sites

I added the changes you suggester and now the ball renders but with a purple colour and doesn't render during flight at all (when before it rendered weird with a bunch of textures overlayed on it where some parts were clear and others weren't and didn't render during flight either).

Link to comment
Share on other sites

my textures are organized as follows in my modding folder I have a forge folder and inside that folder the path is src/soccer/assets/soccer/textures/items/Ball3D.png I have tried inputting and I still get the purple.

 

 

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"Ball3D.png"); 

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"items/Ball3D.png");

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"textures/items/Ball3D.png");

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"soccer/textures/items/Ball3D.png");

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"assets/soccer/textures/items/Ball3D.png");

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"soccer/assets/soccer/textures/items/Ball3D.png");

private static final ResourceLocation BallTextures = new ResourceLocation(yourmod.modid+"src/soccer/assets/soccer/textures/items/Ball3D.png");

 

Is it a problem with how I set up my resource locations? Do they have to be in the "src/main/resources/..." directory?

Link to comment
Share on other sites

Part 1 is [solved] But it doesnt seem to be thrown and doesnt render in flight

 

I replaced this line

private static final ResourceLocation itemBallTexture = new ResourceLocation(Soccer.modid+"/assets/soccer/textures/items/Ball3D.png");

with this line

private static final ResourceLocation itemBallTexture = new ResourceLocation("soccer","textures/items/ball3D.png");

in the ItemRenderBall renderer.

 

working code

 

 

public class ItemRenderBall implements IItemRenderer {

protected ItemModelBall modelBall;
private static final ResourceLocation itemBallTexture = new ResourceLocation(
		"soccer", "textures/items/ball.png");
public ItemRenderBall() {
	modelBall = new ItemModelBall();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
	case ENTITY:
		return true;
	default:
		return false;
	}
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	return false;
}
//Renders the Ball in your hand
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
		GL11.glPushMatrix();
		// rotates the item
		GL11.glRotatef(90, 0, 0, 1);
		GL11.glRotatef(90, 0, 1, 0);
		GL11.glRotatef(230, 1, 0, 0);
		GL11.glTranslatef(0, 0.2f, -0.6f);
		Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();

	default:
		break;
		//Renders the Ball on ground
	}
	switch (type) {
	case ENTITY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, 0f, 0f);
		Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}

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

 

and changed my mod id in the main mod class to be all lowercase letters.

 

However, the model is not rendering midflight when these changes are applied to the in flight Renderer

 

in flight Renderer File

@SideOnly(Side.CLIENT)
public class RenderBall extends Render
{
private static final ResourceLocation itemBallTexture = new ResourceLocation("soccer","textures/items/ball3D.png");
   /**
     * instance of Model for rendering
     */
    protected ModelBase modelBall;
    public RenderBall()
    {
        this.shadowSize = 0.5F;
        this.modelBall = new ItemModelBall();
    }

    /**
     * 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 doRender(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 par1EntityBall, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
        this.bindEntityTexture(renderflyingball);
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        this.modelBall.render(renderflyingball, 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(Entity par1Entity)
    {
        return this.itemBallTexture;
    }

    }

}

 

Item File

public class Ball extends CustomItem {


public static int itemID;

public Ball(int par1) {
	super();
	itemID = par1;
	setUnlocalizedName("Ball");
	setCreativeTab(CreativeTabs.tabMisc);
	setFull3D();

}

public ItemStack onItemRightClick(ItemStack itemStack, World par2World, EntityPlayer par3EntityPlayer)
   {
       if (!par3EntityPlayer.capabilities.isCreativeMode)
       {
           --itemStack.stackSize;
       }
       par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
       if (!par2World.isRemote)
       {
           par2World.spawnEntityInWorld(new EntityBall(par2World));
       }
       return itemStack;
   }

 				}

 

Entity File

public class EntityBall extends EntityThrowable {


public EntityBall(World par1World) {
	super(par1World);
	this.setSize(0.9F, 0.9F); // hit-box size?

}

public EntityBall(World par1World, EntityLiving par2EntityLiving) {
	super(par1World, par2EntityLiving);
}

/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
	if (par1MovingObjectPosition.entityHit != null) {
		byte b0 = 0;

		if (par1MovingObjectPosition.entityHit instanceof EntityPlayer) {
			b0 = 3;
		}

		par1MovingObjectPosition.entityHit
				.attackEntityFrom(
						DamageSource.causeThrownDamage(this,
								this.getThrower()), b0);
	}

	for (int i = 0; i < 8; ++i) {
		this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY,
				this.posZ, 0.0D, 0.0D, 0.0D);
	}

	if (!this.worldObj.isRemote) {
		this.setDead();
	}
}
    private int field_145788_c = -1;
    private int field_145786_d = -1;
    private int field_145787_e = -1;
    private Block field_145785_f;
    protected boolean inGround;
    public int throwableShake;
    /** The entity that threw this throwable item. */
    private EntityLivingBase thrower;
    private String throwerName;
    private int ticksInGround;
    private int ticksInAir;
    private static final String __OBFID = "CL_00001723";

    

    protected void entityInit() {}

    /**
     * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
     * length * 64 * renderDistanceWeight Args: distance
     */
    @SideOnly(Side.CLIENT)
    public boolean isInRangeToRenderDist(double par1)
    {
        double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D;
        d1 *= 64.0D;
        return par1 < d1 * d1;
    }

    public EntityBall(World par1World, EntityLivingBase par2EntityLivingBase)
    {
        super(par1World);
        this.thrower = par2EntityLivingBase;
        this.setSize(0.25F, 0.25F);
        this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch);
        this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
        this.posY -= 0.10000000149011612D;
        this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
        this.setPosition(this.posX, this.posY, this.posZ);
        this.yOffset = 0.0F;
        float f = 0.4F;
        this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
        this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
        this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f);
        this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.func_70182_d(), 1.0F);
    }

    public EntityBall(World par1World, double par2, double par4, double par6)
    {
        super(par1World);
        this.ticksInGround = 0;
        this.setSize(0.25F, 0.25F);
        this.setPosition(par2, par4, par6);
        this.yOffset = 0.0F;
    }

    protected float func_70182_d()
    {
        return 1.5F;
    }

    protected float func_70183_g()
    {
        return 0.0F;
    }

    /**
     * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
     */
    public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
    {
        float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
        par1 /= (double)f2;
        par3 /= (double)f2;
        par5 /= (double)f2;
        par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
        par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
        par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
        par1 *= (double)par7;
        par3 *= (double)par7;
        par5 *= (double)par7;
        this.motionX = par1;
        this.motionY = par3;
        this.motionZ = par5;
        float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
        this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
        this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI);
        this.ticksInGround = 0;
    }

    /**
     * Sets the velocity to the args. Args: x, y, z
     */
    @SideOnly(Side.CLIENT)
    public void setVelocity(double par1, double par3, double par5)
    {
        this.motionX = par1;
        this.motionY = par3;
        this.motionZ = par5;

        if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
        {
            float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
            this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
            this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI);
        }
    }

    /**
     * Called to update the entity's position/logic.
     */
    public void onUpdate()
    {
        this.lastTickPosX = this.posX;
        this.lastTickPosY = this.posY;
        this.lastTickPosZ = this.posZ;
        super.onUpdate();

        if (this.throwableShake > 0)
        {
            --this.throwableShake;
        }

        if (this.inGround)
        {
            if (this.worldObj.getBlock(this.field_145788_c, this.field_145786_d, this.field_145787_e) == this.field_145785_f)
            {
                ++this.ticksInGround;

                if (this.ticksInGround == 1200)
                {
                    this.setDead();
                }

                return;
            }

            this.inGround = false;
            this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
            this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
            this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
            this.ticksInGround = 0;
            this.ticksInAir = 0;
        }
        else
        {
            ++this.ticksInAir;
        }

        Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
        Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
        MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31);
        vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
        vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

        if (movingobjectposition != null)
        {
            vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
        }

        if (!this.worldObj.isRemote)
        {
            Entity entity = null;
            List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
            double d0 = 0.0D;
            EntityLivingBase entitylivingbase = this.getThrower();

            for (int j = 0; j < list.size(); ++j)
            {
                Entity entity1 = (Entity)list.get(j);

                if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5))
                {
                    float f = 0.3F;
                    AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f);
                    MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);

                    if (movingobjectposition1 != null)
                    {
                        double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

                        if (d1 < d0 || d0 == 0.0D)
                        {
                            entity = entity1;
                            d0 = d1;
                        }
                    }
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }
        }

        if (movingobjectposition != null)
        {
            if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal)
            {
                this.setInPortal();
            }
            else
            {
                this.onImpact(movingobjectposition);
            }
        }

        this.posX += this.motionX;
        this.posY += this.motionY;
        this.posZ += this.motionZ;
        float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

        for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
        {
            ;
        }

        while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
        {
            this.prevRotationPitch += 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw < -180.0F)
        {
            this.prevRotationYaw -= 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
        {
            this.prevRotationYaw += 360.0F;
        }

        this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
        float f2 = 0.99F;
        float f3 = this.getGravityVelocity();

        if (this.isInWater())
        {
            for (int i = 0; i < 4; ++i)
            {
                float f4 = 0.25F;
                this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
            }

            f2 = 0.8F;
        }

        this.motionX *= (double)f2;
        this.motionY *= (double)f2;
        this.motionZ *= (double)f2;
        this.motionY -= (double)f3;
        this.setPosition(this.posX, this.posY, this.posZ);
    }

    /**
     * Gets the amount of gravity to apply to the thrown entity with each tick.
     */
    protected float getGravityVelocity()
    {
        return 0.03F;
    }

    
    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
    {
        par1NBTTagCompound.setShort("xTile", (short)this.field_145788_c);
        par1NBTTagCompound.setShort("yTile", (short)this.field_145786_d);
        par1NBTTagCompound.setShort("zTile", (short)this.field_145787_e);
        par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145785_f));
        par1NBTTagCompound.setByte("shake", (byte)this.throwableShake);
        par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));

        if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer)
        {
            this.throwerName = this.thrower.getCommandSenderName();
        }

        par1NBTTagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        this.field_145788_c = par1NBTTagCompound.getShort("xTile");
        this.field_145786_d = par1NBTTagCompound.getShort("yTile");
        this.field_145787_e = par1NBTTagCompound.getShort("zTile");
        this.field_145785_f = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
        this.throwableShake = par1NBTTagCompound.getByte("shake") & 255;
        this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
        this.throwerName = par1NBTTagCompound.getString("ownerName");

        if (this.throwerName != null && this.throwerName.length() == 0)
        {
            this.throwerName = null;
        }
    }

    @SideOnly(Side.CLIENT)
    public float getShadowSize()
    {
        return 0.1F;
    }

    public EntityLivingBase getThrower()
    {
        if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0)
        {
            this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);
        }

        return this.thrower;
    }

}

 

Link to comment
Share on other sites

Can I see your imports on your model and render file? Sometimes there can be a faulty import there that prevents everything from working.

 

	       if (!par2World.isRemote)
       {
           par2World.spawnEntityInWorld(new EntityBall(par2World));
       }

There is the problem. You never move the ball to the players coordinates, nor do you give it a velocity. I bet if you went to 0 0 0 and broke all the blocks around there, you would see a fully functioning rendered ball spawning there every time you threw it. (Don't worry, we all make mistake like this :P I've honestly done worse.)

 

Change it to:

 

[code=]       if (!par2World.isRemote)
      {
          par2World.spawnEntityInWorld(new EntityBall(par2World,par3EntityPlayer));
      }[/code]

 

And the EntityThrowable class will take care of all the velocities and stuff.

 

Also, try running the server side version, I think the way you are registering your rendering is going to cause problems with server.

 

Lastly,

Link to comment
Share on other sites

I have made a few changes to the code, and am now trying to get it to render in the inventory before I tackle the in flight rendering again since I couldnt get it to work and need a break, it isnt rendering while being thrown and I have no idea why because when I replaced everything with the egg it worked fine.

 

This is the updated renderer that handles case ENTITY, case EQUIPPED_FIRST_PERSON, and now case INVENTORY

 

public class ItemRenderBall implements IItemRenderer {

protected ItemModelBall modelBall;
private static final ResourceLocation itemBallTexture = new ResourceLocation(
		"soccer:textures/items/ball.png");
public ItemRenderBall() {
	modelBall = new ItemModelBall();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
	case ENTITY:
                case INVENTORY:
		return true;
	default:
		return false;
	}
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	return false;
}
//Renders the Ball in your hand
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
		GL11.glPushMatrix();
		// rotates the item
		GL11.glRotatef(90, 0, 0, 1);
		GL11.glRotatef(90, 0, 1, 0);
		GL11.glRotatef(230, 1, 0, 0);
		GL11.glTranslatef(0, 0.2f, -0.6f);
		Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();

	default:
		break;
		//Renders the Ball on ground
	}
	switch (type) {
	case ENTITY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, 0f, 0f);
		Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}
switch (type) {
	case INVENTORY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, 0f, 0f);
		Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture);
		// renders the item
		modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}
}
 /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity Ball)
    {
        return this.itemBallTexture;
    }
}

but im getting an error from  line

 modelBall.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,0.0f, 0.0225f);

where changing (Entity) data[1]  to null fixes the error but in game the ball doesnt show up and when you try to puck up a stack the stacknumber shows up so it seems to be there but is invisible in the inventory.

 

Link to comment
Share on other sites

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




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.