Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Lolcroc

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by Lolcroc

  1. Hi,

     

    So basically what i want to do is make a mob that throws something which it is attached to him with a rope. Both entities have models and renderers. The thing that he throws extends EntityThrowable and it is created in the attackEntityWithRangedAttack method (all mobs implementing the interface IRangedAttackMob need that), much like a snowball in EntitySnowman.

     

    Rendering the rope is the same as rendering the leash: i literally copied it from RenderLiving since there is no real other way to do it. The first line of func_110827_b (the method responsible for rendering the leash) is the entity that needs to be connected to the current entityliving it is rendering:

    Entity entity = par1EntityLiving.func_110166_bE();
    

    In my case, that entity is the thing it's throwing. What I did however is the following:

     

    I copied everything nested in the if statement of func_110827_b and made a new method for it in the renderer of the thing that gets thrown, so NOT the mob. I added a new parameter:

    func_110827_b(EntityLiving par1EntityLiving, EntityThatIsThrown thrown, double par2, double par4, double par6, float par8, float par9)
    

    and called it like this: (All the other parameters are directly from the doRender method it is called in)

    func_110827_b(thrown.getThrower(), thrown, par2, par4, par6, par8, par9)
    

     

    But here's the problem: getThrower() is null. This is because attackEntityWithRangedAttack is only called on the server, and so is the thrower field in the thrown entity. Is there any way to get the thrower on the client?

  2. Well, this one is easy to fix:

     

    map.put(net.smcrafting.src.EntityMagicBullet.class, new RenderSnowball(this.MagicBullet.getIconFromDamage(0)));

     

    You said it to get icon index 0. If you go into RenderSnowBall, you can see that in doRender it uses: this.loadTexture("/gui/items.png");

    And  icon index 0 in items.png is, you guessed it, a leather helmet.

     

    So there's no other way then to create a custom render class (like RenderMagicBullet) and do this.loadTexture("your path here"); in the doRender method. (You can copy the RenderSnowBall class for this I guess...)

     

    When you're done, don't forget to change

    map.put(net.smcrafting.src.EntityMagicBullet.class, new RenderSnowball(this.MagicBullet.getIconFromDamage(0)));
    

    to:

    map.put(net.smcrafting.src.EntityMagicBullet.class, new RenderMagicBullet(this.MagicBullet.getIconFromDamage(0)));
    

  3. Look at TileEntitySign and TileEntitySignRenderer for this.

     

    You can create a tile entity to store a String of text, then use the FontRenderer.drawString(...) method to draw the String from the NBTTag on the tile entity.

  4. Sure, here are my source files:

     

    @Init
    public void load(FMLInitializationEvent event) {
    proxy.registerRenderers();
    registerEntity(EntityFireBolt.class, new RenderBolt(0), "fireBolt", "a hot ball of fire", 1, 64, 10, true);
    }
    

    private void registerEntity(Class <? extends Entity> entityClass, Render renderer, String entityName, String description, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) {
    	RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer);
    	EntityRegistry.registerModEntity(entityClass, entityName, id, Scrolls.instance, trackingRange, updateFrequency, sendsVelocityUpdates);
    	LanguageRegistry.instance().addStringLocalization("entity.Scrolls." + entityName + ".name", description);
    }
    

    One of the entities:

    public class EntityEarthBolt extends EntityBolt {
    public EntityEarthBolt(World world) {
    	super(world);
    }
    
    public EntityEarthBolt(World world, EntityLiving entity, double powerMod) {
            super(world, entity, powerMod, 10);
        }
    }
    

    As you can see EntityBolt is a throwable. I'm just showing the necessary stuff here

    public class EntityBolt extends EntityThrowable {
        public EntityBolt(World world) {
            super(world);
        }
    
        public EntityBolt(World world, EntityLiving entity, double powerMod, int defaultDamage) {
            super(world, entity);
        }
    

    The paramater type in the constructor is just something I added, you don't need it

    public class RenderBolt extends Render {
    
    public ModelBase modelbolt;
    public float rotationSpeed;
    
    public RenderBolt(int type) {
    	modelbolt = new ModelBolt(type);
    }
    
    public void doRenderBolt(EntityBolt var1, double var2, double var4, double var6, float var8, float var9) {
            float var10 = (float)var1.innerRotation + var9;
    	GL11.glPushMatrix();
            GL11.glTranslatef((float)var2, (float)var4, (float)var6);
            this.loadTexture(CommonProxy.BOLTS_PNG);
            modelbolt.render(var1, 0.0F, var10 * this.rotationSpeed, 0.0F, 0.0F, 0.0F, 0.0625F);
            GL11.glPopMatrix();
    }
    
    @Override
        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
            this.doRenderBolt((EntityBolt)par1Entity, par2, par4, par6, par8, par9);
        }
    }
    

    Last but not least, the model:

    Please not that the rotations in render(...) are not necessary

    public class ModelBolt extends ModelBase {
    
    public ModelRenderer box;
    public ModelRenderer box0;
    public ModelRenderer box1;
    
    public ModelBolt(int type) {
    	this.textureWidth = 128;
    	this.textureHeight = 48;
    
    	box = new ModelRenderer(this, type*32, 0);
    	box.addBox(-4F, -4F, -4F, 8, 8, ;
    	box.setRotationPoint(0F, 0F, 0F);
    
    	box0 = new ModelRenderer(this, type*32, 16);
    	box0.addBox(-4F, -4F, -4F, 8, 8, ;
    	box0.setRotationPoint(0F, 0F, 0F);
    
    	box1 = new ModelRenderer(this, type*32, 32);
    	box1.addBox(-4F, -4F, -4F, 8, 8, ;
    	box1.setRotationPoint(0F, 0F, 0F);
    }
    
    @Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {	
    	GL11.glPushMatrix();
            GL11.glRotatef(30.0F, 0.7F, 0.0F, 0.7F);
            GL11.glRotatef(f1, 0.0F, 1.0F, 0.0F);
            this.box.render(f5);
            GL11.glRotatef(60.0F, 0.8F, 0.0F, 0.8F);
            GL11.glRotatef(f1, 0.0F, 1.0F, 0.0F);
            this.box0.render(f5);
            GL11.glRotatef(90.0F, 0.9F, 0.0F, 0.9F);
            GL11.glRotatef(f1, 0.0F, 1.0F, 0.0F);
            this.box1.render(f5);
            GL11.glPopMatrix();
    }
    }
    

     

    EDIT:

    What the hell is mainModel here?

    field_40295_c = (ModelVampire)mainModel;

    It should be:

    field_40295_c = new ModelVampire();

  5. RenderingRegistry.registerEntityRenderingHandler(EntityVampire.class, new RenderLiving(new ModelVampire(),0.5F));
    

     

    RenderLiving should be your own renderer

     

    ModLoader.getUniqueEntityId()
    

    Doesn't work for me. As soon as i register 2 entities one overwrites the other.

     

    And use @Override above methods you are overriding. It is possible that one of your method names is outdated and doesn't work anymore

  6. I don't need the potions, but potioneffect gets its effect from the potion id. The current potiontypes array only has 32 elements and 20 or so are already occupied by existing potion effects. Is there any way to make more than 32 potions?

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.