Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Okay, here's my code

package net.railowar.src;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;

public class EntityLocoChe extends Entity
{
public EntityLocoChe(World par1World)
    {
        super(par1World);
}

public EntityLocoChe(World world, double d, double d1, double d2)
    {
        this(world);
        setPosition(d, d1, d2);
        setSize(1.0F, 1.0F);
    }

protected void entityInit(){}


public AxisAlignedBB getCollisionBox(Entity entity)
    {
        return entity.boundingBox;
    }

    public AxisAlignedBB getBoundingBox()
    {
        return boundingBox;
    }
    
    public boolean canBeCollidedWith()
    {
        return true;
    }
    
    public boolean canBePushed()
    {
        return true;
    }

    public void writeEntityToNBT(NBTTagCompound nbttagcompound)
    {
    }

    public void readEntityFromNBT(NBTTagCompound nbttagcompound)
    {
    }

    protected int getDropItemId()
    {
        return 0;
    }
}

EntityRegistry.registerModEntity(EntityLocoChe.class, "Cherepanov", cpw.mods.fml.common.registry.EntityRegistry.findGlobalUniqueEntityId(), this, 64, 1, true);

public void addRenderer(Map map)
{
	map.put(net.railowar.src.EntityLocoChe.class, new RenderLocoChe());
}

package net.railowar.src;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemChe extends Item
{
    public ItemChe(int par1)
    {
        super(par1);
        this.maxStackSize = 1;
        this.setCreativeTab(CreativeTabs.tabTransport);
    }

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3)
    {
        if (!par3.capabilities.isCreativeMode)
        {
            --par1ItemStack.stackSize;
        }

        par2World.playSoundAtEntity(par3, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityLocoChe(par2World, par3.posX, par3.posY, par3.posZ));
        }

        return par1ItemStack;
    }
}

And it doesn't spawn... What's wrong with that?

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

cpw.mods.fml.common.registry.EntityRegistry.findGlobalUniqueEntityId()

This is wrong. The parameter is the mod-unique Entity ID, meaning you can / have to begin with 0 and counting up.

 

Also where does this method get called?

addRenderer(Map map)

 

EDIT: Also you should call the super methods for these:


    public void writeEntityToNBT(NBTTagCompound nbttagcompound)
    {
    }

    public void readEntityFromNBT(NBTTagCompound nbttagcompound)
    {
    }

 

since it won't write it to the world save (except that is intended)

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.

  • Author

Okay.

addRender goes to the main mod class.

 

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author

Oh, i had to add an entityInit(){} method, even if it's empty. Now i have to make it render my model...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Oh, i had to add an entityInit(){} method, even if it's empty. Now i have to make it render my model...

 

Okay.

addRender goes to the main mod class.

 

and where do you call it? You know it doesn't magically get called by Forge, as it's not a BaseMod class...

You need to have a proxy method called registerRenderer or something (it's up to you) and in the Client Proxy, use RenderingRegistry.registerEntityRenderer (or something like that) inside that method.

Call it tn your main class (preferably in your @Init method) like "proxy.registerRenderers()"

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.

  • Author

What proxy in minecraft actually is? How do i use it?.. I was out of modding for a while and in past times all was gut and without any proxies...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Look at this, it explains everything pretty well: http://www.minecraftforge.net/wiki/Basic_Modding

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.

  • Author

Yay! Instead all that shit that i still don't understand, i just had to put

RenderingRegistry.registerEntityRenderingHandler(net.railowar.src.EntityLocoChe.class, new RenderLocoChe());

into my load method. No public void addRenderer or proxies are needed. Also, calling super method in write/readtonbt crashed the game, but it saves my locomotives without it.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Yay! Instead all that shit that i still don't understand, i just had to put

RenderingRegistry.registerEntityRenderingHandler(net.railowar.src.EntityLocoChe.class, new RenderLocoChe());

into my load method. No public void addRenderer or proxies are needed. Also, calling super method in write/readtonbt crashed the game, but it saves my locomotives without it.

 

But if you call this on a dedicated server, it will crash. That's why proxies are there for.

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.

  • Author

But i still don't understand how to use them...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

But i still don't understand how to use them...

 

http://www.minecraftforge.net/wiki/Basic_Modding#Proxy_Classes

 

Please explain what don't you understand there?

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.

  • Author

I don't have items.png file, i have many different ones...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

I don't have items.png file, i have many different ones...

 

You mean this?

                MinecraftForgeClient.preloadTexture(ITEMS_PNG);
                MinecraftForgeClient.preloadTexture(BLOCK_PNG);

 

Just ignore that, it's a leftover from the old texture system. Put your Entity Render register method there instead.

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.

  • Author

Oh, now it finally works. Have i said i love you?

Now i'm having problems with making the physics of my wagen... And making my blocks to brake...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.