revolver animations

This commit is contained in:
Bob 2022-07-05 22:46:32 +02:00
parent f771345f88
commit 7777fdb32a
6 changed files with 130 additions and 13 deletions

View File

@ -49,7 +49,7 @@ public class ItemArmorMod extends Item {
if(chestplate)
list.add(" " + I18nUtil.resolveKey("armorMod.chestplates"));
if(leggings)
list.add(" " + I18nUtil.resolveKey("armorMod.leggins"));
list.add(" " + I18nUtil.resolveKey("armorMod.leggings"));
if(boots)
list.add(" " + I18nUtil.resolveKey("armorMod.boots"));
}

View File

@ -27,7 +27,7 @@ public class ItemTemplateFolder extends Item {
String[] lang = I18nUtil.resolveKeyArray(this.getUnlocalizedName() + ".desc");
for(String line : lang) {
list.add(lang);
list.add(line);
}
}
}

View File

@ -16,6 +16,7 @@ import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.GunAnimationPacket;
import com.hbm.packet.GunButtonPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.anim.BusAnimation;
import com.hbm.render.anim.HbmAnimations.AnimType;
import com.hbm.render.util.RenderScreenOverlay;
import com.hbm.render.util.RenderScreenOverlay.Crosshair;
@ -248,7 +249,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD {
EntityBulletBase bullet = new EntityBulletBase(world, config, player);
world.spawnEntityInWorld(bullet);
if(this.mainConfig.animations.containsKey(AnimType.CYCLE) && player instanceof EntityPlayerMP)
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
}
@ -804,4 +805,10 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD {
RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, Crosshair.NONE);
}
}
@SideOnly(Side.CLIENT)
public BusAnimation getAnimation(ItemStack stack, AnimType type) {
GunConfiguration config = ((ItemGunBase) stack.getItem()).mainConfig;
return config.animations.get(type);
}
}

View File

@ -4,6 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import com.hbm.handler.GunConfiguration;
import com.hbm.render.anim.BusAnimation;
import com.hbm.render.anim.BusAnimationKeyframe;
import com.hbm.render.anim.BusAnimationSequence;
import com.hbm.render.anim.HbmAnimations.AnimType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -32,7 +36,7 @@ public class ItemGunBio extends ItemGunBase {
protected void updateClient(ItemStack stack, World world, EntityPlayer entity, int slot, boolean isCurrentItem) {
super.updateClient(stack, world, entity, slot, isCurrentItem);
boolean smoking = lastShot + 3000 > System.currentTimeMillis();
boolean smoking = lastShot + 2000 > System.currentTimeMillis();
if(!smoking && !smokeNodes.isEmpty()) {
smokeNodes.clear();
@ -52,10 +56,71 @@ public class ItemGunBio extends ItemGunBase {
node[2] += prev.zCoord * accel + world.rand.nextGaussian() * waggle;
}
double alpha = (System.currentTimeMillis() - ItemGunBio.lastShot) / 3000D;
alpha = (1 - alpha) * 0.25D;
double alpha = (System.currentTimeMillis() - ItemGunBio.lastShot) / 2000D;
alpha = (1 - alpha) * 0.35D;
if(this.getReloadCycle(stack) > 0) alpha = 0;
smokeNodes.add(new double[] {0, 0, 0, alpha});
}
}
@Override
@SideOnly(Side.CLIENT)
public BusAnimation getAnimation(ItemStack stack, AnimType type) {
//GunConfiguration config = ((ItemGunBase) stack.getItem()).mainConfig;
//return config.animations.get(type);
if(type == AnimType.CYCLE) return new BusAnimation()
.addBus("RECOIL", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 50))
.addKeyframe(new BusAnimationKeyframe(0, 0, -3, 50))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 250))
)
.addBus("HAMMER", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 1, 50))
.addKeyframe(new BusAnimationKeyframe(0, 0, 1, 300))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 200))
)
.addBus("DRUM", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 1, 50))
);
if(type == AnimType.RELOAD) return new BusAnimation()
.addBus("LATCH", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 90, 300))
.addKeyframe(new BusAnimationKeyframe(0, 0, 90, 2000))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 150))
)
.addBus("FRONT", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 200))
.addKeyframe(new BusAnimationKeyframe(0, 0, 45, 150))
.addKeyframe(new BusAnimationKeyframe(0, 0, 45, 2000))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 75))
)
.addBus("RELOAD_ROT", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 300))
.addKeyframe(new BusAnimationKeyframe(60, 0, 0, 500))
.addKeyframe(new BusAnimationKeyframe(60, 0, 0, 500))
.addKeyframe(new BusAnimationKeyframe(0, -90, -90, 0))
.addKeyframe(new BusAnimationKeyframe(0, -90, -90, 600))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 300))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 100))
.addKeyframe(new BusAnimationKeyframe(-45, 0, 0, 50))
.addKeyframe(new BusAnimationKeyframe(-45, 0, 0, 100))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 300))
)
.addBus("RELOAD_MOVE", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 300))
.addKeyframe(new BusAnimationKeyframe(0, -15, 0, 1000))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 450))
)
.addBus("DRUM_PUSH", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 1600))
.addKeyframe(new BusAnimationKeyframe(0, 0, -5, 0))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 300))
);
return null;
}
}

View File

@ -1,6 +1,5 @@
package com.hbm.packet;
import com.hbm.handler.GunConfiguration;
import com.hbm.items.weapon.ItemGunBase;
import com.hbm.render.anim.BusAnimation;
import com.hbm.render.anim.HbmAnimations;
@ -58,10 +57,8 @@ public class GunAnimationPacket implements IMessage {
if(m.type < 0 || m.type >= AnimType.values().length)
return null;
GunConfiguration config = ((ItemGunBase) stack.getItem()).mainConfig;
AnimType type = AnimType.values()[m.type];
BusAnimation animation = config.animations.get(type);
BusAnimation animation = ((ItemGunBase) stack.getItem()).getAnimation(stack, type);
if(animation != null) {
HbmAnimations.hotbar[slot] = new Animation(stack.getItem().getUnlocalizedName(), System.currentTimeMillis(), animation);

View File

@ -4,6 +4,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.items.weapon.ItemGunBio;
import com.hbm.main.ResourceManager;
import com.hbm.render.anim.HbmAnimations;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
@ -52,6 +53,9 @@ public class ItemRenderBioRevolver implements IItemRenderer {
GL11.glPushMatrix();
GL11.glTranslated(0.0, 2.0, 10.0);
double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL");
GL11.glTranslated(0, -recoil[2] * 1.5, recoil[2]);
if(ItemGunBio.smokeNodes.size() > 1) {
Tessellator tess = Tessellator.instance;
@ -79,6 +83,48 @@ public class ItemRenderBioRevolver implements IItemRenderer {
}
GL11.glPopMatrix();
GL11.glTranslated(recoil[0], recoil[1], recoil[2]);
GL11.glRotated(recoil[2] * 10, 1, 0, 0);
double[] reloadMove = HbmAnimations.getRelevantTransformation("RELOAD_MOVE");
GL11.glTranslated(reloadMove[0], reloadMove[1], reloadMove[2]);
double[] reloadRot = HbmAnimations.getRelevantTransformation("RELOAD_ROT");
GL11.glRotated(reloadRot[0], 1, 0, 0);
GL11.glRotated(reloadRot[2], 0, 0, 1);
GL11.glRotated(reloadRot[1], 0, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
ResourceManager.bio_revolver.renderPart("Grip");
GL11.glPushMatrix(); /// FRONT PUSH ///
GL11.glRotated(HbmAnimations.getRelevantTransformation("FRONT")[2], 1, 0, 0);
ResourceManager.bio_revolver.renderPart("Barrel");
GL11.glPushMatrix(); /// LATCH PUSH ///
GL11.glTranslated(0, 2.3125, -0.875);
GL11.glRotated(HbmAnimations.getRelevantTransformation("LATCH")[2], 1, 0, 0);
GL11.glTranslated(0, -2.3125, 0.875);
ResourceManager.bio_revolver.renderPart("Latch");
GL11.glPopMatrix(); /// LATCH POP ///
GL11.glPushMatrix(); /// DRUM PUSH ///
GL11.glTranslated(0, 1, 0);
GL11.glRotated(HbmAnimations.getRelevantTransformation("DRUM")[2] * 60, 0, 0, 1);
GL11.glTranslated(0, -1, 0);
GL11.glTranslated(0, 0, HbmAnimations.getRelevantTransformation("DRUM_PUSH")[2]);
ResourceManager.bio_revolver.renderPart("Drum");
GL11.glPopMatrix(); /// DRUM POP ///
GL11.glPopMatrix(); /// FRONT POP ///
GL11.glPushMatrix(); /// HAMMER ///
GL11.glTranslated(0, 0, -4.5);
GL11.glRotated(-45 + 45 * HbmAnimations.getRelevantTransformation("HAMMER")[2], 1, 0, 0);
GL11.glTranslated(0, 0, 4.5);
ResourceManager.bio_revolver.renderPart("Hammer");
GL11.glPopMatrix();
GL11.glShadeModel(GL11.GL_FLAT);
break;
@ -115,9 +161,11 @@ public class ItemRenderBioRevolver implements IItemRenderer {
default: break;
}
GL11.glShadeModel(GL11.GL_SMOOTH);
ResourceManager.bio_revolver.renderAll();
GL11.glShadeModel(GL11.GL_FLAT);
if(type != ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glShadeModel(GL11.GL_SMOOTH);
ResourceManager.bio_revolver.renderAll();
GL11.glShadeModel(GL11.GL_FLAT);
}
GL11.glPopMatrix();
}