mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-27 23:45:48 +00:00
First merging of weaponry into tinkers
This commit is contained in:
1 parent
6e1ea0e736
commit
73b25d19f0
191 files changed
+5325
-1
No files matched your search
@@ -0,0 +1,57 @@
|
||||
package boni.tinkersweaponry.client;
|
||||
|
||||
import boni.tinkersweaponry.library.weaponry.ProjectileWeapon;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
|
||||
public class AmmoSlotHandler {
|
||||
@SubscribeEvent
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
if(event.type != RenderGameOverlayEvent.ElementType.HOTBAR)
|
||||
return;
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
|
||||
if(equipped == null || equipped.getItem() == null)
|
||||
return;
|
||||
if(!(equipped.getItem() instanceof ProjectileWeapon))
|
||||
return;
|
||||
|
||||
// find ammo
|
||||
// todo: cache this somehow?
|
||||
ItemStack ammo = ((ProjectileWeapon) equipped.getItem()).searchForAmmo(player, equipped);
|
||||
if(ammo == null)
|
||||
return;
|
||||
|
||||
// check if it's in the inventory
|
||||
int slot = -1;
|
||||
for(int i = 0; i < 9; i++)
|
||||
if(player.inventory.mainInventory[i] == ammo)
|
||||
{
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
|
||||
// not in the hotbar
|
||||
if(slot == -1)
|
||||
return;
|
||||
|
||||
int x = event.resolution.getScaledWidth() / 2 - 90 + slot * 20 + 2;
|
||||
int z = event.resolution.getScaledHeight() - 16 - 3;
|
||||
|
||||
int col = 0;
|
||||
col |= 120 << 16; // red
|
||||
col |= 150 << 8; // green
|
||||
col |= 200 << 0; // blue
|
||||
col |= 200 << 24; // alpha
|
||||
|
||||
// render a cool underlay thing
|
||||
Gui.drawRect(x,z, x+16, z+16, col);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package boni.tinkersweaponry.client;
|
||||
|
||||
import boni.tinkersweaponry.util.Reference;
|
||||
import boni.tinkersweaponry.library.weaponry.IWindup;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class CrosshairHandler {
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static ResourceLocation crossHairSquare = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair.png");
|
||||
private static ResourceLocation crossHairTip = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair2.png");
|
||||
private static ResourceLocation crossHairWeird = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair3.png");
|
||||
private static ResourceLocation crossHairSpike = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair4.png");
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
if(event.type != RenderGameOverlayEvent.ElementType.CROSSHAIRS)
|
||||
return;
|
||||
|
||||
ItemStack equipped = mc.thePlayer.getCurrentEquippedItem();
|
||||
if(equipped == null || equipped.getItem() == null)
|
||||
return;
|
||||
if(!(equipped.getItem() instanceof IWindup))
|
||||
return;
|
||||
|
||||
IWindup weapon = (IWindup) equipped.getItem();
|
||||
|
||||
float width = event.resolution.getScaledWidth();
|
||||
float height = event.resolution.getScaledHeight();
|
||||
|
||||
int type = 0;
|
||||
ResourceLocation tex;
|
||||
switch (weapon.getCrosshairType())
|
||||
{
|
||||
case SQUARE: tex = crossHairSquare; break;
|
||||
case TIP: tex = crossHairTip; break;
|
||||
case WEIRD: tex = crossHairWeird; type = 1; break;
|
||||
case SPIKE: tex = crossHairSpike; type = 1; break;
|
||||
default: tex = crossHairSquare; type = 0;
|
||||
}
|
||||
|
||||
mc.getTextureManager().bindTexture(tex);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0);
|
||||
|
||||
float spread = ((1.0f - weapon.getWindupProgress(equipped, mc.thePlayer)) * 25f);
|
||||
|
||||
// 4 square crosshair
|
||||
if(type == 0) {
|
||||
drawCrosshairPart(width / 2f - spread, height / 2f - spread, 0);
|
||||
drawCrosshairPart(width / 2f + spread, height / 2f - spread, 1);
|
||||
drawCrosshairPart(width / 2f - spread, height / 2f + spread, 2);
|
||||
drawCrosshairPart(width / 2f + spread, height / 2f + spread, 3);
|
||||
}
|
||||
// 4 triangle crosshair
|
||||
else {
|
||||
drawAlternateCrosshairPart(width/2f, height/2f - spread, 0);
|
||||
drawAlternateCrosshairPart(width/2f - spread, height/2f, 1);
|
||||
drawAlternateCrosshairPart(width/2f + spread, height/2f, 2);
|
||||
drawAlternateCrosshairPart(width/2f, height/2f + spread, 3);
|
||||
}
|
||||
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
private void drawCrosshairPart(float width, float height, int part)
|
||||
{
|
||||
double w = (double)width;
|
||||
double h = (double)height;
|
||||
|
||||
double s = 4;
|
||||
double z = -90;
|
||||
|
||||
double u1 = 0;
|
||||
double v1 = 0;
|
||||
|
||||
switch(part)
|
||||
{
|
||||
// top left
|
||||
case 0:
|
||||
w -= s;
|
||||
h -= s;
|
||||
break;
|
||||
case 1:
|
||||
u1 = 0.5;
|
||||
w += s;
|
||||
h -= s;
|
||||
break;
|
||||
case 2:
|
||||
v1 = 0.5;
|
||||
w -= s;
|
||||
h += s;
|
||||
break;
|
||||
case 3:
|
||||
u1 = 0.5;
|
||||
v1 = 0.5;
|
||||
w += s;
|
||||
h += s;
|
||||
break;
|
||||
}
|
||||
|
||||
double u2 = u1 + 0.5;
|
||||
double v2 = v1 + 0.5;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, u1, v1);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, u1, v2);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, u2, v2);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, u2, v1);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private void drawAlternateCrosshairPart(float width, float height, int part)
|
||||
{
|
||||
double w = (double)width;
|
||||
double h = (double)height;
|
||||
|
||||
final double s = 8d;
|
||||
final double z = -90;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawing(GL11.GL_TRIANGLES); // 4
|
||||
// top part
|
||||
if(part == 0) {
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, 0, 0);
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, 1, 0);
|
||||
}
|
||||
// left part
|
||||
else if(part == 1) {
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, 0, 0);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, 0, 1);
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
}
|
||||
// right part
|
||||
else if(part == 2) {
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, 1, 1);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, 1, 0);
|
||||
}
|
||||
// bottom part
|
||||
else if(part == 3) {
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, 0, 1);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, 1, 1);
|
||||
}
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package boni.tinkersweaponry.client;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum CrosshairType {
|
||||
SQUARE,
|
||||
TIP,
|
||||
WEIRD,
|
||||
SPIKE
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package boni.tinkersweaponry.client;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
// required to fix Mojansg bugs...
|
||||
public class IconFlipped extends net.minecraft.client.renderer.IconFlipped {
|
||||
private final IIcon baseIcon;
|
||||
private final boolean flipV;
|
||||
|
||||
public IconFlipped(IIcon p_i1560_1_, boolean p_i1560_2_, boolean p_i1560_3_) {
|
||||
super(p_i1560_1_, p_i1560_2_, p_i1560_3_);
|
||||
|
||||
this.baseIcon = p_i1560_1_;
|
||||
this.flipV = p_i1560_3_;
|
||||
}
|
||||
|
||||
// has a faulty implementation in original class
|
||||
public float getMinV()
|
||||
{
|
||||
return this.flipV ? this.baseIcon.getMaxV() : this.baseIcon.getMinV();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package boni.tinkersweaponry.client;
|
||||
|
||||
import boni.tinkersweaponry.TinkerWeaponry;
|
||||
import boni.tinkersweaponry.library.weaponry.BowBaseAmmo;
|
||||
import boni.tinkersweaponry.library.weaponry.IWindup;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
public class RenderEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onAimZoom(FOVUpdateEvent event)
|
||||
{
|
||||
if(!event.entity.isUsingItem())
|
||||
return;
|
||||
|
||||
if(!(event.entity.getItemInUse().getItem() instanceof IWindup))
|
||||
return;
|
||||
|
||||
ItemStack weapon = event.entity.getItemInUse();
|
||||
IWindup item = (IWindup) weapon.getItem();
|
||||
|
||||
if(item.zoomOnWindup(weapon))
|
||||
event.newfov = event.fov / (event.fov + (item.getZoom(weapon)-1.0f) * item.getWindupProgress(weapon, event.entity));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderPlayer(RenderPlayerEvent.Pre event)
|
||||
{
|
||||
if(event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() == TinkerWeaponry.javelin) {
|
||||
|
||||
}
|
||||
|
||||
if(event.entityPlayer.getItemInUse() == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.getItemInUse().getItem() instanceof BowBaseAmmo) {
|
||||
event.renderer.modelBipedMain.aimedBow = true;
|
||||
event.renderer.modelArmor.aimedBow = true;
|
||||
event.renderer.modelArmorChestplate.aimedBow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package boni.tinkersweaponry.client.entityrenderer;
|
||||
|
||||
import boni.tinkersweaponry.entity.ArrowEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ArrowEntityRenderer extends ProjectileBaseRenderer<ArrowEntity> {
|
||||
private int count = 0;
|
||||
private final float size;
|
||||
|
||||
public ArrowEntityRenderer(float size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public ArrowEntityRenderer() {
|
||||
this(1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(ArrowEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
count = 0;
|
||||
super.doRender(entity, x, y, z, p_76986_8_, p_76986_9_);
|
||||
count = 1;
|
||||
super.doRender(entity, x, y, z, p_76986_8_, p_76986_9_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customRendering(ArrowEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
// flip it, flop it, pop it, pull it, push it, rotate it, translate it, TECHNOLOGY
|
||||
|
||||
GL11.glScalef(size, size, size);
|
||||
|
||||
// rotate it into the direction we threw it
|
||||
GL11.glRotatef(entity.rotationYaw, 0f, 1f, 0f);
|
||||
GL11.glRotatef(-entity.rotationPitch, 1f, 0f, 0f);
|
||||
|
||||
// rotate it so it's "upright"
|
||||
if(count == 0)
|
||||
GL11.glRotatef(90, 0f, 0f, 1f);
|
||||
|
||||
GL11.glRotatef(45, 0f, 0f, 1f);
|
||||
|
||||
// rotate it so it faces forward
|
||||
GL11.glRotatef(90f, 1f, 0f, 0f);
|
||||
|
||||
// rotate the projectile it so it faces upwards (because the graphic itself is rotated by 45°)
|
||||
GL11.glRotatef(-45, 0f, 0f, 1f);
|
||||
|
||||
// thinner arrows
|
||||
toolCoreRenderer.setDepth(1/64f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package boni.tinkersweaponry.client.entityrenderer;
|
||||
|
||||
import boni.tinkersweaponry.entity.JavelinEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class JavelinEntityRenderer extends ProjectileBaseRenderer<JavelinEntity> {
|
||||
@Override
|
||||
public void customRendering(JavelinEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
|
||||
// rotate it into the direction we threw it
|
||||
GL11.glRotatef(entity.rotationYaw, 0f, 1f, 0f);
|
||||
GL11.glRotatef(-entity.rotationPitch, 1f, 0f, 0f);
|
||||
|
||||
// rotate it so it faces forward
|
||||
GL11.glRotatef(90f, 1f, 0f, 0f);
|
||||
|
||||
// roll it all aroun
|
||||
GL11.glRotated(entity.roll, 0, 1, 0);
|
||||
|
||||
// make it looooong
|
||||
GL11.glScalef(1.5F, 3.0F, 1.5F);
|
||||
GL11.glTranslatef(0f, -0.5f, 0f);
|
||||
|
||||
// rotate the projectile it so it faces upwards (because the graphic itself is rotated by 45°)
|
||||
GL11.glRotatef(45, 0f, 0f, 1f);
|
||||
|
||||
toolCoreRenderer.setDepth(1/16f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package boni.tinkersweaponry.client.entityrenderer;
|
||||
|
||||
import boni.tinkersweaponry.client.renderer.FlexibleToolRenderer;
|
||||
import boni.tinkersweaponry.entity.ProjectileBase;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class ProjectileBaseRenderer<T extends ProjectileBase> extends Render {
|
||||
protected static FlexibleToolRenderer toolCoreRenderer = new FlexibleToolRenderer();
|
||||
|
||||
@Override
|
||||
public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) {
|
||||
doRender((T)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
||||
}
|
||||
|
||||
public void doRender(T entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
// preface: Remember that the rotations are applied in reverse order.
|
||||
// the rendering call does not apply any transformations.
|
||||
// That'd screw things up, since it'd be applied before our transformations
|
||||
// So remember to read this from the rendering call up to this line
|
||||
|
||||
// can be overwritten in customRendering
|
||||
toolCoreRenderer.setDepth(1/32f);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
// last step: translate from 0/0/0 to correct position in world
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
// mkae it smaller
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
|
||||
customRendering(entity, x, y, z, p_76986_8_, p_76986_9_);
|
||||
|
||||
// arrow shake
|
||||
float f11 = (float)entity.arrowShake - p_76986_9_;
|
||||
if (f11 > 0.0F)
|
||||
{
|
||||
float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
|
||||
GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
// draw correct texture. not some weird block fragments.
|
||||
renderManager.renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
// rendering code has been optimized to be exactly at the center and without translation
|
||||
toolCoreRenderer.renderItem(IItemRenderer.ItemRenderType.ENTITY, entity.getEntityItem());
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void customRendering(T entity, double x, double y, double z, float p_76986_8_, float p_76986_9_)
|
||||
{
|
||||
// flip it, flop it, pop it, pull it, push it, rotate it, translate it, TECHNOLOGY
|
||||
|
||||
// rotate it into the direction we threw it
|
||||
GL11.glRotatef(entity.rotationYaw, 0f, 1f, 0f);
|
||||
GL11.glRotatef(-entity.rotationPitch, 1f, 0f, 0f);
|
||||
|
||||
// rotate it so it's "upright"
|
||||
GL11.glRotatef(90, 0f, 0f, 1f);
|
||||
|
||||
// rotate it so it faces forward
|
||||
GL11.glRotatef(90f, 1f, 0f, 0f);
|
||||
|
||||
// rotate the projectile it so it faces upwards
|
||||
GL11.glRotatef(-45, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture (Entity par1Entity)
|
||||
{
|
||||
return this.func_110796_a((ProjectileBase) par1Entity);
|
||||
}
|
||||
|
||||
protected ResourceLocation func_110796_a (ProjectileBase par1ArrowEntity)
|
||||
{
|
||||
return this.renderManager.renderEngine.getResourceLocation(par1ArrowEntity.getEntityItem().getItemSpriteNumber());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package boni.tinkersweaponry.client.entityrenderer;
|
||||
|
||||
import boni.tinkersweaponry.entity.ShurikenEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ShurikenEntityRenderer extends ProjectileBaseRenderer<ShurikenEntity> {
|
||||
|
||||
@Override
|
||||
public void customRendering(ShurikenEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
// make it smaller
|
||||
GL11.glScalef(0.6F, 0.6F, 0.6F);
|
||||
|
||||
// rotate it into the direction we threw it
|
||||
GL11.glRotatef(entity.rotationYaw, 0f, 1f, 0f);
|
||||
GL11.glRotatef(-entity.rotationPitch, 1f, 0f, 0f);
|
||||
|
||||
// add some diversity
|
||||
GL11.glRotatef(entity.rollAngle, 0f, 0f, 1f);
|
||||
|
||||
// rotate it into a horizontal position
|
||||
GL11.glRotatef(90f, 1f, 0f, 0f);
|
||||
|
||||
// shurikens spin around their center a lot. *spin*
|
||||
GL11.glRotatef(entity.spin, 0f, 0f, 1f);
|
||||
|
||||
|
||||
// also make it a bit thicker
|
||||
toolCoreRenderer.setDepth(1/20f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package boni.tinkersweaponry.client.renderer;
|
||||
|
||||
import boni.tinkersweaponry.library.weaponry.IAmmo;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class AmmoItemRenderer extends FlexibleToolRenderer {
|
||||
//public static FontRenderer fontRenderer;
|
||||
|
||||
public AmmoItemRenderer() {
|
||||
// super(true);
|
||||
//fontRenderer = new FontRenderer(Minecraft.getMinecraft().gameSettings, new ResourceLocation(Reference.RESOURCE, "textures/font/border_numbers.png"), Minecraft.getMinecraft().renderEngine, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
if(type == ItemRenderType.INVENTORY)
|
||||
return true;
|
||||
|
||||
return super.handleRenderType(item, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
// render the item regularly
|
||||
super.renderItem(type, item, data);
|
||||
//RenderItem.getInstance().renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, item, 0,0);
|
||||
|
||||
if(item.getTagCompound() == null || type != ItemRenderType.INVENTORY)
|
||||
return;
|
||||
|
||||
// render custom stacksize
|
||||
renderAmmoCount(item);
|
||||
}
|
||||
|
||||
public void renderAmmoCount(ItemStack item)
|
||||
{
|
||||
if(!(item.getItem() instanceof IAmmo))
|
||||
return;
|
||||
int amount = ((IAmmo) item.getItem()).getAmmoCount(item);
|
||||
String str = String.valueOf(amount);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
GL11.glScalef(0.7f, 0.7f, 0.7f);
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
fontRenderer.drawStringWithShadow(str, 7 + 19 - 2 - fontRenderer.getStringWidth(str), 7 + 6 + 3, 16777215);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package boni.tinkersweaponry.client.renderer;
|
||||
|
||||
import boni.tinkersweaponry.TinkerWeaponry;
|
||||
import boni.tinkersweaponry.ammo.ArrowAmmo;
|
||||
import boni.tinkersweaponry.entity.ArrowEntity;
|
||||
import boni.tinkersweaponry.library.weaponry.ProjectileWeapon;
|
||||
import boni.tinkersweaponry.library.weaponry.IWindup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class BowRenderer extends FlexibleToolRenderer {
|
||||
private static final ArrowEntity dummy = new ArrowEntity(null);
|
||||
|
||||
@Override
|
||||
protected void specialAnimation(ItemRenderType type, ItemStack item) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
//GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||
GL11.glTranslatef(0.2F, -0.4F, 0.2f);
|
||||
GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
|
||||
//GL11.glScalef(f1, -f1, f1);
|
||||
//GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
// windup animation
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON && player.isUsingItem())
|
||||
{
|
||||
float progress = ((IWindup) item.getItem()).getWindupProgress(item, player);
|
||||
|
||||
//GL11.glScalef(1.2f, 1.2f, 1.2f);
|
||||
//float progress = ((IWindup) item.getItem()).getWindupProgress(item, Minecraft.getMinecraft().thePlayer);;
|
||||
GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); // tilts the bow forward a bit
|
||||
GL11.glRotatef(-6.0F, 0.0F, 1.0F, 0.0F); // rotates the bow so it faces more forward
|
||||
GL11.glRotatef(8.0F, 1.0F, 0.0F, 0.0F); // rotates the bow forward
|
||||
GL11.glTranslatef(-0.9F, 0.2F, -1.0F);
|
||||
|
||||
|
||||
// this does the "zoom closer to the bow" thing
|
||||
GL11.glTranslatef(progress * -0.1f, progress * -0.125f, 0.0F);
|
||||
|
||||
|
||||
|
||||
// we're crazy, so.. render the arrow =D
|
||||
ItemStack ammo = ((ProjectileWeapon) item.getItem()).searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
|
||||
if(ammo != null) {
|
||||
if(ammo.getItem() == Items.arrow)
|
||||
dummy.returnStack = ArrowAmmo.vanillaArrow;
|
||||
else
|
||||
dummy.returnStack = ammo;
|
||||
Render renderer = RenderManager.instance.getEntityClassRenderObject(ArrowEntity.class);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
// adjust position
|
||||
GL11.glScalef(2, 2, 2); // bigger
|
||||
GL11.glRotatef(90, 0, 1, 0); // rotate it into the same direction as the bow
|
||||
GL11.glRotatef(15, 0, 1, 0); // rotate it a bit more so it's not directly inside the bow
|
||||
GL11.glRotatef(-45, 1, 0, 0); // sprite is rotated by 45° in the graphics, correct that
|
||||
GL11.glTranslatef(0.05f, 0, 0); // same as the not-inside-bow-rotation
|
||||
|
||||
// move the arrow with the charging process
|
||||
float offset = 0.075f - 0.15f * progress;
|
||||
|
||||
GL11.glTranslatef(0, 0, offset);
|
||||
|
||||
// render iiit
|
||||
renderer.doRender(dummy, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
else if(type == ItemRenderType.EQUIPPED && player.isUsingItem())
|
||||
{
|
||||
// we're crazy, so.. render the arrow =D
|
||||
ItemStack ammo = ((ProjectileWeapon) item.getItem()).searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
|
||||
if(ammo != null) {
|
||||
if(ammo.getItem() == Items.arrow)
|
||||
dummy.returnStack = ArrowAmmo.vanillaArrow;
|
||||
else
|
||||
dummy.returnStack = ammo;
|
||||
Render renderer = RenderManager.instance.getEntityClassRenderObject(ArrowEntity.class);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
// adjust position
|
||||
GL11.glScalef(2, 2, 2); // bigger
|
||||
GL11.glRotatef(90, 0, 1, 0); // rotate it into the same direction as the bow
|
||||
GL11.glRotatef(15, 0, 1, 0); // rotate it a bit more so it's not directly inside the bow
|
||||
GL11.glRotatef(-45, 1, 0, 0); // sprite is rotated by 45° in the graphics, correct that
|
||||
GL11.glTranslatef(0.05f, 0, 0); // same as the not-inside-bow-rotation
|
||||
|
||||
// move the arrow with the charging process
|
||||
float offset = 0.075f - 0.15f * 1;
|
||||
|
||||
GL11.glTranslatef(0, 0, offset);
|
||||
|
||||
// render iiit
|
||||
renderer.doRender(dummy, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(item.getItem() == TinkerWeaponry.longbow)
|
||||
GL11.glScalef(2.3f, 2.3f, 1.0f);
|
||||
else if(item.getItem() == TinkerWeaponry.shortbow)
|
||||
GL11.glScalef(1.7f, 1.7f, 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package boni.tinkersweaponry.client.renderer;
|
||||
|
||||
import boni.tinkersweaponry.entity.ArrowEntity;
|
||||
import boni.tinkersweaponry.entity.BoltEntity;
|
||||
import boni.tinkersweaponry.weapons.Crossbow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class CrossbowRenderer extends FlexibleToolRenderer {
|
||||
private static final BoltEntity dummy = new BoltEntity(null);
|
||||
|
||||
@Override
|
||||
protected void specialAnimation(ItemRenderType type, ItemStack item) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
Crossbow crossbow = (Crossbow)item.getItem();
|
||||
|
||||
GL11.glScalef(1.5f, 1.5f, 1.5f);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
// we're crazy, so.. render the arrow =D
|
||||
ItemStack ammo = crossbow.getLoadedAmmo(item);
|
||||
|
||||
if(crossbow.isLoaded(item))
|
||||
{
|
||||
GL11.glTranslatef(0.0f, 0.0f, -0.3f);
|
||||
GL11.glRotatef(80f, 1f, 0f, 0f);
|
||||
GL11.glRotatef(15f, 0f, 1f, 0f);
|
||||
GL11.glRotatef(-20, 0, 0, 1);
|
||||
}
|
||||
else {
|
||||
GL11.glScalef(1.1f, 1.1f, 1.1f);
|
||||
GL11.glTranslatef(0.1f, 0f, 0f);
|
||||
GL11.glRotatef(50f, 1f, 0f, 0f);
|
||||
}
|
||||
|
||||
if(ammo != null) {
|
||||
//float progress = crossbow.getWindupProgress(item, player);
|
||||
float progress = 1f;
|
||||
dummy.returnStack = ammo;
|
||||
Render renderer = RenderManager.instance.getEntityClassRenderObject(ArrowEntity.class);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
// adjust position
|
||||
//GL11.glScalef(2, 2, 2); // bigger
|
||||
GL11.glRotatef(95, 0, 1, 0); // rotate it into the same direction as the bow
|
||||
//GL11.glRotatef(15, 0, 1, 0); // rotate it a bit more so it's not directly inside the bow
|
||||
GL11.glRotatef(-45, 1, 0, 0); // sprite is rotated by 45° in the graphics, correct that
|
||||
GL11.glTranslatef(0.05f, 0, 0); // same as the not-inside-bow-rotation
|
||||
|
||||
// move the arrow with the charging process
|
||||
float offset = -0.15f;
|
||||
|
||||
GL11.glTranslatef(0, 0, offset);
|
||||
|
||||
// render iiit
|
||||
renderer.doRender(dummy, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glTranslatef(0.25f, 0, 0);
|
||||
GL11.glRotatef(45.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
package boni.tinkersweaponry.client.renderer;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class FlexibleToolRenderer implements IItemRenderer {
|
||||
public float depth = 1/32f;
|
||||
|
||||
public void setDepth(float d) { depth = d; }
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType (ItemStack item, ItemRenderType type)
|
||||
{
|
||||
if(!item.hasTagCompound())
|
||||
return false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ENTITY:
|
||||
//GL11.glTranslatef(-0.0625F, -0.0625F, 0F);
|
||||
return true;
|
||||
case EQUIPPED:
|
||||
//GL11.glTranslatef(0.03f, 0F, -0.09375F);
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
return true;
|
||||
case INVENTORY:
|
||||
return true;
|
||||
default:
|
||||
TConstruct.logger.warn("[TCon] Unhandled render case!");
|
||||
case FIRST_PERSON_MAP:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return handleRenderType(item, type) & helper.ordinal() < ItemRendererHelper.EQUIPPED_BLOCK.ordinal();
|
||||
}
|
||||
|
||||
private static final int toolIcons = 10;
|
||||
|
||||
protected void specialAnimation(ItemRenderType type, ItemStack item) {}
|
||||
|
||||
@Override
|
||||
public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
|
||||
Entity ent = null;
|
||||
if (data.length > 1)
|
||||
ent = (Entity) data[1];
|
||||
|
||||
IIcon[] parts = new IIcon[toolIcons];
|
||||
int iconParts = getIcons(item, type, ent, parts);
|
||||
|
||||
// drawing the inventory is a simple procedure
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
renderInventory(iconParts, parts, item);
|
||||
return;
|
||||
}
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
float[] xMax = new float[iconParts];
|
||||
float[] yMin = new float[iconParts];
|
||||
float[] xMin = new float[iconParts];
|
||||
float[] yMax = new float[iconParts];
|
||||
|
||||
float[] width = new float[iconParts];
|
||||
float[] height = new float[iconParts];
|
||||
float[] xDiff = new float[iconParts];
|
||||
float[] yDiff = new float[iconParts];
|
||||
float[] xSub = new float[iconParts];
|
||||
float[] ySub = new float[iconParts];
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
IIcon icon = parts[i];
|
||||
xMin[i] = icon.getMinU();
|
||||
xMax[i] = icon.getMaxU();
|
||||
yMin[i] = icon.getMinV();
|
||||
yMax[i] = icon.getMaxV();
|
||||
width[i] = icon.getIconWidth();
|
||||
height[i] = icon.getIconHeight();
|
||||
xDiff[i] = xMin[i] - xMax[i];
|
||||
yDiff[i] = yMin[i] - yMax[i];
|
||||
xSub[i] = 0.5f * (xMax[i] - xMin[i]) / width[i];
|
||||
ySub[i] = 0.5f * (yMax[i] - yMin[i]) / height[i];
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
if(type != ItemRenderType.ENTITY) {
|
||||
GL11.glTranslatef(0.5f, 0.5f, 0);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
specialAnimation(type, item);
|
||||
}
|
||||
|
||||
// prepare colors
|
||||
int[] color = new int[iconParts];
|
||||
for(int i = 0; i < iconParts; i++)
|
||||
color[i] = item.getItem().getColorFromItemStack(item, i);
|
||||
|
||||
// one side
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0, 0, 1);
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(color[i]);
|
||||
tess.addVertexWithUV(-0.5, -0.5, +depth, xMax[i], yMax[i]);
|
||||
tess.addVertexWithUV(+0.5, -0.5, +depth, xMin[i], yMax[i]);
|
||||
tess.addVertexWithUV(+0.5, +0.5, +depth, xMin[i], yMin[i]);
|
||||
tess.addVertexWithUV(-0.5, +0.5, +depth, xMax[i], yMin[i]);
|
||||
}
|
||||
tess.draw();
|
||||
|
||||
// other side
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0, 0, -1);
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(color[i]);
|
||||
tess.addVertexWithUV(-0.5, +0.5, -depth, xMax[i], yMin[i]);
|
||||
tess.addVertexWithUV(+0.5, +0.5, -depth, xMin[i], yMin[i]);
|
||||
tess.addVertexWithUV(+0.5, -0.5, -depth, xMin[i], yMax[i]);
|
||||
tess.addVertexWithUV(-0.5, -0.5, -depth, xMax[i], yMax[i]);
|
||||
}
|
||||
tess.draw();
|
||||
|
||||
// make it have "depth"
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(-1, 0, 0);
|
||||
float pos;
|
||||
float iconPos;
|
||||
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(color[i]);
|
||||
float w = width[i], m = xMax[i], d = xDiff[i], s = xSub[i];
|
||||
for (int k = 0, e = (int)w; k < e; ++k)
|
||||
{
|
||||
pos = k / w;
|
||||
iconPos = m + d * pos - s;
|
||||
pos -= 0.5f;
|
||||
tess.addVertexWithUV(pos, -0.5, -depth, iconPos, yMax[i]);
|
||||
tess.addVertexWithUV(pos, -0.5, +depth, iconPos, yMax[i]);
|
||||
tess.addVertexWithUV(pos, +0.5, +depth, iconPos, yMin[i]);
|
||||
tess.addVertexWithUV(pos, +0.5, -depth, iconPos, yMin[i]);
|
||||
}
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(1, 0, 0);
|
||||
float posEnd;
|
||||
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(color[i]);
|
||||
float w = width[i], m = xMax[i], d = xDiff[i], s = xSub[i];
|
||||
float d2 = 1f / w;
|
||||
for (int k = 0, e = (int)w; k < e; ++k)
|
||||
{
|
||||
pos = k / w;
|
||||
iconPos = m + d * pos - s;
|
||||
pos -= 0.5f;
|
||||
posEnd = pos + d2;
|
||||
tess.addVertexWithUV(posEnd, +0.5, -depth, iconPos, yMin[i]);
|
||||
tess.addVertexWithUV(posEnd, +0.5, +depth, iconPos, yMin[i]);
|
||||
tess.addVertexWithUV(posEnd, -0.5, +depth, iconPos, yMax[i]);
|
||||
tess.addVertexWithUV(posEnd, -0.5, -depth, iconPos, yMax[i]);
|
||||
}
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0, 1, 0);
|
||||
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(color[i]);
|
||||
float h = height[i], m = yMax[i], d = yDiff[i], s = ySub[i];
|
||||
float d2 = 1f / h;
|
||||
for (int k = 0, e = (int)h; k < e; ++k)
|
||||
{
|
||||
pos = k / h;
|
||||
iconPos = m + d * pos - s;
|
||||
pos -= 0.5f;
|
||||
posEnd = pos + d2;
|
||||
tess.addVertexWithUV(-0.5, posEnd, +depth, xMax[i], iconPos);
|
||||
tess.addVertexWithUV(+0.5, posEnd, +depth, xMin[i], iconPos);
|
||||
tess.addVertexWithUV(+0.5, posEnd, -depth, xMin[i], iconPos);
|
||||
tess.addVertexWithUV(-0.5, posEnd, -depth, xMax[i], iconPos);
|
||||
}
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal(0, -1, 0);
|
||||
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(color[i]);
|
||||
float h = height[i], m = yMax[i], d = yDiff[i], s = ySub[i];
|
||||
for (int k = 0, e = (int)h; k < e; ++k)
|
||||
{
|
||||
pos = k / h;
|
||||
iconPos = m + d * pos - s;
|
||||
pos -= 0.5f;
|
||||
tess.addVertexWithUV(+0.5, pos, +depth, xMin[i], iconPos);
|
||||
tess.addVertexWithUV(-0.5, pos, +depth, xMax[i], iconPos);
|
||||
tess.addVertexWithUV(-0.5, pos, -depth, xMax[i], iconPos);
|
||||
tess.addVertexWithUV(+0.5, pos, -depth, xMin[i], iconPos);
|
||||
}
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderInventory(int count, IIcon[] icons, ItemStack item)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
tess.startDrawingQuads();
|
||||
|
||||
// draw a simple rectangle for the inventory icon
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
tess.setColorOpaque_I(item.getItem().getColorFromItemStack(item, i));
|
||||
|
||||
final IIcon icon = icons[i];
|
||||
final float xmin = icon.getMinU();
|
||||
final float xmax = icon.getMaxU();
|
||||
final float ymin = icon.getMinV();
|
||||
final float ymax = icon.getMaxV();
|
||||
tess.addVertexWithUV( 0, 16, 0, xmin, ymax);
|
||||
tess.addVertexWithUV(16, 16, 0, xmax, ymax);
|
||||
tess.addVertexWithUV(16, 0, 0, xmax, ymin);
|
||||
tess.addVertexWithUV( 0, 0, 0, xmin, ymin);
|
||||
}
|
||||
tess.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public int getIcons(ItemStack item, ItemRenderType type, Entity ent, IIcon[] parts)
|
||||
{
|
||||
int iconParts = toolIcons;//tool.getRenderPasses(item.getItemDamage());
|
||||
// TODO: have the tools define how many render passes they have
|
||||
// (requires more logic rewrite than it sounds like)
|
||||
|
||||
boolean isInventory = type == ItemRenderType.INVENTORY;
|
||||
ToolCore tool = (ToolCore) item.getItem();
|
||||
|
||||
IIcon[] tempParts = new IIcon[iconParts];
|
||||
label:
|
||||
{
|
||||
if (!isInventory && ent instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) ent;
|
||||
ItemStack itemInUse = player.getItemInUse();
|
||||
if (itemInUse != null)
|
||||
{
|
||||
int useCount = player.getItemInUseCount();
|
||||
for (int i = iconParts; i-- > 0;)
|
||||
tempParts[i] = tool.getIcon(item, i, player, itemInUse, useCount);
|
||||
break label;
|
||||
}
|
||||
}
|
||||
for (int i = iconParts; i-- > 0;)
|
||||
tempParts[i] = tool.getIcon(item, i);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < iconParts; ++i)
|
||||
{
|
||||
IIcon part = tempParts[i];
|
||||
if (part == null || part == ToolCore.blankSprite || part == ToolCore.emptyIcon)
|
||||
++count;
|
||||
else
|
||||
parts[i - count] = part;
|
||||
}
|
||||
iconParts -= count;
|
||||
|
||||
if (iconParts <= 0)
|
||||
{
|
||||
iconParts = 1;
|
||||
parts[0] = ToolCore.blankSprite;
|
||||
}
|
||||
|
||||
return iconParts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package boni.tinkersweaponry.client.renderer;
|
||||
|
||||
import boni.tinkersweaponry.library.weaponry.IWindup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class JavelinRenderer extends AmmoItemRenderer {
|
||||
|
||||
@Override
|
||||
protected void specialAnimation(ItemRenderType type, ItemStack item) {
|
||||
float progress = ((IWindup)item.getItem()).getWindupProgress(item, Minecraft.getMinecraft().thePlayer); // 0.5 while not winding
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
GL11.glRotatef(90, 0, 0, 1);
|
||||
|
||||
GL11.glRotatef(-45, 0, 0, 1);
|
||||
GL11.glScalef(1.5F, 2F, 1.5F);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
GL11.glTranslatef(0, progress * 0.4f, 0);
|
||||
GL11.glRotatef(45, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package boni.tinkersweaponry.client.renderer;
|
||||
|
||||
import boni.tinkersweaponry.library.weaponry.IWindup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class ThrowingKnifeRenderer extends AmmoItemRenderer {
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Override
|
||||
protected void specialAnimation(ItemRenderType type, ItemStack item) {
|
||||
float progress = ((IWindup)item.getItem()).getWindupProgress(item, mc.thePlayer);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(2.5f, 2.5f, 2.5f);
|
||||
// rotate it, otherwise it's drawn over our item :(
|
||||
GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
//GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
//GL11.glRotatef(-85.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glRotatef(progress * 35.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
mc.getTextureManager().bindTexture(mc.thePlayer.getLocationSkin());
|
||||
RenderPlayer plrRender = (RenderPlayer) RenderManager.instance.getEntityRenderObject(mc.thePlayer);
|
||||
plrRender.renderFirstPersonArm(mc.thePlayer);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
|
||||
|
||||
// rotate it aroooound
|
||||
//GL11.glRotatef(-180, 0, 0, 1);
|
||||
//GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
//GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glTranslatef(1.3f, 0.4f, -0.2f);
|
||||
|
||||
//GL11.glTranslatef(-0.5f, 0.6f, 0f);
|
||||
//GL11.glTranslatef(0.f, 1f, 0f);
|
||||
//GL11.glTranslatef(progress * -1.5f, 0.0f, 0f);
|
||||
GL11.glTranslatef(0.0f, -1.85f, 0f);
|
||||
GL11.glRotatef(progress * 35.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0f, 1.85f, 0f);
|
||||
GL11.glRotatef(progress * -15.0F, 0.0F, 0.0F, 1.0F);
|
||||
//GL11.glTranslatef(-0.f, -1f, 0f);
|
||||
//GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
|
||||
|
||||
GL11.glScalef(1.5f, 1.5f, 1.5f);
|
||||
|
||||
GL11.glRotatef(-180, 0, 0, 1);
|
||||
GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
GL11.glRotatef(-180, 0, 0, 1);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user