mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fixed tick issues in eventHandler, added packets to orchestra + third person rendering for every gun with built-in muzzle/laser flashes, and softened playAnimation so skeleguns use orchestra/muzzle flashes. akimbos show both firing, probably won't be changed
63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
package com.hbm.packet.toclient;
|
|
|
|
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
|
|
import com.hbm.render.item.weapon.sedna.ItemRenderWeaponBase;
|
|
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import io.netty.buffer.ByteBuf;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
public class MuzzleFlashPacket implements IMessage {
|
|
|
|
private int entityID;
|
|
//private int gunIndex; //e.g. akimbo
|
|
|
|
public MuzzleFlashPacket() { }
|
|
|
|
//public MuzzleFlashPacket(EntityLivingBase entity) { this(entity, 0); }
|
|
|
|
public MuzzleFlashPacket(EntityLivingBase entity) {
|
|
this.entityID = entity.getEntityId();
|
|
//this.gunIndex = index;
|
|
}
|
|
|
|
@Override
|
|
public void toBytes(ByteBuf buf) {
|
|
buf.writeInt(entityID);
|
|
//buf.writeInt(gunIndex);
|
|
}
|
|
|
|
@Override
|
|
public void fromBytes(ByteBuf buf) {
|
|
this.entityID = buf.readInt();
|
|
//this.gunIndex = buf.readInt();
|
|
}
|
|
|
|
public static class Handler implements IMessageHandler<MuzzleFlashPacket, IMessage> {
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public IMessage onMessage(MuzzleFlashPacket m, MessageContext ctx) {
|
|
EntityLivingBase entity = (EntityLivingBase) Minecraft.getMinecraft().theWorld.getEntityByID(m.entityID);
|
|
if(entity == null || entity == Minecraft.getMinecraft().thePlayer) return null; //packets are sent to the player who fired
|
|
ItemStack stack = entity.getHeldItem();
|
|
if(stack == null) return null;
|
|
|
|
if(stack.getItem() instanceof ItemGunBaseNT) {
|
|
ItemGunBaseNT gun = (ItemGunBaseNT) stack.getItem();
|
|
|
|
ItemRenderWeaponBase.flashMap.put(entity, System.currentTimeMillis());
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|