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

Ok, so I have a new weapon called ItemXBow.  When it's right-clicked, I had it spawn a new projectile called EntityXBowBolt.  However, it continues to render as a small cube, even though I set its render class to be RenderXBowBolt and used a custom model(ModelXBowBolt).

 

 

EntityXBowBolt:

 

 

package com.caske2000.carnivores.entity;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.World;

public class EntityXBowBolt extends EntityThrowable {

private int lifeTime = 400;
private double speed = 2.01;
private final int damage = 8;

public EntityXBowBolt(World world) {

	super(world);
	setSize(0.5F, 0.5F);

}

public EntityXBowBolt(World world, EntityLivingBase entity, float p_i1756_3_) {

	super(world, entity);

}

public EntityXBowBolt(World world, double var2, double var3, double var4) {

	super(world, var2, var3, var4);

}

@Override
protected void onImpact(MovingObjectPosition movObjPos) {

	if (movObjPos.typeOfHit == MovingObjectType.ENTITY) {

		movObjPos.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);

	} else if (movObjPos.typeOfHit == MovingObjectType.BLOCK) {

	}

	this.setDead();

}

/*
 * @Override protected float getGravityVelocity() {
 * 
 * this.motionX *= speed; this.motionY *= speed; this.motionZ *= speed;
 * return 0;
 * 
 * }
 */

public int getMaxLifetime() {
	return 400;
}

public float getAirResistance() {
	return 0.0F;
}

public float getGravity() {
	return 0.0F;
}

public int getMaxArrowShake() {
	return 0;
}

}

 

 

 

ModelXBowBolt.java:

 

 

 

 

 

 

package com.caske2000.carnivores.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelXBowBolt extends ModelBase
{
  //fields
    ModelRenderer bolt;
  
  public ModelXBowBolt()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      bolt = new ModelRenderer(this, 0, 0);
      bolt.addBox(0F, 0F, 0F, 1, 1, 16);
      bolt.setRotationPoint(0F, 0F, 0F);
      bolt.setTextureSize(64, 32);
      bolt.mirror = false;
      setRotation(bolt, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    bolt.render(f5);
  }
  
  public void renderModel(float f)
  {
    bolt.render(f);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

 

 

RenderXBowBolt.java:

 

 

package com.caske2000.carnivores.render;

import org.lwjgl.opengl.GL11;

import com.caske2000.carnivores.entity.EntityXBowBolt;
import com.caske2000.carnivores.model.ModelXBowBolt;
import com.caske2000.carnivores.reference.Reference;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderArrow;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

public class RenderXBowBolt extends RenderArrow {

private static final ResourceLocation boltEntity = new ResourceLocation(Reference.MODID + ":" + "textures/entity/xbowbolt.png");

private ModelBase model;

public RenderXBowBolt() {

	super();
	shadowSize = 0.5F;
	model = new ModelXBowBolt();
}

@Override
public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) {
	GL11.glPushMatrix();
	this.bindTexture(boltEntity);
	GL11.glTranslatef((float) d, (float) d1, (float) d2);
	model.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
	Tessellator tessellator = Tessellator.instance;
	float f2 = 0.0F;
	float f3 = 0.3125F;
	float f10 = 0.05625F;
	GL11.glEnable(32826);
	GL11.glScalef(1.0F, 1.0F, 1.0F);
	GL11.glNormal3f(f10, 0.0F, 0.0F);
	GL11.glNormal3f(-f10, 0.0F, 0.0F);
	for (int j = 0; j < 4; j++) {
		GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
		GL11.glNormal3f(0.0F, 0.0F, f10);
	}
	GL11.glDisable(32826);
	GL11.glPopMatrix();

}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	// TODO Auto-generated method stub
	return getCustomTexture((EntityXBowBolt) entity);
}
protected ResourceLocation getCustomTexture(EntityXBowBolt entity) {

	return boltEntity;

}

}

 

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.