mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
lockon funsies
This commit is contained in:
parent
038bb626e0
commit
10987bee2c
@ -5,6 +5,13 @@ import java.util.Random;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.explosion.ExplosionLarge;
|
||||
import com.hbm.explosion.ExplosionNukeSmall;
|
||||
import com.hbm.explosion.vanillant.ExplosionVNT;
|
||||
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
|
||||
import com.hbm.explosion.vanillant.standard.BlockMutatorFire;
|
||||
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
|
||||
import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth;
|
||||
import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon;
|
||||
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.bomb.TileEntityLandmine;
|
||||
@ -147,10 +154,19 @@ public class Landmine extends BlockContainer implements IBomb {
|
||||
Landmine.safeMode = false;
|
||||
|
||||
if(this == ModBlocks.mine_ap) {
|
||||
world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 2.5F, false, false);
|
||||
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F);
|
||||
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, 10F));
|
||||
vnt.setPlayerProcessor(new PlayerProcessorStandard());
|
||||
vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F));
|
||||
vnt.explode();
|
||||
} else if(this == ModBlocks.mine_he) {
|
||||
ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 3F, true, false, false);
|
||||
world.newExplosion(null, x + 0.5, y + 2, z + 0.5, 15F, false, false);
|
||||
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 4F);
|
||||
vnt.setBlockAllocator(new BlockAllocatorStandard());
|
||||
vnt.setBlockProcessor(new BlockProcessorStandard());
|
||||
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, 35));
|
||||
vnt.setPlayerProcessor(new PlayerProcessorStandard());
|
||||
vnt.setSFX(new ExplosionEffectWeapon(15, 3.5F, 1.25F));
|
||||
vnt.explode();
|
||||
} else if(this == ModBlocks.mine_shrap) {
|
||||
ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 1, true, false, false);
|
||||
ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D);
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.hbm.entity.projectile;
|
||||
|
||||
import com.hbm.items.weapon.sedna.BulletConfig;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.TrackerUtil;
|
||||
import com.hbm.util.Vec3NT;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntityTrackerEntry;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
@ -19,6 +23,7 @@ public class EntityBulletBaseMK4 extends EntityThrowableInterp {
|
||||
public double accel;
|
||||
public float damage;
|
||||
public int ricochets = 0;
|
||||
public Entity lockonTarget = null;
|
||||
|
||||
public EntityBulletBaseMK4(World world) {
|
||||
super(world);
|
||||
@ -49,6 +54,10 @@ public class EntityBulletBaseMK4 extends EntityThrowableInterp {
|
||||
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
|
||||
motionX += entity.motionX;
|
||||
motionY += entity.motionY;
|
||||
motionZ += entity.motionZ;
|
||||
|
||||
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 1.0F, this.config.spread + gunSpread);
|
||||
}
|
||||
@ -90,6 +99,22 @@ public class EntityBulletBaseMK4 extends EntityThrowableInterp {
|
||||
double dY = this.posY - this.prevPosY;
|
||||
double dZ = this.posZ - this.prevPosZ;
|
||||
|
||||
if(this.lockonTarget != null && !this.lockonTarget.isDead) {
|
||||
Vec3NT motion = new Vec3NT(motionX, motionY, motionZ);
|
||||
double vel = motion.lengthVector();
|
||||
Vec3NT delta = new Vec3NT(lockonTarget.posX - posX, lockonTarget.posY + lockonTarget.height / 2D - posY, lockonTarget.posZ - posZ);
|
||||
float turn = Math.min(0.005F * this.ticksExisted, 1F);
|
||||
Vec3NT newVec = new Vec3NT(
|
||||
BobMathUtil.interp(motion.xCoord, delta.xCoord, turn),
|
||||
BobMathUtil.interp(motion.yCoord, delta.yCoord, turn),
|
||||
BobMathUtil.interp(motion.zCoord, delta.zCoord, turn)).normalizeSelf().multiply(vel);
|
||||
this.motionX = newVec.xCoord;
|
||||
this.motionY = newVec.yCoord;
|
||||
this.motionZ = newVec.zCoord;
|
||||
EntityTrackerEntry entry = TrackerUtil.getTrackerEntry((WorldServer) worldObj, this.getEntityId());
|
||||
entry.lastYaw = MathHelper.floor_float(this.rotationYaw * 256.0F / 360.0F) + 10; //force-trigger rotation update
|
||||
}
|
||||
|
||||
this.prevVelocity = this.velocity;
|
||||
this.velocity = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
|
||||
|
||||
|
||||
@ -59,6 +59,8 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
|
||||
public static final String KEY_RELOAD = "reload_";
|
||||
public static final String KEY_LASTANIM = "lastanim_";
|
||||
public static final String KEY_ANIMTIMER = "animtimer_";
|
||||
public static final String KEY_LOCKONTARGET = "lockontarget";
|
||||
public static final String KEY_LOCKEDON = "lockedon";
|
||||
|
||||
public static ConcurrentHashMap<EntityPlayer, AudioWrapper> loopedSounds = new ConcurrentHashMap();
|
||||
|
||||
@ -231,6 +233,11 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
|
||||
// GUN AIMING //
|
||||
public static float getWear(ItemStack stack, int index) { return getValueFloat(stack, KEY_WEAR + index); }
|
||||
public static void setWear(ItemStack stack, int index, float value) { setValueFloat(stack, KEY_WEAR + index, value); }
|
||||
// LOCKON //
|
||||
public static int getLockonTarget(ItemStack stack) { return getValueInt(stack, KEY_LOCKONTARGET); }
|
||||
public static void setLockonTarget(ItemStack stack, int value) { setValueInt(stack, KEY_LOCKONTARGET, value); }
|
||||
public static boolean getIsLockedOn(ItemStack stack) { return getValueBool(stack, KEY_LOCKEDON); }
|
||||
public static void setIsLockedOn(ItemStack stack, boolean value) { setValueBool(stack, KEY_LOCKEDON, value); }
|
||||
// ANIM TRACKING //
|
||||
public static AnimType getLastAnim(ItemStack stack, int index) { return EnumUtil.grabEnumSafely(AnimType.class, getValueInt(stack, KEY_LASTANIM + index)); }
|
||||
public static void setLastAnim(ItemStack stack, int index, AnimType value) { setValueInt(stack, KEY_LASTANIM + index, value.ordinal()); }
|
||||
|
||||
@ -134,4 +134,10 @@ public class Receiver {
|
||||
.canFire(Lego.LAMBDA_STANDARD_CAN_FIRE)
|
||||
.fire(Lego.LAMBDA_STANDARD_FIRE);
|
||||
}
|
||||
|
||||
public Receiver setupLockonFire() {
|
||||
return this
|
||||
.canFire(Lego.LAMBDA_LOCKON_CAN_FIRE)
|
||||
.fire(Lego.LAMBDA_STANDARD_FIRE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,20 +154,28 @@ public class Lego {
|
||||
|
||||
/** Toggles isAiming. Used by keybinds. */
|
||||
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_TOGGLE_AIM = (stack, ctx) -> { ItemGunBaseNT.setIsAiming(stack, !ItemGunBaseNT.getIsAiming(stack)); };
|
||||
|
||||
/** Returns true if the mag has ammo in it. Used by keybind functions on whether to fire, and deciders on whether to trigger a refire, */
|
||||
|
||||
/** Returns true if the mag has ammo in it. Used by keybind functions on whether to fire, and deciders on whether to trigger a refire. */
|
||||
public static BiFunction<ItemStack, LambdaContext, Boolean> LAMBDA_STANDARD_CAN_FIRE = (stack, ctx) -> { return ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmount(stack) > 0; };
|
||||
|
||||
/** Returns true if the mag has ammo in it, and the gun is in the locked on state */
|
||||
public static BiFunction<ItemStack, LambdaContext, Boolean> LAMBDA_LOCKON_CAN_FIRE = (stack, ctx) -> { return ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmount(stack) > 0 && ItemGunBaseNT.getIsLockedOn(stack); };
|
||||
|
||||
|
||||
|
||||
|
||||
/** JUMPER - bypasses mag testing and just allows constant fire */
|
||||
public static BiFunction<ItemStack, LambdaContext, Boolean> LAMBDA_DEBUG_CAN_FIRE = (stack, ctx) -> { return true; };
|
||||
|
||||
|
||||
/** Spawns an EntityBulletBaseMK4 with the loaded bulletcfg */
|
||||
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_STANDARD_FIRE = (stack, ctx) -> {
|
||||
doStandardFire(stack, ctx, AnimType.CYCLE);
|
||||
};
|
||||
/** Spawns an EntityBulletBaseMK4 with the loaded bulletcfg, then resets lockon progress */
|
||||
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_LOCKON_FIRE = (stack, ctx) -> {
|
||||
doStandardFire(stack, ctx, AnimType.CYCLE);
|
||||
ItemGunBaseNT.setIsLockedOn(stack, false);
|
||||
};
|
||||
|
||||
public static void doStandardFire(ItemStack stack, LambdaContext ctx, AnimType anim) {
|
||||
EntityPlayer player = ctx.player;
|
||||
@ -195,6 +203,7 @@ public class Lego {
|
||||
float damage = primary.getBaseDamage(stack) * getStandardWearDamage(stack, ctx.config, index);
|
||||
float spread = primary.getGunSpread(stack) * aim + getStandardWearSpread(stack, ctx.config, index) * 0.125F;
|
||||
EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(player, config, damage, spread, sideOffset, heightOffset, forwardOffset);
|
||||
if(ItemGunBaseNT.getIsLockedOn(stack)) mk4.lockonTarget = player.worldObj.getEntityByID(ItemGunBaseNT.getLockonTarget(stack));
|
||||
player.worldObj.spawnEntityInWorld(mk4);
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.function.BiConsumer;
|
||||
import com.hbm.config.ClientConfig;
|
||||
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
|
||||
import com.hbm.items.weapon.sedna.Receiver;
|
||||
import com.hbm.items.weapon.sedna.impl.ItemGunStinger;
|
||||
import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext;
|
||||
import com.hbm.items.weapon.sedna.mags.IMagazine;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -664,6 +665,24 @@ public class Orchestras {
|
||||
if(player.worldObj.isRemote) return;
|
||||
AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex);
|
||||
int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex);
|
||||
|
||||
AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player);
|
||||
if(ItemGunStinger.getLockonProgress(stack) > 0 && !ItemGunStinger.getIsLockedOn(stack)) {
|
||||
//start sound
|
||||
if(runningAudio == null || !runningAudio.isPlaying()) {
|
||||
AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.lockon", (float) player.posX, (float) player.posY, (float) player.posZ, 1F, 15F, 1F, 10);
|
||||
ItemGunBaseNT.loopedSounds.put(player, audio);
|
||||
audio.startSound();
|
||||
}
|
||||
//keepalive
|
||||
if(runningAudio != null && runningAudio.isPlaying()) {
|
||||
runningAudio.keepAlive();
|
||||
runningAudio.updatePosition((float) player.posX, (float) player.posY, (float) player.posZ);
|
||||
}
|
||||
} else {
|
||||
//stop sound due to timeout
|
||||
if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound();
|
||||
}
|
||||
|
||||
if(type == AnimType.RELOAD) {
|
||||
if(timer == 30) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.insertCanister", 1F, 1F);
|
||||
|
||||
@ -65,7 +65,7 @@ public class XFactoryRocket {
|
||||
.dmg(25F).delay(5).reload(50).jam(40).sound("hbm:weapon.rpgShoot", 1.0F, 1.0F)
|
||||
.mag(new MagazineSingleReload(0, 1).addConfigs(rocket_rpzb_he, rocket_rpzb_heat))
|
||||
.offset(1, -0.0625 * 1.5, -0.1875D)
|
||||
.setupStandardFire().recoil(Lego.LAMBDA_STANDARD_RECOIL))
|
||||
.setupLockonFire().recoil(Lego.LAMBDA_STANDARD_RECOIL))
|
||||
.setupStandardConfiguration().ps(LAMBDA_STINGER_SECONDARY_PRESS).rs(LAMBDA_STINGER_SECONDARY_RELEASE)
|
||||
.anim(LAMBDA_PANZERSCHRECK_ANIMS).orchestra(Orchestras.ORCHESTRA_STINGER)
|
||||
).setUnlocalizedName("gun_stinger").setTextureName(RefStrings.MODID + ":gun_darter");
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
package com.hbm.items.weapon.sedna.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.items.weapon.sedna.GunConfig;
|
||||
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
|
||||
import com.hbm.items.weapon.sedna.hud.IHUDComponent;
|
||||
import com.hbm.render.util.RenderScreenOverlay;
|
||||
import com.hbm.util.Vec3NT;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -11,6 +14,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
@ -18,8 +22,6 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
public class ItemGunStinger extends ItemGunBaseNT {
|
||||
|
||||
public static final String KEY_LOCKINGON = "lockingon";
|
||||
public static final String KEY_LOCKEDON = "lockedon";
|
||||
public static final String KEY_LOCKONTARGET = "lockontarget";
|
||||
public static final String KEY_LOCKONPROGRESS = "lockonprogress";
|
||||
|
||||
public static float prevLockon;
|
||||
@ -40,37 +42,81 @@ public class ItemGunStinger extends ItemGunBaseNT {
|
||||
}
|
||||
|
||||
this.prevLockon = this.lockon;
|
||||
int prevTarget = this.getLockonTarget(stack);
|
||||
if(isHeld && this.getIsLockingOn(stack) && this.getIsAiming(stack)) {
|
||||
int newLockonTarget = this.getLockonTarget(player);
|
||||
|
||||
if(newLockonTarget == -1) {
|
||||
resetLockon(world, stack);
|
||||
} else {
|
||||
if(newLockonTarget != prevTarget) {
|
||||
resetLockon(world, stack);
|
||||
this.setLockonTarget(stack, newLockonTarget);
|
||||
|
||||
if(!world.isRemote) {
|
||||
int prevTarget = this.getLockonTarget(stack);
|
||||
if(isHeld && this.getIsLockingOn(stack) && this.getIsAiming(stack) && this.getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getAmount(stack) > 0) {
|
||||
int newLockonTarget = this.getLockonTarget(player);
|
||||
|
||||
if(newLockonTarget == -1) {
|
||||
if(!this.getIsLockedOn(stack)) resetLockon(world, stack);
|
||||
} else {
|
||||
if(!this.getIsLockedOn(stack) && newLockonTarget != prevTarget) {
|
||||
resetLockon(world, stack);
|
||||
this.setLockonTarget(stack, newLockonTarget);
|
||||
}
|
||||
progressLockon(world, stack);
|
||||
|
||||
if(this.getLockonProgress(stack) >= 60 && !this.getIsLockedOn(stack)) {
|
||||
player.worldObj.playSoundAtEntity(player, "hbm:item.techBleep", 1F, 1F);
|
||||
this.setIsLockedOn(stack, true);
|
||||
}
|
||||
}
|
||||
progressLockon(world, stack);
|
||||
} else {
|
||||
resetLockon(world, stack);
|
||||
}
|
||||
} else {
|
||||
resetLockon(world, stack);
|
||||
if(this.getLockonProgress(stack) > 1) {
|
||||
this.lockon += (1F / 60F);
|
||||
} else {
|
||||
this.lockon = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetLockon(World world, ItemStack stack) {
|
||||
if(world.isRemote) this.lockon = 0F;
|
||||
if(!world.isRemote) this.setLockonProgress(stack, 0);
|
||||
this.setLockonProgress(stack, 0);
|
||||
this.setIsLockedOn(stack, false);
|
||||
}
|
||||
|
||||
public void progressLockon(World world, ItemStack stack) {
|
||||
if(world.isRemote) this.lockon += (1F / 100F);
|
||||
if(!world.isRemote) this.setLockonProgress(stack, this.getLockonProgress(stack) + 1);
|
||||
this.setLockonProgress(stack, this.getLockonProgress(stack) + 1);
|
||||
}
|
||||
|
||||
public static int getLockonTarget(EntityPlayer player) {
|
||||
return -1;
|
||||
|
||||
double x = player.posX;
|
||||
double y = player.posY + player.getEyeHeight();
|
||||
double z = player.posZ;
|
||||
|
||||
Vec3NT delta = new Vec3NT(player.getLook(1F)).multiply(150);
|
||||
Vec3NT look = new Vec3NT(delta).add(x, y, z);
|
||||
Vec3NT pos = new Vec3NT(x, y, z);
|
||||
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(Vec3NT.getMinX(look, pos), Vec3NT.getMinY(look, pos), Vec3NT.getMinZ(look, pos),
|
||||
Vec3NT.getMaxX(look, pos), Vec3NT.getMaxY(look, pos), Vec3NT.getMaxZ(look, pos));
|
||||
List<Entity> entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, aabb);
|
||||
Entity closestEntity = null;
|
||||
double closestAngle = 360D;
|
||||
|
||||
Vec3NT toEntity = new Vec3NT(0, 0, 0);
|
||||
|
||||
for(Entity entity : entities) {
|
||||
if(entity.height < 0.5F) continue;
|
||||
toEntity.setComponents(entity.posX - x, entity.posY + entity.height / 2D - y, entity.posZ - z);
|
||||
|
||||
double vecProd = toEntity.xCoord * delta.xCoord + toEntity.yCoord * delta.yCoord + toEntity.zCoord * delta.zCoord;
|
||||
double bot = toEntity.lengthVector() * delta.lengthVector();
|
||||
double angle = Math.abs(Math.acos(vecProd / bot) * 180 / Math.PI);
|
||||
|
||||
if(angle < closestAngle && angle < 10) {
|
||||
closestAngle = angle;
|
||||
closestEntity = entity;
|
||||
}
|
||||
}
|
||||
|
||||
return closestEntity == null ? - 1 : closestEntity.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,10 +147,6 @@ public class ItemGunStinger extends ItemGunBaseNT {
|
||||
|
||||
public static boolean getIsLockingOn(ItemStack stack) { return getValueBool(stack, KEY_LOCKINGON); }
|
||||
public static void setIsLockingOn(ItemStack stack, boolean value) { setValueBool(stack, KEY_LOCKINGON, value); }
|
||||
public static boolean getIsLockedOn(ItemStack stack) { return getValueBool(stack, KEY_LOCKEDON); }
|
||||
public static void setIsLockedOn(ItemStack stack, boolean value) { setValueBool(stack, KEY_LOCKEDON, value); }
|
||||
public static int getLockonTarget(ItemStack stack) { return getValueInt(stack, KEY_LOCKONTARGET); }
|
||||
public static void setLockonTarget(ItemStack stack, int value) { setValueInt(stack, KEY_LOCKONTARGET, value); }
|
||||
public static int getLockonProgress(ItemStack stack) { return getValueInt(stack, KEY_LOCKONPROGRESS); }
|
||||
public static void setLockonProgress(ItemStack stack, int value) { setValueInt(stack, KEY_LOCKONPROGRESS, value); }
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import java.util.Random;
|
||||
import com.hbm.particle.ParticleSpentCasing;
|
||||
import com.hbm.particle.SpentCasing;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -56,6 +58,7 @@ public class CasingCreator implements IParticleCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void makeParticle(World world, EntityPlayer player, TextureManager texman, Random rand, double x, double y, double z, NBTTagCompound data) {
|
||||
|
||||
String name = data.getString("name");
|
||||
|
||||
@ -5,6 +5,8 @@ import java.util.Random;
|
||||
import com.hbm.particle.ParticleExplosionSmall;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
@ -34,6 +36,7 @@ public class ExplosionSmallCreator implements IParticleCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void makeParticle(World world, EntityPlayer player, TextureManager texman, Random rand, double x, double y, double z, NBTTagCompound data) {
|
||||
|
||||
int cloudCount = data.getInteger("cloudCount");
|
||||
|
||||
@ -4,6 +4,8 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.particle.ParticleFlamethrower;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -19,6 +21,7 @@ public class FlameCreator implements IParticleCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void makeParticle(World world, EntityPlayer player, TextureManager texman, Random rand, double x, double y, double z, NBTTagCompound data) {
|
||||
ParticleFlamethrower particle = new ParticleFlamethrower(world, x, y, z);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
|
||||
|
||||
128
src/main/java/com/hbm/util/Vec3NT.java
Normal file
128
src/main/java/com/hbm/util/Vec3NT.java
Normal file
@ -0,0 +1,128 @@
|
||||
package com.hbm.util;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class Vec3NT extends Vec3 {
|
||||
|
||||
public Vec3NT(double x, double y, double z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
public Vec3NT(Vec3 vec) {
|
||||
super(vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
}
|
||||
|
||||
public Vec3NT normalizeSelf() {
|
||||
double len = MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord);
|
||||
if(len < 1.0E-4D) {
|
||||
return multiply(0D);
|
||||
} else {
|
||||
return multiply(1D / len);
|
||||
}
|
||||
}
|
||||
|
||||
public Vec3NT add(double x, double y, double z) {
|
||||
this.xCoord += x;
|
||||
this.yCoord += y;
|
||||
this.zCoord += z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec3NT multiply(double m) {
|
||||
this.xCoord *= m;
|
||||
this.yCoord *= m;
|
||||
this.zCoord *= m;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec3NT multiply(double x, double y, double z) {
|
||||
this.xCoord *= x;
|
||||
this.yCoord *= y;
|
||||
this.zCoord *= z;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3NT setComponents(double x, double y, double z) {
|
||||
this.xCoord = x;
|
||||
this.yCoord = y;
|
||||
this.zCoord = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundXRad(double alpha) {
|
||||
double cos = Math.cos(alpha);
|
||||
double sin = Math.sin(alpha);
|
||||
double x = this.xCoord;
|
||||
double y = this.yCoord * cos + this.zCoord * sin;
|
||||
double z = this.zCoord * cos - this.yCoord * sin;
|
||||
return this.setComponents(x, y, z);
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundYRad(double alpha) {
|
||||
double cos = Math.cos(alpha);
|
||||
double sin = Math.sin(alpha);
|
||||
double x = this.xCoord * cos + this.zCoord * sin;
|
||||
double y = this.yCoord;
|
||||
double z = this.zCoord * cos - this.xCoord * sin;
|
||||
return this.setComponents(x, y, z);
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundZRad(double alpha) {
|
||||
double cos = Math.cos(alpha);
|
||||
double sin = Math.sin(alpha);
|
||||
double x = this.xCoord * cos + this.yCoord * sin;
|
||||
double y = this.yCoord * cos - this.xCoord * sin;
|
||||
double z = this.zCoord;
|
||||
return this.setComponents(x, y, z);
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundXDeg(double alpha) {
|
||||
return this.rotateAroundXRad(alpha * 180D / Math.PI);
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundYDeg(double alpha) {
|
||||
return this.rotateAroundYRad(alpha * 180D / Math.PI);
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundZDeg(double alpha) {
|
||||
return this.rotateAroundZRad(alpha * 180D / Math.PI);
|
||||
}
|
||||
|
||||
public static double getMinX(Vec3NT... vecs) {
|
||||
double min = Double.POSITIVE_INFINITY;
|
||||
for(Vec3NT vec : vecs) if(vec.xCoord < min) min = vec.xCoord;
|
||||
return min;
|
||||
}
|
||||
|
||||
public static double getMinY(Vec3NT... vecs) {
|
||||
double min = Double.POSITIVE_INFINITY;
|
||||
for(Vec3NT vec : vecs) if(vec.yCoord < min) min = vec.yCoord;
|
||||
return min;
|
||||
}
|
||||
|
||||
public static double getMinZ(Vec3NT... vecs) {
|
||||
double min = Double.POSITIVE_INFINITY;
|
||||
for(Vec3NT vec : vecs) if(vec.zCoord < min) min = vec.zCoord;
|
||||
return min;
|
||||
}
|
||||
|
||||
public static double getMaxX(Vec3NT... vecs) {
|
||||
double max = Double.NEGATIVE_INFINITY;
|
||||
for(Vec3NT vec : vecs) if(vec.xCoord > max) max = vec.xCoord;
|
||||
return max;
|
||||
}
|
||||
|
||||
public static double getMaxY(Vec3NT... vecs) {
|
||||
double max = Double.NEGATIVE_INFINITY;
|
||||
for(Vec3NT vec : vecs) if(vec.yCoord > max) max = vec.yCoord;
|
||||
return max;
|
||||
}
|
||||
|
||||
public static double getMaxZ(Vec3NT... vecs) {
|
||||
double max = Double.NEGATIVE_INFINITY;
|
||||
for(Vec3NT vec : vecs) if(vec.zCoord > max) max = vec.zCoord;
|
||||
return max;
|
||||
}
|
||||
}
|
||||
@ -226,6 +226,7 @@
|
||||
|
||||
"weapon.fire.blackPowder": {"category": "player", "sounds": [{"name": "weapon/fire/blackPowder", "stream": false}]},
|
||||
"weapon.fire.flameLoop": {"category": "player", "sounds": [{"name": "weapon/fire/flameLoop", "stream": false}]},
|
||||
"weapon.fire.lockon": {"category": "player", "sounds": [{"name": "weapon/fire/lockon", "stream": false}]},
|
||||
|
||||
"weapon.reload.boltClose": {"category": "player", "sounds": ["weapon/reload/boltClose"]},
|
||||
"weapon.reload.boltOpen": {"category": "player", "sounds": ["weapon/reload/boltOpen"]},
|
||||
|
||||
BIN
src/main/resources/assets/hbm/sounds/weapon/fire/lockon.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/weapon/fire/lockon.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user