mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 06:50:46 +00:00
improve IAnimatedItem and move existing item animations out of the ClientProxy monolith
This commit is contained in:
parent
539ecb8130
commit
8c752488ee
@ -1,14 +1,31 @@
|
|||||||
package com.hbm.items;
|
package com.hbm.items;
|
||||||
|
|
||||||
|
import com.hbm.packet.PacketDispatcher;
|
||||||
|
import com.hbm.packet.toclient.GunAnimationPacket;
|
||||||
import com.hbm.render.anim.BusAnimation;
|
import com.hbm.render.anim.BusAnimation;
|
||||||
|
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
public interface IAnimatedItem {
|
public interface IAnimatedItem {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
// Fetch the animation for a given type
|
||||||
public BusAnimation getAnimation(NBTTagCompound data, ItemStack stack);
|
public BusAnimation getAnimation(AnimType type, ItemStack stack);
|
||||||
|
|
||||||
|
// Run the swing animation
|
||||||
|
public default void playAnimation(EntityPlayer player) {
|
||||||
|
playAnimation(player, AnimType.CYCLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run a specified animation
|
||||||
|
public default void playAnimation(EntityPlayer player, AnimType type) {
|
||||||
|
if(player instanceof EntityPlayerMP) {
|
||||||
|
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(type.ordinal(), 0, 0), (EntityPlayerMP) player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import com.hbm.main.MainRegistry;
|
|||||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||||
import com.hbm.render.anim.BusAnimation;
|
import com.hbm.render.anim.BusAnimation;
|
||||||
import com.hbm.render.anim.BusAnimationSequence;
|
import com.hbm.render.anim.BusAnimationSequence;
|
||||||
|
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||||
import com.hbm.util.EntityDamageUtil;
|
import com.hbm.util.EntityDamageUtil;
|
||||||
|
|
||||||
import api.hbm.block.IToolable;
|
import api.hbm.block.IToolable;
|
||||||
@ -19,7 +20,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@ -73,13 +73,10 @@ public class ItemBoltgun extends Item implements IAnimatedItem {
|
|||||||
data.setFloat("size", 1F);
|
data.setFloat("size", 1F);
|
||||||
data.setByte("count", (byte)1);
|
data.setByte("count", (byte)1);
|
||||||
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, entity.posX, entity.posY + entity.height / 2 - entity.yOffset, entity.posZ), new TargetPoint(world.provider.dimensionId, entity.posX, entity.posY, entity.posZ, 50));
|
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, entity.posX, entity.posY + entity.height / 2 - entity.yOffset, entity.posZ), new TargetPoint(world.provider.dimensionId, entity.posX, entity.posY, entity.posZ, 50));
|
||||||
} else {
|
|
||||||
// doing this on the client outright removes the packet delay and makes the animation silky-smooth
|
playAnimation(player);
|
||||||
NBTTagCompound d0 = new NBTTagCompound();
|
|
||||||
d0.setString("type", "anim");
|
|
||||||
d0.setString("mode", "generic");
|
|
||||||
MainRegistry.proxy.effectNT(d0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,10 +107,7 @@ public class ItemBoltgun extends Item implements IAnimatedItem {
|
|||||||
data.setByte("count", (byte)1);
|
data.setByte("count", (byte)1);
|
||||||
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, x + fX + dir.offsetX * off, y + fY + dir.offsetY * off, z + fZ + dir.offsetZ * off), new TargetPoint(world.provider.dimensionId, x, y, z, 50));
|
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, x + fX + dir.offsetX * off, y + fY + dir.offsetY * off, z + fZ + dir.offsetZ * off), new TargetPoint(world.provider.dimensionId, x, y, z, 50));
|
||||||
|
|
||||||
NBTTagCompound d0 = new NBTTagCompound();
|
playAnimation(player);
|
||||||
d0.setString("type", "anim");
|
|
||||||
d0.setString("mode", "generic");
|
|
||||||
PacketThreading.createSendToThreadedPacket(new AuxParticlePacketNT(d0, 0, 0, 0), (EntityPlayerMP) player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -124,7 +118,7 @@ public class ItemBoltgun extends Item implements IAnimatedItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public BusAnimation getAnimation(NBTTagCompound data, ItemStack stack) {
|
public BusAnimation getAnimation(AnimType type, ItemStack stack) {
|
||||||
return new BusAnimation()
|
return new BusAnimation()
|
||||||
.addBus("RECOIL", new BusAnimationSequence()
|
.addBus("RECOIL", new BusAnimationSequence()
|
||||||
.addPos(1, 0, 1, 50)
|
.addPos(1, 0, 1, 50)
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
package com.hbm.items.tool;
|
package com.hbm.items.tool;
|
||||||
|
|
||||||
import com.hbm.handler.threading.PacketThreading;
|
|
||||||
import com.hbm.inventory.fluid.FluidType;
|
import com.hbm.inventory.fluid.FluidType;
|
||||||
|
import com.hbm.items.IAnimatedItem;
|
||||||
import com.hbm.items.IHeldSoundProvider;
|
import com.hbm.items.IHeldSoundProvider;
|
||||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
import com.hbm.render.anim.BusAnimation;
|
||||||
|
import com.hbm.render.anim.BusAnimationSequence;
|
||||||
|
import com.hbm.render.anim.HbmAnimations;
|
||||||
|
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
public class ItemChainsaw extends ItemToolAbilityFueled implements IHeldSoundProvider {
|
public class ItemChainsaw extends ItemToolAbilityFueled implements IHeldSoundProvider, IAnimatedItem {
|
||||||
|
|
||||||
public ItemChainsaw(float damage, double movement, ToolMaterial material, EnumToolType type, int maxFuel, int consumption, int fillRate, FluidType... acceptedFuels) {
|
public ItemChainsaw(float damage, double movement, ToolMaterial material, EnumToolType type, int maxFuel, int consumption, int fillRate, FluidType... acceptedFuels) {
|
||||||
super(damage, movement, material, type, maxFuel, consumption, fillRate, acceptedFuels);
|
super(damage, movement, material, type, maxFuel, consumption, fillRate, acceptedFuels);
|
||||||
@ -25,11 +28,46 @@ public class ItemChainsaw extends ItemToolAbilityFueled implements IHeldSoundPro
|
|||||||
if(stack.getItemDamage() >= stack.getMaxDamage())
|
if(stack.getItemDamage() >= stack.getMaxDamage())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
playAnimation((EntityPlayer) entityLiving);
|
||||||
nbt.setString("type", "anim");
|
|
||||||
nbt.setString("mode", "sSwing");
|
|
||||||
PacketThreading.createSendToThreadedPacket(new AuxParticlePacketNT(nbt, 0, 0, 0), (EntityPlayerMP)entityLiving);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BusAnimation getAnimation(AnimType type, ItemStack stack) {
|
||||||
|
int forward = 150;
|
||||||
|
int sideways = 100;
|
||||||
|
int retire = 200;
|
||||||
|
|
||||||
|
if(HbmAnimations.getRelevantAnim() == null) {
|
||||||
|
|
||||||
|
return new BusAnimation()
|
||||||
|
.addBus("SWING_ROT", new BusAnimationSequence()
|
||||||
|
.addPos(0, 0, 90, forward)
|
||||||
|
.addPos(45, 0, 90, sideways)
|
||||||
|
.addPos(0, 0, 0, retire))
|
||||||
|
.addBus("SWING_TRANS", new BusAnimationSequence()
|
||||||
|
.addPos(0, 0, 3, forward)
|
||||||
|
.addPos(2, 0, 2, sideways)
|
||||||
|
.addPos(0, 0, 0, retire));
|
||||||
|
} else {
|
||||||
|
|
||||||
|
double[] rot = HbmAnimations.getRelevantTransformation("SWING_ROT");
|
||||||
|
double[] trans = HbmAnimations.getRelevantTransformation("SWING_TRANS");
|
||||||
|
|
||||||
|
if(System.currentTimeMillis() - HbmAnimations.getRelevantAnim().startMillis < 50) return null;
|
||||||
|
|
||||||
|
return new BusAnimation()
|
||||||
|
.addBus("SWING_ROT", new BusAnimationSequence()
|
||||||
|
.addPos(rot[0], rot[1], rot[2], 0)
|
||||||
|
.addPos(0, 0, 90, forward)
|
||||||
|
.addPos(45, 0, 90, sideways)
|
||||||
|
.addPos(0, 0, 0, retire))
|
||||||
|
.addBus("SWING_TRANS", new BusAnimationSequence()
|
||||||
|
.addPos(trans[0], trans[1], trans[2], 0)
|
||||||
|
.addPos(0, 0, 3, forward)
|
||||||
|
.addPos(2, 0, 2, sideways)
|
||||||
|
.addPos(0, 0, 0, retire));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,29 @@
|
|||||||
package com.hbm.items.weapon;
|
package com.hbm.items.weapon;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.hbm.handler.threading.PacketThreading;
|
import com.hbm.handler.threading.PacketThreading;
|
||||||
|
import com.hbm.items.IAnimatedItem;
|
||||||
import com.hbm.items.IEquipReceiver;
|
import com.hbm.items.IEquipReceiver;
|
||||||
|
import com.hbm.items.ModItems;
|
||||||
import com.hbm.items.tool.ItemSwordAbility;
|
import com.hbm.items.tool.ItemSwordAbility;
|
||||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||||
|
import com.hbm.render.anim.BusAnimation;
|
||||||
|
import com.hbm.render.anim.BusAnimationSequence;
|
||||||
|
import com.hbm.render.anim.HbmAnimations;
|
||||||
|
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||||
|
import com.hbm.render.anim.HbmAnimations.Animation;
|
||||||
import com.hbm.util.ShadyUtil;
|
import com.hbm.util.ShadyUtil;
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
@ -25,9 +35,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.ChatStyle;
|
import net.minecraft.util.ChatStyle;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ItemCrucible extends ItemSwordAbility implements IEquipReceiver {
|
public class ItemCrucible extends ItemSwordAbility implements IEquipReceiver, IAnimatedItem {
|
||||||
|
|
||||||
public ItemCrucible(float damage, double movement, ToolMaterial material) {
|
public ItemCrucible(float damage, double movement, ToolMaterial material) {
|
||||||
super(damage, movement, material);
|
super(damage, movement, material);
|
||||||
@ -44,10 +55,7 @@ public class ItemCrucible extends ItemSwordAbility implements IEquipReceiver {
|
|||||||
World world = player.worldObj;
|
World world = player.worldObj;
|
||||||
world.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.cDeploy", 1.0F, 1.0F);
|
world.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.cDeploy", 1.0F, 1.0F);
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
playAnimation(player, AnimType.EQUIP);
|
||||||
nbt.setString("type", "anim");
|
|
||||||
nbt.setString("mode", "crucible");
|
|
||||||
PacketThreading.createSendToThreadedPacket(new AuxParticlePacketNT(nbt, 0, 0, 0), (EntityPlayerMP)player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,10 +72,7 @@ public class ItemCrucible extends ItemSwordAbility implements IEquipReceiver {
|
|||||||
if(stack.getItemDamage() >= stack.getMaxDamage())
|
if(stack.getItemDamage() >= stack.getMaxDamage())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
playAnimation((EntityPlayerMP)entityLiving, AnimType.CYCLE);
|
||||||
nbt.setString("type", "anim");
|
|
||||||
nbt.setString("mode", "cSwing");
|
|
||||||
PacketThreading.createSendToThreadedPacket(new AuxParticlePacketNT(nbt, 0, 0, 0), (EntityPlayerMP)entityLiving);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -132,4 +137,49 @@ public class ItemCrucible extends ItemSwordAbility implements IEquipReceiver {
|
|||||||
|
|
||||||
list.add(charge);
|
list.add(charge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BusAnimation getAnimation(AnimType type, ItemStack stack) {
|
||||||
|
/* crucible deploy */
|
||||||
|
if(type == AnimType.EQUIP) {
|
||||||
|
|
||||||
|
return new BusAnimation()
|
||||||
|
.addBus("GUARD_ROT", new BusAnimationSequence()
|
||||||
|
.addPos(90, 0, 1, 0)
|
||||||
|
.addPos(90, 0, 1, 800)
|
||||||
|
.addPos(0, 0, 1, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* crucible swing */
|
||||||
|
if(type == AnimType.CYCLE) {
|
||||||
|
|
||||||
|
if(HbmAnimations.getRelevantTransformation("SWING_ROT")[0] == 0) {
|
||||||
|
|
||||||
|
Random rand = Minecraft.getMinecraft().theWorld.rand;
|
||||||
|
|
||||||
|
int offset = rand.nextInt(80) - 20;
|
||||||
|
|
||||||
|
playSwing(0.8F + rand.nextFloat() * 0.2F);
|
||||||
|
|
||||||
|
return new BusAnimation()
|
||||||
|
.addBus("SWING_ROT", new BusAnimationSequence()
|
||||||
|
.addPos(90 - offset, 90 - offset, 35, 75)
|
||||||
|
.addPos(90 + offset, 90 - offset, -45, 150)
|
||||||
|
.addPos(0, 0, 0, 500))
|
||||||
|
.addBus("SWING_TRANS", new BusAnimationSequence()
|
||||||
|
.addPos(-3, 0, 0, 75)
|
||||||
|
.addPos(8, 0, 0, 150)
|
||||||
|
.addPos(0, 0, 0, 500));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// could do this better, but this preserves existing behaviour the closest with the least amount
|
||||||
|
// of effort, without crashing servers (I'm learning my lesson :o_ )
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private void playSwing(float pitchProbablyIDontFuckingCare) {
|
||||||
|
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("hbm:weapon.cSwing"), pitchProbablyIDontFuckingCare));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1787,105 +1787,6 @@ public class ClientProxy extends ServerProxy {
|
|||||||
Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleDeadLeaf(man, world, x, y, z));
|
Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleDeadLeaf(man, world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
if("anim".equals(type)) {
|
|
||||||
|
|
||||||
String mode = data.getString("mode");
|
|
||||||
|
|
||||||
/* crucible deploy */
|
|
||||||
if("crucible".equals(mode) && player.getHeldItem() != null) {
|
|
||||||
|
|
||||||
BusAnimation animation = new BusAnimation()
|
|
||||||
.addBus("GUARD_ROT", new BusAnimationSequence()
|
|
||||||
.addPos(90, 0, 1, 0)
|
|
||||||
.addPos(90, 0, 1, 800)
|
|
||||||
.addPos(0, 0, 1, 50));
|
|
||||||
|
|
||||||
String id = ModItems.crucible.getUnlocalizedName();
|
|
||||||
HbmAnimations.hotbar[player.inventory.currentItem][0] = new Animation(id, System.currentTimeMillis(), animation, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* crucible swing */
|
|
||||||
if("cSwing".equals(mode)) {
|
|
||||||
|
|
||||||
if(HbmAnimations.getRelevantTransformation("SWING_ROT")[0] == 0) {
|
|
||||||
|
|
||||||
int offset = rand.nextInt(80) - 20;
|
|
||||||
|
|
||||||
BusAnimation animation = new BusAnimation()
|
|
||||||
.addBus("SWING_ROT", new BusAnimationSequence()
|
|
||||||
.addPos(90 - offset, 90 - offset, 35, 75)
|
|
||||||
.addPos(90 + offset, 90 - offset, -45, 150)
|
|
||||||
.addPos(0, 0, 0, 500))
|
|
||||||
.addBus("SWING_TRANS", new BusAnimationSequence()
|
|
||||||
.addPos(-3, 0, 0, 75)
|
|
||||||
.addPos(8, 0, 0, 150)
|
|
||||||
.addPos(0, 0, 0, 500));
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("hbm:weapon.cSwing"), 0.8F + player.getRNG().nextFloat() * 0.2F));
|
|
||||||
String id = ModItems.crucible.getUnlocalizedName();
|
|
||||||
HbmAnimations.hotbar[player.inventory.currentItem][0] = new Animation(id, System.currentTimeMillis(), animation, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* chainsaw swing */
|
|
||||||
if("sSwing".equals(mode) || "lSwing".equals(mode)) { //temp for lance
|
|
||||||
|
|
||||||
int forward = 150;
|
|
||||||
int sideways = 100;
|
|
||||||
int retire = 200;
|
|
||||||
|
|
||||||
if(HbmAnimations.getRelevantAnim() == null) {
|
|
||||||
|
|
||||||
BusAnimation animation = new BusAnimation()
|
|
||||||
.addBus("SWING_ROT", new BusAnimationSequence()
|
|
||||||
.addPos(0, 0, 90, forward)
|
|
||||||
.addPos(45, 0, 90, sideways)
|
|
||||||
.addPos(0, 0, 0, retire))
|
|
||||||
.addBus("SWING_TRANS", new BusAnimationSequence()
|
|
||||||
.addPos(0, 0, 3, forward)
|
|
||||||
.addPos(2, 0, 2, sideways)
|
|
||||||
.addPos(0, 0, 0, retire));
|
|
||||||
|
|
||||||
|
|
||||||
HbmAnimations.hotbar[player.inventory.currentItem][0] = new Animation(player.getHeldItem().getItem().getUnlocalizedName(), System.currentTimeMillis(), animation, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
double[] rot = HbmAnimations.getRelevantTransformation("SWING_ROT");
|
|
||||||
double[] trans = HbmAnimations.getRelevantTransformation("SWING_TRANS");
|
|
||||||
|
|
||||||
if(System.currentTimeMillis() - HbmAnimations.getRelevantAnim().startMillis < 50) return;
|
|
||||||
|
|
||||||
BusAnimation animation = new BusAnimation()
|
|
||||||
.addBus("SWING_ROT", new BusAnimationSequence()
|
|
||||||
.addPos(rot[0], rot[1], rot[2], 0)
|
|
||||||
.addPos(0, 0, 90, forward)
|
|
||||||
.addPos(45, 0, 90, sideways)
|
|
||||||
.addPos(0, 0, 0, retire))
|
|
||||||
.addBus("SWING_TRANS", new BusAnimationSequence()
|
|
||||||
.addPos(trans[0], trans[1], trans[2], 0)
|
|
||||||
.addPos(0, 0, 3, forward)
|
|
||||||
.addPos(2, 0, 2, sideways)
|
|
||||||
.addPos(0, 0, 0, retire));
|
|
||||||
|
|
||||||
HbmAnimations.hotbar[player.inventory.currentItem][0] = new Animation(player.getHeldItem().getItem().getUnlocalizedName(), System.currentTimeMillis(), animation, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if("generic".equals(mode)) {
|
|
||||||
ItemStack stack = player.getHeldItem();
|
|
||||||
|
|
||||||
if(stack != null && stack.getItem() instanceof IAnimatedItem) {
|
|
||||||
IAnimatedItem item = (IAnimatedItem) stack.getItem();
|
|
||||||
BusAnimation anim = item.getAnimation(data, stack);
|
|
||||||
|
|
||||||
if(anim != null) {
|
|
||||||
HbmAnimations.hotbar[player.inventory.currentItem][0] = new Animation(player.getHeldItem().getItem().getUnlocalizedName(), System.currentTimeMillis(), anim, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if("tau".equals(type)) {
|
if("tau".equals(type)) {
|
||||||
|
|
||||||
for(int i = 0; i < data.getByte("count"); i++)
|
for(int i = 0; i < data.getByte("count"); i++)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.hbm.packet.toclient;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
import com.hbm.items.IAnimatedItem;
|
||||||
import com.hbm.items.armor.ArmorTrenchmaster;
|
import com.hbm.items.armor.ArmorTrenchmaster;
|
||||||
import com.hbm.items.weapon.sedna.GunConfig;
|
import com.hbm.items.weapon.sedna.GunConfig;
|
||||||
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
|
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
|
||||||
@ -79,6 +80,8 @@ public class GunAnimationPacket implements IMessage {
|
|||||||
|
|
||||||
if(stack.getItem() instanceof ItemGunBaseNT) {
|
if(stack.getItem() instanceof ItemGunBaseNT) {
|
||||||
handleSedna(player, stack, slot, AnimType.values()[m.type], m.receiverIndex, m.gunIndex);
|
handleSedna(player, stack, slot, AnimType.values()[m.type], m.receiverIndex, m.gunIndex);
|
||||||
|
} else if(stack.getItem() instanceof IAnimatedItem) {
|
||||||
|
handleItem(player, stack, slot, AnimType.values()[m.type], m.receiverIndex, m.gunIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception x) { }
|
} catch(Exception x) { }
|
||||||
@ -105,9 +108,6 @@ public class GunAnimationPacket implements IMessage {
|
|||||||
BiFunction<ItemStack, AnimType, BusAnimation> anims = config.getAnims(stack);
|
BiFunction<ItemStack, AnimType, BusAnimation> anims = config.getAnims(stack);
|
||||||
BusAnimation animation = anims.apply(stack, type);
|
BusAnimation animation = anims.apply(stack, type);
|
||||||
|
|
||||||
if(animation == null && type == AnimType.RELOAD_EMPTY) {
|
|
||||||
animation = anims.apply(stack, AnimType.RELOAD);
|
|
||||||
}
|
|
||||||
if(animation == null && (type == AnimType.ALT_CYCLE || type == AnimType.CYCLE_EMPTY)) {
|
if(animation == null && (type == AnimType.ALT_CYCLE || type == AnimType.CYCLE_EMPTY)) {
|
||||||
animation = anims.apply(stack, AnimType.CYCLE);
|
animation = anims.apply(stack, AnimType.CYCLE);
|
||||||
}
|
}
|
||||||
@ -115,10 +115,21 @@ public class GunAnimationPacket implements IMessage {
|
|||||||
if(animation != null) {
|
if(animation != null) {
|
||||||
Minecraft.getMinecraft().entityRenderer.itemRenderer.resetEquippedProgress();
|
Minecraft.getMinecraft().entityRenderer.itemRenderer.resetEquippedProgress();
|
||||||
Minecraft.getMinecraft().entityRenderer.itemRenderer.itemToRender = stack;
|
Minecraft.getMinecraft().entityRenderer.itemRenderer.itemToRender = stack;
|
||||||
boolean isReloadAnimation = type == AnimType.RELOAD || type == AnimType.RELOAD_CYCLE || type == AnimType.RELOAD_EMPTY;
|
boolean isReloadAnimation = type == AnimType.RELOAD || type == AnimType.RELOAD_CYCLE;
|
||||||
if(isReloadAnimation && ArmorTrenchmaster.isTrenchMaster(player)) animation.setTimeMult(0.5D);
|
if(isReloadAnimation && ArmorTrenchmaster.isTrenchMaster(player)) animation.setTimeMult(0.5D);
|
||||||
HbmAnimations.hotbar[slot][gunIndex] = new Animation(stack.getItem().getUnlocalizedName(), System.currentTimeMillis(), animation, type, isReloadAnimation && config.getReloadAnimSequential(stack));
|
HbmAnimations.hotbar[slot][gunIndex] = new Animation(stack.getItem().getUnlocalizedName(), System.currentTimeMillis(), animation, isReloadAnimation && config.getReloadAnimSequential(stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleItem(EntityPlayer player, ItemStack stack, int slot, AnimType type, int receiverIndex, int itemIndex) {
|
||||||
|
IAnimatedItem item = (IAnimatedItem) stack.getItem();
|
||||||
|
BusAnimation animation = item.getAnimation(type, stack);
|
||||||
|
|
||||||
|
if(animation != null) {
|
||||||
|
HbmAnimations.hotbar[slot][itemIndex] = new Animation(stack.getItem().getUnlocalizedName(), System.currentTimeMillis(), animation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,10 +20,9 @@ public class HbmAnimations {
|
|||||||
|
|
||||||
public static enum AnimType {
|
public static enum AnimType {
|
||||||
RELOAD, //either a full reload or start of a reload
|
RELOAD, //either a full reload or start of a reload
|
||||||
@Deprecated RELOAD_EMPTY, //same as reload, but the mag is completely empty
|
|
||||||
RELOAD_CYCLE, //animation that plays for every individual round (for shotguns and similar single round loading weapons)
|
RELOAD_CYCLE, //animation that plays for every individual round (for shotguns and similar single round loading weapons)
|
||||||
RELOAD_END, //animation for transitioning from our RELOAD_CYCLE to idle
|
RELOAD_END, //animation for transitioning from our RELOAD_CYCLE to idle
|
||||||
CYCLE, //animation for every firing cycle
|
CYCLE, //animation for every firing cycle / weapon swing
|
||||||
CYCLE_EMPTY, //animation for the final shot in the magazine
|
CYCLE_EMPTY, //animation for the final shot in the magazine
|
||||||
CYCLE_DRY, //animation for trying to fire, but no round is available
|
CYCLE_DRY, //animation for trying to fire, but no round is available
|
||||||
ALT_CYCLE, //animation for alt fire cycles
|
ALT_CYCLE, //animation for alt fire cycles
|
||||||
@ -31,11 +30,11 @@ public class HbmAnimations {
|
|||||||
SPINDOWN, //animation for actionend
|
SPINDOWN, //animation for actionend
|
||||||
EQUIP, //animation for drawing the weapon
|
EQUIP, //animation for drawing the weapon
|
||||||
INSPECT, //animation for inspecting the weapon
|
INSPECT, //animation for inspecting the weapon
|
||||||
JAMMED //animation for jammed weapons
|
JAMMED, //animation for jammed weapons
|
||||||
}
|
}
|
||||||
|
|
||||||
// A NOTE ON SHOTGUN STYLE RELOADS
|
// A NOTE ON SHOTGUN STYLE RELOADS
|
||||||
// Make sure the RELOAD and RELOAD_EMPTY adds shells, not just RELOAD_CYCLE, they all proc once for each loaded shell
|
// Make sure the RELOAD adds shells, not just RELOAD_CYCLE, they all proc once for each loaded shell
|
||||||
|
|
||||||
public static class Animation {
|
public static class Animation {
|
||||||
|
|
||||||
@ -48,22 +47,18 @@ public class HbmAnimations {
|
|||||||
public BusAnimation animation;
|
public BusAnimation animation;
|
||||||
// If set, don't cancel this animation when the timer ends, instead wait for the next to start
|
// If set, don't cancel this animation when the timer ends, instead wait for the next to start
|
||||||
public boolean holdLastFrame = false;
|
public boolean holdLastFrame = false;
|
||||||
// so we know what type of animation we're playing, only used rarely
|
|
||||||
public AnimType type;
|
|
||||||
|
|
||||||
public Animation(String key, long startMillis, BusAnimation animation, AnimType type) {
|
public Animation(String key, long startMillis, BusAnimation animation) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.startMillis = startMillis;
|
this.startMillis = startMillis;
|
||||||
this.animation = animation;
|
this.animation = animation;
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Animation(String key, long startMillis, BusAnimation animation, AnimType type, boolean holdLastFrame) {
|
public Animation(String key, long startMillis, BusAnimation animation, boolean holdLastFrame) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.startMillis = startMillis;
|
this.startMillis = startMillis;
|
||||||
this.animation = animation;
|
this.animation = animation;
|
||||||
this.holdLastFrame = holdLastFrame;
|
this.holdLastFrame = holdLastFrame;
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user