Jump to content

Recommended Posts

Posted

Hello,

 

I'm trying to render a model I imported/exported from Techne, but the model does not appear anywhere near the player. I added in prints to see if it was rendering, it was.

 

KnifeRenderer:

package csgocases.render;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.model.ModelBase;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

public class KnifeRenderer implements IItemRenderer {
public final ModelBase model;

public KnifeRenderer(ModelBase model) {
	super();

	this.model = model;
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return type == ItemRenderType.EQUIPPED;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
	return false;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	if(type == ItemRenderType.EQUIPPED) {
		EntityClientPlayerMP entity = (EntityClientPlayerMP) data[1];

		GL11.glPushMatrix();
		GL11.glTranslatef(0, 4, 0);

		model.render(entity, 0, 0, 0, 0, 0, 0);

		GL11.glPopMatrix();
	}
}
}

 

ModelBayonet:

package csgocases.model;

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

public class ModelBayonet extends ModelBase {
ModelRenderer handle;
ModelRenderer bottomHandle;
ModelRenderer guard1;
ModelRenderer guard3;
ModelRenderer guard2;
ModelRenderer guard4;
ModelRenderer guard5;
ModelRenderer blade1;
ModelRenderer blade2;
ModelRenderer blade3;
ModelRenderer blade4;
ModelRenderer blade5;
ModelRenderer blade7;
ModelRenderer blade8;

public ModelBayonet() {
	textureWidth = 128;
	textureHeight = 64;

	handle = new ModelRenderer(this, 0, 0);
	handle.addBox(0F, 0F, 0F, 12, 32, 6);
	handle.setRotationPoint(-6F, -9F, -3F);
	handle.setTextureSize(128, 64);
	handle.mirror = true;
	setRotation(handle, 0F, 0F, 0F);

	bottomHandle = new ModelRenderer(this, 36, 0);
	bottomHandle.addBox(0F, 0F, 0F, 14, 1, ;
	bottomHandle.setRotationPoint(-7F, 23F, -4F);
	bottomHandle.setTextureSize(128, 64);
	bottomHandle.mirror = true;
	setRotation(bottomHandle, 0F, 0F, 0F);

	guard1 = new ModelRenderer(this, 36, 9);
	guard1.addBox(0F, 0F, 0F, 13, 1, ;
	guard1.setRotationPoint(-6F, -10F, -4F);
	guard1.setTextureSize(128, 64);
	guard1.mirror = true;
	setRotation(guard1, 0F, 0F, 0F);

	guard3 = new ModelRenderer(this, 80, 0);
	guard3.addBox(0F, 0F, 0F, 1, 1, 6);
	guard3.setRotationPoint(7F, -10F, -3F);
	guard3.setTextureSize(128, 64);
	guard3.mirror = true;
	setRotation(guard3, 0F, 0F, 0F);

	guard2 = new ModelRenderer(this, 94, 0);
	guard2.addBox(0F, 0F, 0F, 7, 1, 1);
	guard2.setRotationPoint(-13F, -10F, -4F);
	guard2.setTextureSize(128, 64);
	guard2.mirror = true;
	setRotation(guard2, 0F, 0F, 0F);

	guard4 = new ModelRenderer(this, 94, 0);
	guard4.addBox(0F, 0F, 0F, 7, 1, 1);
	guard4.setRotationPoint(-13F, -10F, 3F);
	guard4.setTextureSize(128, 64);
	guard4.mirror = true;
	setRotation(guard4, 0F, 0F, 0F);

	guard5 = new ModelRenderer(this, 94, 0);
	guard5.addBox(0F, 0F, 0F, 6, 1, 1);
	guard5.setRotationPoint(-12F, -10F, -3F);
	guard5.setTextureSize(128, 64);
	guard5.mirror = true;
	setRotation(guard5, 0F, -1.570796F, 0F);

	blade1 = new ModelRenderer(this, 36, 18);
	blade1.addBox(0F, 0F, 0F, 9, 32, 2);
	blade1.setRotationPoint(-5.5F, -42F, -1F);
	blade1.setTextureSize(128, 64);
	blade1.mirror = true;
	setRotation(blade1, 0F, 0F, 0F);

	blade2 = new ModelRenderer(this, 58, 18);
	blade2.addBox(0F, 0F, 0F, 3, 32, 1);
	blade2.setRotationPoint(3.5F, -42F, -0.5F);
	blade2.setTextureSize(128, 64);
	blade2.mirror = true;
	setRotation(blade2, 0F, 0F, 0F);

	blade3 = new ModelRenderer(this, 0, 38);
	blade3.addBox(0F, 0F, 0F, 4, 19, 2);
	blade3.setRotationPoint(-3.85F, -60.9F, -1F);
	blade3.setTextureSize(128, 64);
	blade3.mirror = true;
	setRotation(blade3, 0F, 0F, 0.0872665F);

	blade4 = new ModelRenderer(this, 66, 18);
	blade4.addBox(0F, 0F, 0F, 3, 18, 1);
	blade4.setRotationPoint(3.366667F, -59.7F, 0.5F);
	blade4.setTextureSize(128, 64);
	blade4.mirror = true;
	setRotation(blade4, 0F, 3.141593F, 0.1745329F);

	blade5 = new ModelRenderer(this, 66, 37);
	blade5.addBox(0F, 0F, 0F, 2, 19, 2);
	blade5.setRotationPoint(-1.8F, -60F, -1F);
	blade5.setTextureSize(128, 64);
	blade5.mirror = true;
	setRotation(blade5, 0F, 0F, -0.1745329F);

	blade7 = new ModelRenderer(this, 58, 51);
	blade7.addBox(0F, 0F, 0F, 3, 6, 1);
	blade7.setRotationPoint(-1.5F, -62.8F, 0.5F);
	blade7.setTextureSize(128, 64);
	blade7.mirror = true;
	setRotation(blade7, 3.141593F, 0F, 2.190781F);

	blade8 = new ModelRenderer(this, 12, 38);
	blade8.addBox(0F, 0F, 0F, 3, 3, 2);
	blade8.setRotationPoint(-3.85F, -60.9F, 1F);
	blade8.setTextureSize(128, 64);
	blade8.mirror = true;
	setRotation(blade8, 3.141593F, 0F, 0.896934F);
}

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);

	handle.render(f5);
	bottomHandle.render(f5);
	guard1.render(f5);
	guard3.render(f5);
	guard2.render(f5);
	guard4.render(f5);
	guard5.render(f5);
	blade1.render(f5);
	blade2.render(f5);
	blade3.render(f5);
	blade4.render(f5);
	blade5.render(f5);
	blade7.render(f5);
	blade8.render(f5);
}

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);
}

}

 

ClientProxyCS:

package csgocases;

import net.minecraftforge.client.MinecraftForgeClient;
import tlhpoeCore.TLHPoE;
import csgocases.model.ModelBayonet;
import csgocases.render.KnifeRenderer;

public class ClientProxyCS extends ServerProxyCS {
@Override
public void initClient() {
	TLHPoE.registerUpdateDetector(ReferenceCS.ID, ReferenceCS.NAME, ReferenceCS.VERSION, "0B6mhkrh-GwwwcFRXTGFiTlpqN1U");

	MinecraftForgeClient.registerItemRenderer(ServerProxyCS.bayonet, new KnifeRenderer(new ModelBayonet()));
}
}

 

ServerProxyCS:

package csgocases;

import net.minecraft.item.Item;
import cpw.mods.fml.common.registry.GameRegistry;
import csgocases.item.ItemKnife;

public class ServerProxyCS {
public static Item bayonet = new ItemKnife("bayonet");

public void initServer() {
	register(bayonet);
}

public void initClient() {
}

private static void register(Item item) {
	GameRegistry.registerItem(item, item.getUnlocalizedName());
}
}

 

ItemKnife:

package csgocases.item;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import tf2crates.ReferenceTC;
import tf2crates.ServerProxyTC;
import tf2crates.entity.EntityDamageSourceBackstab;
import tlhpoeCore.network.MessagePlaySound;
import csgocases.ReferenceCS;

public class ItemKnife extends ItemSword {
public static double backstabDifficulty = 0.75D;

public ItemKnife(String name) {
	super(ToolMaterial.EMERALD);

	this.setUnlocalizedName(name);
	this.setTextureName(ReferenceCS.ID + ":" + name);
}

@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase prey, EntityLivingBase attacker) {
	itemStack.damageItem(1, attacker);

	float pYaw = prey.rotationYawHead % 360F;

	pYaw = pYaw < 0 ? 360 + pYaw : prey.rotationYawHead;

	float aYaw = attacker.rotationYawHead < 0 ? 360 + attacker.rotationYawHead : attacker.rotationYawHead;

	float newRot = pYaw - aYaw;

	if(newRot < (90 * backstabDifficulty) && newRot > (-90 * backstabDifficulty)) {
		if(!attacker.worldObj.isRemote) {
			new MessagePlaySound(ReferenceTC.ID + ":tf2crates.crit").sendTo((EntityPlayerMP) attacker);
		}

		if(itemStack.getItem() == ServerProxyTC.conniversKunai) {
			attacker.heal(prey.getMaxHealth());
		}

		prey.attackEntityFrom(EntityDamageSourceBackstab.causeBackstabDamage(attacker), prey.getMaxHealth() * 600);
	}

	return false;
}
}

Kain

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



×
×
  • Create New...

Important Information

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