Created
August 2, 2014 17:35
-
-
Save MultiMote/351c23bd73b1d4d88ff1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.multimote.microz.item.render; | |
import com.multimote.microz.item.model.*; | |
import com.multimote.microz.utils.DebugData; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.client.model.ModelBase; | |
import net.minecraft.client.renderer.entity.RenderManager; | |
import net.minecraft.client.renderer.entity.RenderPlayer; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.ResourceLocation; | |
import net.minecraftforge.client.IItemRenderer; | |
import org.lwjgl.opengl.GL11; | |
import scala.collection.parallel.ParIterableLike; | |
/** | |
* Created by multimote on 08.06.14. | |
*/ | |
public class MeleeWeaponRenderer implements IItemRenderer { | |
private ModelBase modelBase; | |
private static final ResourceLocation htex = new ResourceLocation("microz:textures/modelled/hatchet.png"); | |
private static final ResourceLocation ctex = new ResourceLocation("microz:textures/modelled/crowbar.png"); | |
private static final ResourceLocation mtex = new ResourceLocation("microz:textures/modelled/machete.png"); | |
private static final ResourceLocation stex = new ResourceLocation("microz:textures/modelled/showel.png"); | |
private static final ResourceLocation ptex = new ResourceLocation("microz:textures/modelled/pick.png"); | |
private ResourceLocation tex; | |
public MeleeWeaponRenderer(ModelBase model){ | |
// modelBase = new HatchetModel(); | |
this.modelBase = model; | |
if(modelBase instanceof HatchetModel) | |
tex = htex; | |
else if(modelBase instanceof CrowbarModel) | |
tex = ctex; | |
else if(modelBase instanceof MacheteModel) | |
tex = mtex; | |
else if(modelBase instanceof ShowelModel) | |
tex = stex; | |
else if(modelBase instanceof PickaxeModel) | |
tex = ptex; //кудах | |
} | |
@Override | |
public boolean handleRenderType(ItemStack item, ItemRenderType type) { | |
return true; | |
} | |
@Override | |
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { | |
switch (type) { | |
case INVENTORY: | |
return true; | |
default: | |
break; | |
} | |
return false; | |
} | |
@Override | |
public void renderItem(ItemRenderType type, ItemStack item, Object... data) { | |
switch (type) { | |
case EQUIPPED: | |
GL11.glPushMatrix(); | |
Minecraft.getMinecraft().renderEngine.bindTexture(tex); | |
GL11.glTranslatef(0.4F, 0.5F, 0.1F); | |
GL11.glScalef(1.7F, 1.7F, 1.7F); | |
GL11.glRotatef(-75.0F, 1.0F, 0.0F, 0.0F); | |
GL11.glRotatef(170.0F, 0.0F, 1.0F, 0.0F); | |
GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); | |
modelBase.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, | |
0.0625F); | |
GL11.glPopMatrix(); | |
break; | |
case EQUIPPED_FIRST_PERSON: | |
GL11.glPushMatrix(); | |
/*GL11.glPushMatrix(); | |
Minecraft mc = Minecraft.getMinecraft(); | |
mc.getTextureManager().bindTexture(mc.thePlayer.getLocationSkin()); | |
GL11.glTranslatef(0.2F, 0.4F, -0.4F); | |
DebugData.glWorkwoScale(); | |
RenderPlayer render =(RenderPlayer) RenderManager.instance.getEntityRenderObject(mc.thePlayer); | |
float f10 = 1.0F; | |
GL11.glScalef(f10, f10, f10); | |
render.renderFirstPersonArm(mc.thePlayer); | |
GL11.glPopMatrix();*/ | |
Minecraft.getMinecraft().renderEngine.bindTexture(tex); | |
GL11.glTranslatef(0.2F, 0.4F, -0.4F); | |
GL11.glRotatef(85.0F, 1.0F, 0.0F, 0.0F); | |
GL11.glRotatef(35.0F, 0.0F, 1.0F, 0.0F); | |
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); | |
modelBase.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, | |
0.0625F); | |
GL11.glPopMatrix(); | |
break; | |
case ENTITY: | |
GL11.glPushMatrix(); | |
GL11.glScalef(2F, 2F, 2F); | |
Minecraft.getMinecraft().renderEngine.bindTexture(tex); | |
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); | |
GL11.glTranslatef(-0.1F, 0.0F, 0.0F); | |
if(modelBase instanceof ShowelModel) { | |
GL11.glTranslatef(0.04F, 0.0F, 0.0F); | |
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); | |
} | |
modelBase.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, | |
0.0625F); | |
GL11.glPopMatrix(); | |
break; | |
case INVENTORY: | |
GL11.glPushMatrix(); | |
if(modelBase instanceof ShowelModel) | |
GL11.glScalef(0.8F, 0.8F, 0.8F); | |
else if(modelBase instanceof PickaxeModel) | |
GL11.glScalef(1.1F, 1.1F, 1.1F); | |
else | |
GL11.glScalef(1.5F, 1.5F, 1.5F); | |
Minecraft.getMinecraft().renderEngine.bindTexture(tex); | |
GL11.glTranslatef(0.0F, 0.0F, 0.0F); | |
GL11.glRotatef(33.0F, 1.0F, 0.0F, 0.0F); | |
GL11.glRotatef(-132.0F, 0.0F, 0.0F, 1.0F); | |
if(modelBase instanceof ShowelModel) | |
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); | |
modelBase.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, | |
0.0625F); | |
// modelBase.render(0.0625F); | |
GL11.glPopMatrix(); | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment