Merge pull request #1324 from MellowArpeggiation/master

SPAS-12 animations (and a few bugfixes)
This commit is contained in:
HbmMods 2024-02-03 12:01:01 +01:00 committed by GitHub
commit 217ce07e6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 2220 additions and 2206 deletions

View File

@ -9,7 +9,7 @@ import com.hbm.items.ModItems;
public class BulletConfigSyncingUtil {
private static HashMap<Integer, BulletConfiguration> configSet = new HashMap();
private static HashMap<Integer, BulletConfiguration> configSet = new HashMap<Integer, BulletConfiguration>();
static int i = 0;

View File

@ -23,7 +23,7 @@ import net.minecraft.world.World;
*/
public class CasingEjector implements Cloneable {
public static HashMap<Integer, CasingEjector> mappings = new HashMap();
public static HashMap<Integer, CasingEjector> mappings = new HashMap<Integer, CasingEjector>();
public static final Random rand = new Random();
private int id;

View File

@ -10,15 +10,14 @@ import com.hbm.items.ItemAmmoEnums.Ammo12Gauge;
import com.hbm.items.ModItems;
import com.hbm.lib.HbmCollection;
import com.hbm.lib.HbmCollection.EnumGunManufacturer;
import com.hbm.main.ResourceManager;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.particle.SpentCasing;
import com.hbm.particle.SpentCasing.CasingType;
import com.hbm.potion.HbmPotion;
import com.hbm.render.anim.BusAnimation;
import com.hbm.render.anim.BusAnimationKeyframe;
import com.hbm.render.anim.BusAnimationSequence;
import com.hbm.render.anim.BusAnimationSequence.Dimension;
import com.hbm.render.anim.HbmAnimations.AnimType;
import com.hbm.render.util.RenderScreenOverlay.Crosshair;
@ -89,11 +88,12 @@ public class Gun12GaugeFactory {
GunConfiguration config = new GunConfiguration();
config.rateOfFire = 25;
config.rateOfFire = 20;
config.roundsPerCycle = 1;
config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_MANUAL;
config.reloadDuration = 10;
config.emptyReloadAdditionalDuration = 5;
config.firingDuration = 5;
config.ammoCap = 8;
config.durability = 2500;
@ -101,6 +101,7 @@ public class Gun12GaugeFactory {
config.allowsInfinity = true;
config.crosshair = Crosshair.CIRCLE;
config.reloadSound = GunConfiguration.RSOUND_SHOTGUN;
config.reloadSoundEnd = false;
config.firingSound = "hbm:weapon.shotgunPump";
config.name = "spas12";
@ -109,20 +110,17 @@ public class Gun12GaugeFactory {
config.comment.add("Alt-fire with Mouse 2 (Right-click) to fire 2 shells at once");
config.config = HbmCollection.g12hs;
config.animations.put(AnimType.CYCLE, new BusAnimation()
.addBus("SPAS_RECOIL", new BusAnimationSequence()
.addKeyframePosition(0, 0, -2, 100)
.addKeyframePosition(0, 0, 0, 200)
.addKeyframeRotation(-10, 0, 5, 100)
.addKeyframeRotation(0, 0, 0, 200)
)
.addBus("SPAS_PUMP", new BusAnimationSequence()
.addKeyframe(Dimension.TZ, 0, 450)
.addKeyframe(Dimension.TZ, -1.8, 200)
.addKeyframe(Dimension.TZ, 0, 200)
)
);
config.reloadAnimationsSequential = true;
config.loadAnimations = i -> {
config.animations.put(AnimType.CYCLE, ResourceManager.spas_12_anim.get("Fire"));
config.animations.put(AnimType.ALT_CYCLE, ResourceManager.spas_12_anim.get("FireAlt"));
config.animations.put(AnimType.RELOAD, ResourceManager.spas_12_anim.get("ReloadStart"));
config.animations.put(AnimType.RELOAD_EMPTY, ResourceManager.spas_12_anim.get("ReloadEmptyStart"));
config.animations.put(AnimType.RELOAD_CYCLE, ResourceManager.spas_12_anim.get("Reload"));
config.animations.put(AnimType.RELOAD_END, ResourceManager.spas_12_anim.get("ReloadEnd"));
};
config.ejector = EJECTOR_SPAS;
@ -140,7 +138,7 @@ public class Gun12GaugeFactory {
config.firingDuration = 10;
config.ammoCap = 8;
config.reloadSound = GunConfiguration.RSOUND_SHOTGUN;
config.firingSound = "hbm:weapon.shotgunPump";
config.firingSound = "hbm:weapon.shotgunPumpAlt";
config.reloadType = GunConfiguration.RELOAD_SINGLE;
config.config = HbmCollection.g12hs;
@ -291,7 +289,7 @@ public class Gun12GaugeFactory {
config.reloadType = 1;
config.ammoCap = 24;
config.reloadDuration = 20;
config.reloadSound = config.RSOUND_MAG;
config.reloadSound = GunConfiguration.RSOUND_MAG;
config.reloadSoundEnd = true;
config.name += "Drum";
return config;

View File

@ -78,9 +78,12 @@ public class Gun4GaugeFactory {
config.durability = 3000;
config.reloadSound = GunConfiguration.RSOUND_SHOTGUN;
config.reloadSoundEnd = false;
config.firingSound = "hbm:weapon.revolverShootAlt";
config.firingPitch = 0.65F;
config.ejector = EJECTOR_SHOTGUN.clone().setDelay(10);
config.name = "ks23";
config.manufacturer = EnumGunManufacturer.TULSKY;

View File

@ -4257,7 +4257,7 @@ public class ModItems {
gun_twigun = new GunEuthanasia().setUnlocalizedName("gun_twigun").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_twigun");
gun_defabricator_ammo = new Item().setUnlocalizedName("gun_defabricator_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_defabricator_ammo");
gun_defabricator = new GunDefabricator().setUnlocalizedName("gun_defabricator").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_defabricator");
gun_vortex = new ItemGunVortex(Gun556mmFactory.getEuphieConfig()).setUnlocalizedName("gun_vortex").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_vortex");
gun_vortex = new ItemGunBase(Gun556mmFactory.getEuphieConfig()).setUnlocalizedName("gun_vortex").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_vortex");
gun_super_shotgun = new ItemCustomLore().setUnlocalizedName("gun_super_shotgun").setMaxStackSize(1).setFull3D().setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_super_shotgun");
gun_moist_nugget = new ItemNugget(3, false).setUnlocalizedName("gun_moist_nugget").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_moist_nugget");
gun_dampfmaschine = new GunDampfmaschine().setUnlocalizedName("gun_dampfmaschine").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_dampfmaschine");

View File

@ -26,12 +26,12 @@ public class ItemCryoCannon extends ItemGunBase {
@Override
protected void fire(ItemStack stack, World world, EntityPlayer player) {
if(this.getPressure(stack) >= 1000) return;
if(this.getTurbine(stack) < 100) return;
if(getPressure(stack) >= 1000) return;
if(getTurbine(stack) < 100) return;
BulletConfiguration config = null;
if(mainConfig.reloadType == mainConfig.RELOAD_NONE) {
if(mainConfig.reloadType == GunConfiguration.RELOAD_NONE) {
config = getBeltCfg(player, stack, true);
} else {
config = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack)));
@ -50,6 +50,9 @@ public class ItemCryoCannon extends ItemGunBase {
for(int i = 0; i < bullets; i++) {
spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config));
}
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
useUpAmmo(player, stack, true);
player.inventoryContainer.detectAndSendChanges();
@ -66,26 +69,23 @@ public class ItemCryoCannon extends ItemGunBase {
@Override
protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) {
EntityChemical chem = new EntityChemical(world, player);
chem.setFluid(Fluids.OXYGEN);
world.spawnEntityInWorld(chem);
int pressure = this.getPressure(stack);
int pressure = getPressure(stack);
pressure += 5;
pressure = MathHelper.clamp_int(pressure, 0, 1000);
this.setPressure(stack, pressure);
if(player instanceof EntityPlayerMP) PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
setPressure(stack, pressure);
}
@Override
protected void updateServer(ItemStack stack, World world, EntityPlayer player, int slot, boolean isCurrentItem) {
int turbine = this.getTurbine(stack);
int pressure = this.getPressure(stack);
int turbine = getTurbine(stack);
int pressure = getPressure(stack);
if(this.getIsMouseDown(stack)) {
if(getIsMouseDown(stack)) {
turbine += 10;
} else {
turbine -= 5;
@ -94,8 +94,8 @@ public class ItemCryoCannon extends ItemGunBase {
turbine = MathHelper.clamp_int(turbine, 0, 100);
pressure = MathHelper.clamp_int(pressure, 0, 1000);
this.setTurbine(stack, turbine);
this.setPressure(stack, pressure);
setTurbine(stack, turbine);
setPressure(stack, pressure);
super.updateServer(stack, world, player, slot, isCurrentItem);
}

View File

@ -115,7 +115,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
endActionClient(stack, world, entity, false);
}
if(mainConfig.reloadType != mainConfig.RELOAD_NONE || (altConfig != null && altConfig.reloadType != 0)) {
if(mainConfig.reloadType != GunConfiguration.RELOAD_NONE || (altConfig != null && altConfig.reloadType != 0)) {
if(GameSettings.isKeyDown(HbmKeybinds.reloadKey) && Minecraft.getMinecraft().currentScreen == null && (getMag(stack) < mainConfig.ammoCap || hasInfinity(stack, mainConfig))) {
PacketDispatcher.wrapper.sendToServer(new GunButtonPacket(true, (byte) 2));
@ -184,7 +184,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
protected boolean tryShoot(ItemStack stack, World world, EntityPlayer player, boolean main) {
//cancel reload when trying to shoot if it's a single reload weapon and at least one round is loaded
if(getIsReloading(stack) && mainConfig.reloadType == mainConfig.RELOAD_SINGLE && this.getMag(stack) > 0) {
if(getIsReloading(stack) && mainConfig.reloadType == GunConfiguration.RELOAD_SINGLE && getMag(stack) > 0) {
setReloadCycle(stack, 0);
setIsReloading(stack, false);
}
@ -208,7 +208,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
if(!main)
config = altConfig;
if(config.reloadType == mainConfig.RELOAD_NONE) {
if(config.reloadType == GunConfiguration.RELOAD_NONE) {
return getBeltSize(player, getBeltType(player, stack, main)) > 0;
} else {
@ -222,7 +222,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
BulletConfiguration config = null;
if(mainConfig.reloadType == mainConfig.RELOAD_NONE) {
if(mainConfig.reloadType == GunConfiguration.RELOAD_NONE) {
config = getBeltCfg(player, stack, true);
} else {
config = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack)));
@ -241,6 +241,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
for(int i = 0; i < bullets; i++) {
spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config));
}
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
useUpAmmo(player, stack, true);
player.inventoryContainer.detectAndSendChanges();
@ -261,13 +264,13 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
if(altConfig == null)
return;
BulletConfiguration config = altConfig.reloadType == altConfig.RELOAD_NONE ? getBeltCfg(player, stack, false) : BulletConfigSyncingUtil.pullConfig(altConfig.config.get(getMagType(stack)));
BulletConfiguration config = altConfig.reloadType == GunConfiguration.RELOAD_NONE ? getBeltCfg(player, stack, false) : BulletConfigSyncingUtil.pullConfig(altConfig.config.get(getMagType(stack)));
int bullets = config.bulletsMin;
for(int k = 0; k < altConfig.roundsPerCycle; k++) {
if(altConfig.reloadType != altConfig.RELOAD_NONE && !hasAmmo(stack, player, true))
if(altConfig.reloadType != GunConfiguration.RELOAD_NONE && !hasAmmo(stack, player, true))
break;
if(config.bulletsMax > config.bulletsMin)
@ -276,6 +279,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
for(int i = 0; i < bullets; i++) {
spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config));
}
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.ALT_CYCLE.ordinal()), (EntityPlayerMP) player);
useUpAmmo(player, stack, false);
player.inventoryContainer.detectAndSendChanges();
@ -291,13 +297,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
//spawns the actual projectile, can be overridden to change projectile entity
protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) {
EntityBulletBaseNT bullet = new EntityBulletBaseNT(world, config, player);
world.spawnEntityInWorld(bullet);
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
}
//called on click (server side, called by mouse packet) for semi-automatics and specific events
@ -314,10 +315,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
fire(stack, world, player);
setDelay(stack, mainConfig.rateOfFire);
}
//setMag(stack, getMag(stack) - 1);
//useUpAmmo(player, stack, main);
//player.inventoryContainer.detectAndSendChanges();
}
if(!main && altConfig != null && tryShoot(stack, world, player, main)) {
@ -328,9 +325,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
altFire(stack, world, player);
setDelay(stack, altConfig.rateOfFire);
}
//useUpAmmo(player, stack, main);
//player.inventoryContainer.detectAndSendChanges();
}
}
@ -355,9 +349,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
BulletConfiguration prevCfg = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack)));
if(getMag(stack) == 0)
resetAmmoType(stack, world, player);
BulletConfiguration cfg = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack)));
ComparableStack ammo = (ComparableStack) cfg.ammo.copy();
@ -381,7 +372,10 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.RELOAD_END.ordinal()), (EntityPlayerMP) player);
} else {
resetReloadCycle(player, stack);
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.RELOAD_CYCLE.ordinal()), (EntityPlayerMP) player);
AnimType animType = availableFills <= 1 ? AnimType.RELOAD_END : AnimType.RELOAD_CYCLE;
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(animType.ordinal()), (EntityPlayerMP) player);
if (availableFills > 1 && !mainConfig.reloadSoundEnd)
world.playSoundAtEntity(player, mainConfig.reloadSound, 1.0F, 1.0F);
}
if(hasLoaded && mainConfig.reloadSoundEnd)
@ -403,6 +397,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
//initiates a reload
public void startReloadAction(ItemStack stack, World world, EntityPlayer player) {
if(getMag(stack) == 0)
resetAmmoType(stack, world, player);
if(player.isSneaking() && hasInfinity(stack, mainConfig)) {
@ -494,8 +491,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
addAdditionalInformation(stack, list);
}
protected void addAdditionalInformation(ItemStack stack, List<String> list)
{
protected void addAdditionalInformation(ItemStack stack, List<String> list) {
final BulletConfiguration bulletConfig = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack)));
list.add(I18nUtil.resolveKey(HbmCollection.gunDamage, bulletConfig.dmgMin, bulletConfig.dmgMax));
if(bulletConfig.bulletsMax != 1)

View File

@ -48,13 +48,14 @@ public class ItemGunChemthrower extends ItemGunBase implements IFillableItem {
spawnProjectile(world, player, stack, 0);
}
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
useUpAmmo(player, stack, true);
player.inventoryContainer.detectAndSendChanges();
int wear = (int) Math.ceil(10 / (1F + EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack)));
setItemWear(stack, getItemWear(stack) + wear);
//world.playSoundAtEntity(player, mainConfig.firingSound, 1.0F, mainConfig.firingPitch);
}
@Override
@ -86,15 +87,10 @@ public class ItemGunChemthrower extends ItemGunBase implements IFillableItem {
@Override
protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) {
//spawn fluid projectile
EntityChemical chem = new EntityChemical(world, player);
chem.setFluid(this.getFluidType(stack));
world.spawnEntityInWorld(chem);
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
}
@Override

View File

@ -1,215 +0,0 @@
package com.hbm.items.weapon;
import com.hbm.handler.GunConfiguration;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemGunVortex extends ItemGunBase {
@SideOnly(Side.CLIENT)
private long lastFireTime;
public ItemGunVortex(GunConfiguration config) {
super(config);
}
/*@Override
protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) {
//EntityBeamVortex beam = new EntityBeamVortex(world, player);
//world.spawnEntity(beam);
//100 blocks is its current max range, but I'm sure that could be increased if necessary.
List<Entity> entsOnBeam = Library.rayTraceEntitiesOnLine(player, 100, 1).getRight();
for(Entity e : entsOnBeam){
if(!(e instanceof EntityLivingBase))
continue;
float dmg = 30;
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, ModDamageSource.radiation, dmg);
}
if(this.mainConfig.animations.containsKey(AnimType.CYCLE) && player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
PacketDispatcher.wrapper.sendToAllAround(new GunFXPacket(player, FXType.FIRE), new TargetPoint(world.provider.dimensionId, player.posX, player.posY, player.posZ, 1));
}
//This method should also solve the supershotgun issue where it doesn't fire some of the time (maybe?)
@Override
@SideOnly(Side.CLIENT)
public void onFireClient(ItemStack stack, EntityPlayer player, boolean shouldDoThirdPerson) {
//If I'm going to do more particle systems like this maybe I should write some kind of abstraction around it to make it less messy.
NBTTagCompound tag = new NBTTagCompound();
Vec3d pos = null;
if(stack == player.getHeldItemMainhand()){
pos = new Vec3d(-0.16, -0.20, 1).rotatePitch(-(float) Math.toRadians(player.rotationPitch)).rotateYaw(-(float) Math.toRadians(player.rotationYawHead));
} else {
pos = new Vec3d(0.16, -0.20, 1).rotatePitch(-(float) Math.toRadians(player.rotationPitch)).rotateYaw(-(float) Math.toRadians(player.rotationYawHead));
}
pos = pos.add(player.getPositionEyes(1F));
Vec3d view = BobMathUtil.getVectorFromAngle(BobMathUtil.getEulerAngles(player.getLookVec()).addVector(0, 3, 0));
Vec3d hitPos = null;
Vec3d hitNormal = null;
RayTraceResult r = Library.rayTraceIncludeEntities(player, 100, MainRegistry.proxy.partialTicks());
if(r == null || r.typeOfHit == Type.MISS){
hitPos = player.getLook(MainRegistry.proxy.partialTicks()).scale(100).add(pos);
} else {
hitPos = r.hitVec;
hitNormal = new Vec3d(r.sideHit.getFrontOffsetX(), r.sideHit.getFrontOffsetY(), r.sideHit.getFrontOffsetZ());
}
tag.setString("type", "spark");
tag.setString("mode", "coneBurst");
tag.setDouble("posX", pos.x-player.motionX);
tag.setDouble("posY", pos.y-player.motionY);
tag.setDouble("posZ", pos.z-player.motionZ);
tag.setDouble("dirX", view.x);
tag.setDouble("dirY", view.y);
tag.setDouble("dirZ", view.z);
tag.setFloat("r", 0.2F);
tag.setFloat("g", 0.8F);
tag.setFloat("b", 0.9F);
tag.setFloat("a", 1.5F);
tag.setInteger("lifetime", 1);
tag.setFloat("width", 0.01F);
tag.setFloat("length", 2F);
tag.setFloat("gravity", 0);
tag.setFloat("angle", 15F);
tag.setInteger("count", 12);
MainRegistry.proxy.effectNT(tag);
ParticleVortexBeam beam = new ParticleVortexBeam(player.world, pos.x, pos.y, pos.z, hitPos.x, hitPos.y, hitPos.z, shouldDoThirdPerson);
beam.color(0.5F, 0.8F, 0.9F, 2.0F);
beam.width(0.125F);
Minecraft.getMinecraft().effectRenderer.addEffect(beam);
ParticleVortexFireFlash flash = new ParticleVortexFireFlash(player.world, pos.x, pos.y, pos.z, hitPos.x, hitPos.y, hitPos.z);
flash.color(0.5F, 0.8F, 0.9F, 1F);
flash.width(0.5F);
Minecraft.getMinecraft().effectRenderer.addEffect(flash);
Vec3 line = hitPos.subtract(pos);
int circleParticles = (int) line.lengthVector();
for(int i = 0; i < circleParticles; i ++){
Vec3 circlePos = line.scale(i/(float)circleParticles).add(pos);
ParticleVortexCircle c = new ParticleVortexCircle(player.worldObj, circlePos.x, circlePos.y, circlePos.z, 0.5F+player.worldObj.rand.nextFloat()*0.3F);
c.color(0.5F, 0.8F, 0.9F, 0.15F);
c.lifetime((int) (15+(i/(float)circleParticles)*10));
Minecraft.getMinecraft().effectRenderer.addEffect(c);
}
int extraParticles = (int) line.lengthVector();
for(int i = 0; i < extraParticles; i ++){
Vec3d circlePos = line.scale((i/(float)circleParticles)*0.25).add(pos);
float randX = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F;
float randY = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F;
float randZ = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F;
ParticleVortexParticle c = new ParticleVortexParticle(player.worldObj, circlePos.x+randX, circlePos.y+randY, circlePos.z+randZ, 0.5F);
c.color(0.5F, 0.8F, 0.9F, 0.15F);
c.lifetime(30);
Minecraft.getMinecraft().effectRenderer.addEffect(c);
}
ParticleVortexGlow glow = new ParticleVortexGlow(player.worldObj, pos.x, pos.y, pos.z, 2F);
glow.color(0.3F, 0.7F, 1F, 0.5F);
glow.lifetime(15);
Minecraft.getMinecraft().effectRenderer.addEffect(glow);
if(hitNormal != null){
Vec3d sparkAxis = line.normalize().scale(0.25);
switch(r.sideHit.getAxis()){
case X:
sparkAxis = new Vec3d(-sparkAxis.x, sparkAxis.y, sparkAxis.z);
break;
case Y:
sparkAxis = new Vec3d(sparkAxis.x, -sparkAxis.y, sparkAxis.z);
break;
case Z:
sparkAxis = new Vec3d(sparkAxis.x, sparkAxis.y, -sparkAxis.z);
break;
}
tag = new NBTTagCompound();
tag.setString("type", "spark");
tag.setString("mode", "coneBurst");
tag.setDouble("posX", hitPos.x);
tag.setDouble("posY", hitPos.y);
tag.setDouble("posZ", hitPos.z);
tag.setDouble("dirX", sparkAxis.x);
tag.setDouble("dirY", sparkAxis.y+0.1);
tag.setDouble("dirZ", sparkAxis.z);
tag.setFloat("r", 0.2F);
tag.setFloat("g", 0.8F);
tag.setFloat("b", 0.9F);
tag.setFloat("a", 1.5F);
tag.setInteger("lifetime", 20);
tag.setInteger("randLifetime", 30);
tag.setFloat("width", 0.015F);
tag.setFloat("length", 0.5F);
tag.setFloat("gravity", 0.05F);
tag.setFloat("angle", 70F);
tag.setInteger("count", 15);
tag.setFloat("randomVelocity", 0.1F);
MainRegistry.proxy.effectNT(tag);
ParticleVortexHit hit = new ParticleVortexHit(player.world, hitPos.x, hitPos.y, hitPos.z, 2.5F+player.world.rand.nextFloat()*0.5F, 90);
hit.color(0.4F, 0.8F, 1F, 0.25F);
hit.lifetime(20);
ParticleVortexHit hit2 = new ParticleVortexHit(player.world, hitPos.x, hitPos.y, hitPos.z, 2.5F+player.world.rand.nextFloat()*0.5F, -90);
hit2.color(0.4F, 0.8F, 1F, 0.25F);
hit2.lifetime(20);
Minecraft.getMinecraft().effectRenderer.addEffect(hit);
Minecraft.getMinecraft().effectRenderer.addEffect(hit2);
}
MainRegistry.proxy.setRecoil(3);
lastFireTime = System.currentTimeMillis();
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasCustomHudElement() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void renderHud(ScaledResolution res, GuiIngame gui, ItemStack stack, float partialTicks) {
float x = res.getScaledWidth()/2;
float y = res.getScaledHeight()/2;
Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.vortex_hud_reticle);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glColor4f(0.4F, 0.9F, 0.9F, 1.0F);
GL11.glEnable(GL11.GL_BLEND);
GlStateManager.tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
RenderHelper.drawGuiRect(x - 11F, y - 11F, 0, 0, 22, 22, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.vortex_hud_circle);
//Running off of system time gives less wonky results than relying on server updating the nbt tag.
long time = System.currentTimeMillis();
//float cooldown = (this.mainConfig.rateOfFire-getDelay(stack)+partialTicks)/(float)this.mainConfig.rateOfFire;
//Adding 0.05 so it doesn't start at nothing makes it look better in my opinion.
//It's 55 instead of 50 (50 ms in one tick) because xon lets you fire slightly before the cooldown is over. This extends the cooldown slightly beyond the real one.
float cooldown = MathHelper.clamp((time-lastFireTime)/(float)(mainConfig.rateOfFire*55), 0, 1)+0.05F;
final int SUBDIVISIONS = 64;
Tessellator tes = Tessellator.instance;
tes.startDrawing(GL11.GL_TRIANGLE_FAN);
tes.setColorRGBA_F(0.4F, 0.9F, 0.9F, 0.4F);
tes.addVertexWithUV(x, y, 0, 0.5, 0.5);
for(int i = 0; i < SUBDIVISIONS+1; i ++){
//Should be quite fast because MathHelper uses a sin table... right?
float ratio = i/(float)SUBDIVISIONS;
float x2 = MathHelper.sin((float) (ratio*Math.PI*2+0.5*Math.PI));
float y2 = MathHelper.cos((float) (ratio*Math.PI*2+0.5*Math.PI));
float alphaMult = 1-ratio < cooldown ? 1 : 0;
buf.pos(x+x2*11, y+y2*11, 0).tex(BobMathUtil.remap01(x2, -1, 1), BobMathUtil.remap01(y2, -1, 1)).color(0.4F, 0.9F, 0.9F, 0.4F*alphaMult).endVertex();
}
tes.draw();
GlStateManager.tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
GlStateManager.disableBlend();
}*/
}

View File

@ -5,7 +5,6 @@ import java.util.List;
import org.lwjgl.input.Mouse;
import com.hbm.config.GeneralConfig;
import com.hbm.entity.projectile.EntityBulletBaseNT;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.GunConfiguration;
@ -131,6 +130,9 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem {
for(int i = 0; i < bullets; i++) {
spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config));
}
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
setCharge(stack, getCharge(stack) - config.dischargePerShot);;
}
@ -138,19 +140,9 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem {
world.playSoundAtEntity(player, mainConfig.firingSound, 1.0F, mainConfig.firingPitch);
}
protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) {
EntityBulletBaseNT bullet = new EntityBulletBaseNT(world, config, player);
world.spawnEntityInWorld(bullet);
if(this.mainConfig.animations.containsKey(AnimType.CYCLE) && player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
}
public void startAction(ItemStack stack, World world, EntityPlayer player, boolean main) {
if(mainConfig.firingMode == mainConfig.FIRE_MANUAL && main && tryShoot(stack, world, player, main)) {
if(mainConfig.firingMode == GunConfiguration.FIRE_MANUAL && main && tryShoot(stack, world, player, main)) {
fire(stack, world, player);
setDelay(stack, mainConfig.rateOfFire);

View File

@ -850,6 +850,7 @@ public class ResourceManager {
public static final HashMap<String, BusAnimation> cursed_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/cursed.json"));
public static final HashMap<String, BusAnimation> novac_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/novac.json"));
public static final HashMap<String, BusAnimation> ks23_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/ks23.json"));
public static final HashMap<String, BusAnimation> spas_12_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/spas12.json"));
public static final IModelCustom lance = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/lance.obj"));

View File

@ -66,6 +66,11 @@ public class GunAnimationPacket implements IMessage {
if(animation == null && type == AnimType.RELOAD_EMPTY) {
animation = base.getAnimation(stack, AnimType.RELOAD);
}
// Fallback to regular CYCLE if no ALT_CYCLE exists
if(animation == null && type == AnimType.ALT_CYCLE) {
animation = base.getAnimation(stack, AnimType.CYCLE);
}
if(animation != null) {
boolean isReloadAnimation = type == AnimType.RELOAD || type == AnimType.RELOAD_CYCLE || type == AnimType.RELOAD_EMPTY;

View File

@ -4,8 +4,10 @@ import java.awt.Color;
import org.lwjgl.opengl.GL11;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.items.weapon.ItemGunBase;
import com.hbm.main.ResourceManager;
import com.hbm.particle.SpentCasing;
import com.hbm.render.anim.HbmAnimations;
import net.minecraft.client.Minecraft;
@ -83,12 +85,15 @@ public class ItemRenderWeaponKS23 implements IItemRenderer {
HbmAnimations.applyRelevantTransformation("Shell");
// TODO: Fetch the correct colors to render on the shells
Color shellColor = new Color(SpentCasing.COLOR_CASE_4GA);
ItemGunBase gun = (ItemGunBase)item.getItem();
BulletConfiguration bullet = BulletConfigSyncingUtil.pullConfig(gun.mainConfig.config.get(ItemGunBase.getMagType(item)));
int[] colors = bullet.spentCasing.getColors();
Color shellColor = new Color(colors[1]);
GL11.glColor3f(shellColor.getRed() / 255F, shellColor.getGreen() / 255F, shellColor.getBlue() / 255F);
ResourceManager.ks23.renderPart("Shell");
Color shellForeColor = new Color(0xFFD800);
Color shellForeColor = new Color(colors[0]);
GL11.glColor3f(shellForeColor.getRed() / 255F, shellForeColor.getGreen() / 255F, shellForeColor.getBlue() / 255F);
ResourceManager.ks23.renderPart("ShellFore");

View File

@ -1,7 +1,12 @@
package com.hbm.render.item.weapon;
import java.awt.Color;
import org.lwjgl.opengl.GL11;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.items.weapon.ItemGunBase;
import com.hbm.main.ResourceManager;
import com.hbm.render.anim.HbmAnimations;
@ -47,16 +52,37 @@ public class ItemRenderWeaponSpas12 implements IItemRenderer {
double s0 = 0.5D;
GL11.glRotated(25, 0, 0, 1);
GL11.glTranslated(0, -0.8, 0.1);
GL11.glRotated(80, 0, 1, 0);
GL11.glRotated(-100, 0, 1, 0);
GL11.glScaled(s0, s0, s0);
HbmAnimations.applyRelevantTransformation("SPAS_RECOIL");
HbmAnimations.applyRelevantTransformation("MainBody");
ResourceManager.spas_12.renderPart("MainBody");
HbmAnimations.applyRelevantTransformation("SPAS_PUMP");
GL11.glPushMatrix();
HbmAnimations.applyRelevantTransformation("PumpGrip");
ResourceManager.spas_12.renderPart("PumpGrip");
GL11.glPopMatrix();
GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.casings_tex);
HbmAnimations.applyRelevantTransformation("Shell");
ItemGunBase gun = (ItemGunBase)item.getItem();
BulletConfiguration bullet = BulletConfigSyncingUtil.pullConfig(gun.mainConfig.config.get(ItemGunBase.getMagType(item)));
int[] colors = bullet.spentCasing.getColors();
Color shellColor = new Color(colors[1]);
GL11.glColor3f(shellColor.getRed() / 255F, shellColor.getGreen() / 255F, shellColor.getBlue() / 255F);
ResourceManager.spas_12.renderPart("Shell");
Color shellForeColor = new Color(colors[0]);
GL11.glColor3f(shellForeColor.getRed() / 255F, shellForeColor.getGreen() / 255F, shellForeColor.getBlue() / 255F);
ResourceManager.spas_12.renderPart("ShellFore");
GL11.glColor3f(1F, 1F, 1F);
GL11.glPopMatrix();
break;
@ -65,9 +91,9 @@ public class ItemRenderWeaponSpas12 implements IItemRenderer {
double scale = 0.25D;
GL11.glScaled(scale, scale, scale);
GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(10, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(15F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(2F, -1F, -2F);
GL11.glRotatef(190, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-15F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(-2F, -1F, 2F);
ResourceManager.spas_12.renderAll();
@ -77,7 +103,7 @@ public class ItemRenderWeaponSpas12 implements IItemRenderer {
double s1 = 0.25D;
GL11.glScaled(s1, s1, s1);
GL11.glTranslated(0, 0, -4);
GL11.glTranslated(0, 0, 4);
ResourceManager.spas_12.renderAll();
@ -91,7 +117,7 @@ public class ItemRenderWeaponSpas12 implements IItemRenderer {
GL11.glTranslated(12, 13.5, 0);
GL11.glRotated(-90, 0, 1, 0);
GL11.glRotated(-135, 1, 0, 0);
GL11.glScaled(s, s, -s);
GL11.glScaled(s, s, s);
ResourceManager.spas_12.renderAll();
@ -99,9 +125,6 @@ public class ItemRenderWeaponSpas12 implements IItemRenderer {
default: break;
}
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix();
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -199,6 +199,7 @@
"weapon.extinguisher": {"category": "player", "sounds": [{"name": "weapon/extinguisher", "stream": false}]},
"weapon.robin_explosion": {"category": "player", "sounds": [{"name": "weapon/robin_explosion", "stream": false}]},
"weapon.shotgunPump": {"category": "player", "sounds": [{"name": "weapon/shotgunShootPump", "stream": false}]},
"weapon.shotgunPumpAlt": {"category": "player", "sounds": [{"name": "weapon/shotgunShootPumpAlt", "stream": false}]},
"weapon.explosionMedium": {"category": "player", "sounds": [{"name": "weapon/explosion_medium", "stream": false}]},
"weapon.hicalShot": {"category": "player", "sounds": [{"name": "weapon/hicalShot", "stream": false}]},
"weapon.coilgunReload": {"category": "player", "sounds": [{"name": "weapon/coilgunReload", "stream": false}]},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB