Jump to content

Recommended Posts

Posted

Title says it all. If I make an item that fires an entity (Let's say an exploding baseball as an example :P) on right click, it shoots an invisible entity (I am certain it is shooting it, because onImpact it has the properties of my Throwable Entity). Since they changed the way you used to register the texture for EntityThrowable Entities, how do you do it now?

 

 

Posted

That depends on how you set the texture before. I always used an Item for the projectile and just used that Item texture for the Entity. For example, if I have a cannon I'll make an Item cannonBall.

 

You can either register the texture in the class with registerIcons or, if you don't want to make a class, use setTextureName("texture_name") - that's the updated name for func_111somethingsometing_d from before, so you still need to prefix the texture name with your mod id + ":"

 

When you register your throwable entity renderer, if it's set up similar to RenderSnowball, you just pass in the Item and it will use the correct texture.

Posted

I just do it in my Render(projectilename) class and register it in my clientproxy, here's an example...

(Replace ProjectileName with your projectiles name)

EntityRegistry.registerGlobalEntityID(EntityIceBolt.class, "ProjectileName",
			EntityRegistry.findGlobalUniqueEntityId());
RenderingRegistry.registerEntityRenderingHandler(EntityProjectileName.class,
			new RenderProjectileName());

Just add this under your load method in your main too:

EntityRegistry.registerModEntity(EntityProjectileName.class, "WaveBolt", CUSTOM ENTITY ID,
			this, 64, 1, true);

Finally make a class called RenderProjectileName and find some vanilla projectile that you want to change the sprite of (I would do an arrow because its really just 2 flat rectangles, not shaped like an arrow) and use

 

private static final ResourceLocation texture = new ResourceLocation("MODID","textures/entities/entityprojectilenameinalllowercase.png");

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	return texture;
}

Also, make sure the .png file name is completely lowercase, both in the code and the file itself or it won't work.

Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more!

width=174 height=100http://i.imgur.com/ghgWmA3.jpg[/img]

Posted

Every time I throw the entity now, I still have an invisible texture. However, I also get this error:

 net.minecraft.util.ReportedException: Adding entity to track
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityTracker.addEntityToTracker(EntityTracker.java:219)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at cpw.mods.fml.common.registry.EntityRegistry.tryTrackingEntity(EntityRegistry.java:363)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityTracker.addEntityToTracker(EntityTracker.java:64)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.world.WorldManager.onEntityCreate(WorldManager.java:37)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.world.World.onEntityAdded(World.java:1587)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.world.WorldServer.onEntityAdded(WorldServer.java:923)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.world.World.spawnEntityInWorld(World.java:1578)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at me.myMod.items.ItemBall.onItemRightClick(ItemBall.java:38)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:176)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.item.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:353)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:540)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
2013-09-23 15:20:38 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at cpw.mods.fml.common.network.EntitySpawnPacket.generatePacket(EntitySpawnPacket.java:75)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at cpw.mods.fml.common.network.FMLPacket.makePacket(FMLPacket.java:131)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at cpw.mods.fml.common.network.FMLNetworkHandler.getEntitySpawningPacket(FMLNetworkHandler.java:371)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityTrackerEntry.getPacketForThisEntity(EntityTrackerEntry.java:495)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityTrackerEntry.tryStartWachingThis(EntityTrackerEntry.java:385)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityTrackerEntry.sendEventsToPlayers(EntityTrackerEntry.java:484)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityTracker.addEntityToTracker(EntityTracker.java:205)
2013-09-23 15:20:38 [iNFO] [sTDERR] 	... 20 more

 

 

RenderBall:

@SideOnly(Side.CLIENT)
public class RenderBall extends Render
{
    private static final ResourceLocation texture = new ResourceLocation(MyModInfo.ID,"textures/entities/ball.png");
    
    private Item field_94151_a;
    private int field_94150_f;

    public RenderBall(Item par1Item, int par2)
    {
        this.field_94151_a = par1Item;
        this.field_94150_f = par2;
    }

    public RenderBall(Item par1Item)
    {
        this(par1Item, 0);
    }

    /**
     * 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 par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        Icon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f);

        if (icon != null)
        {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.func_110777_b(par1Entity);
            Tessellator tessellator = Tessellator.instance;

            if (icon == ItemPotion.func_94589_d("bottle_splash"))
            {
                int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false);
                float f2 = (float)(i >> 16 & 255) / 255.0F;
                float f3 = (float)(i >> 8 & 255) / 255.0F;
                float f4 = (float)(i & 255) / 255.0F;
                GL11.glColor3f(f2, f3, f4);
                GL11.glPushMatrix();
                this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay"));
                GL11.glPopMatrix();
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
            }

            this.func_77026_a(tessellator, icon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }

    @Override
    protected ResourceLocation func_110775_a(Entity par1Entity) {
        return texture;
    }

    private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon)
    {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
        par1Tessellator.draw();
    }
}

 

Entity Registration (Method in common proxy, called from my load method in my Main Class though)

	public void registerEntities() {
	EntityRegistry.registerModEntity(EntityBall.class, "Ball", 257, MyMod.instance, 64, 1, true);
}

 

Rendering Registration and other Entity Registration (Of course this is in the client proxy method registerRenderers and registerEntities:))

        @Override
        public void registerRenderers() {
        	RenderingRegistry.registerEntityRenderingHandler(EntityBall.class, new RenderBall(Items.ballItem));
        }

        @Override
        public void registerEntities() {
    		EntityRegistry.registerGlobalEntityID(EntityBall.class, "Ball",
    		EntityRegistry.findGlobalUniqueEntityId());
        }

Posted

If you are talking about this:

EntityRegistry.registerModEntity(EntityProjectileName.class, "WaveBolt", CUSTOM ENTITY ID,
			this, 64, 1, true);

Then yes and no. It's in another class to keep my organization, but the method containing it is called from the load method. So it's essentially like having it in the load method of my main.

Posted

Hi

 

Your crash log suggests to me that the server is trying to invoke a NetworkModHandler which hasn't been defined (is NULL) for your custom entity.  Normally Forge provides a default one for your entities automatically, I think.

FMLNetworkHandler.getEntitySpawningPacket is the place where it retrieves the appropriate NetworkModHandler.

 

After that I get lost...  but I suspect it's something to do with your entity being registered differently on the client and the server.  The crash occurs when the server tries to create a packet to tell the clients about the new entity.  It's nothing to do with the rendering code.

 

Not much help, sorry!  I'm still learning this myself.

 

-TGG

Posted

If you are talking about this:

EntityRegistry.registerModEntity(EntityProjectileName.class, "WaveBolt", CUSTOM ENTITY ID,
			this, 64, 1, true);

Then yes and no. It's in another class to keep my organization, but the method containing it is called from the load method. So it's essentially like having it in the load method of my main.

You mentioned this is in your CommonProxy? I think you should only register entities in ClientProxy, which could be the cause of your null network mod handler. At least, I only register mine in ClientProxy and it works for me on the Eclipse server. I can't claim any expertise in this particular area other than that. :P

 

EDIT: This is wrong. Entities should be registered on both sides, so do it from main mod load method or somewhere similar. Thanks Goto again for the correction.

Posted

Read the tutorials in the wiki please.

Choose one the EntityRegistry method and stick to it. And register on both sides, obviously.

EDIT: Goto was right, of course. I fired up the Eclipse server and tried my custom entity there, didn't render. Moving 'registerModEntity' to the load method of my main mod class resolved the issue. Too bad that's not mentioned in the Forge wiki tutorial, unless there's another one that deals with registering entities besides the SpaceMarine blasterRifle one. If there is, it's not easy to find.

 

Thanks for clearing that up Goto. I've been looking through your mods on github and I can't seem to find where you register your entities... I only see lines like the following:

RenderingRegistry.registerEntityRenderingHandler(EntitySteamBoat.class, new RenderSteamBoat());

I know that's in ClientProxy only, but do you register the EntitySteamBoat? Where? I don't see it in CommonProxy or the main mod class.

 

Thanks again. It's nice to have someone who really understands the code - like I said, the method I used above seems to work fine, and that's the way it says to do it in the Blaster Rifle tutorial on the wiki, but what you say makes sense about needing to register on both sides.

Posted

Thanks for clearing that up Goto. I've been looking through your mods on github and I can't seem to find where you register your entities... I only see lines like the following:

RenderingRegistry.registerEntityRenderingHandler(EntitySteamBoat.class, new RenderSteamBoat());

I know that's in ClientProxy only, but do you register the EntitySteamBoat? Where? I don't see it in CommonProxy or the main mod class.

 

Thanks again. It's nice to have someone who really understands the code - like I said, the method I used above seems to work fine, and that's the way it says to do it in the Blaster Rifle tutorial on the wiki, but what you say makes sense about needing to register on both sides.

EntitySteamBoat is registered below //Boat comment in Pchan3Mods class ("main" mod class).

I tend to register things in the "main" mod class, but any common class would do, actually.

 

I have looked at most generic tutorials so those are fine, but any other i won't comment on.

I think it is better to work things on your own, eventually taking examples from similar mods.

But do not take other mods as absolute reference material. Anyone can make mistakes.

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

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

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