merge and refactor new content

This commit is contained in:
George Paton 2024-10-24 15:28:33 +11:00
parent fcfb4e5341
commit 557913db64
5 changed files with 25 additions and 21 deletions

View File

@ -690,24 +690,24 @@ public class Orchestras {
};
public static BiConsumer<ItemStack, LambdaContext> ORCHESTRA_CHEMTHROWER = (stack, ctx) -> {
EntityPlayer player = ctx.player;
EntityLivingBase entity = ctx.entity;
AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex);
int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex);
if(type == AnimType.CYCLE && player.worldObj.isRemote) {
AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player);
if(type == AnimType.CYCLE && entity.worldObj.isRemote) {
AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity);
if(timer < 5) {
//start sound
if(runningAudio == null || !runningAudio.isPlaying()) {
AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) player.posX, (float) player.posY, (float) player.posZ, 1F, 15F, 1F, 10);
ItemGunBaseNT.loopedSounds.put(player, audio);
AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) entity.posX, (float) entity.posY, (float) entity.posZ, 1F, 15F, 1F, 10);
ItemGunBaseNT.loopedSounds.put(entity, audio);
audio.startSound();
}
//keepalive
if(runningAudio != null && runningAudio.isPlaying()) {
runningAudio.keepAlive();
runningAudio.updatePosition((float) player.posX, (float) player.posY, (float) player.posZ);
runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ);
}
} else {
//stop sound due to timeout
@ -715,15 +715,15 @@ public class Orchestras {
}
}
//stop sound due to state change
if(type != AnimType.CYCLE && player.worldObj.isRemote) {
AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player);
if(type != AnimType.CYCLE && entity.worldObj.isRemote) {
AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity);
if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound();
}
};
public static BiConsumer<ItemStack, LambdaContext> ORCHESTRA_M2 = (stack, ctx) -> {
EntityPlayer player = ctx.player;
if(player.worldObj.isRemote) return;
EntityLivingBase entity = ctx.entity;
if(entity.worldObj.isRemote) return;
AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex);
int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex);
boolean aiming = ItemGunBaseNT.getIsAiming(stack);
@ -731,14 +731,14 @@ public class Orchestras {
if(type == AnimType.CYCLE) {
if(timer == 0) {
SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack);
if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.3125D, 0, 0.06, -0.18, 0.01, casing.getName());
if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.3125D, 0, 0.06, -0.18, 0.01, casing.getName());
}
}
};
public static BiConsumer<ItemStack, LambdaContext> ORCHESTRA_SHREDDER = (stack, ctx) -> {
EntityPlayer player = ctx.player;
if(player.worldObj.isRemote) return;
EntityLivingBase entity = ctx.entity;
if(entity.worldObj.isRemote) return;
AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex);
int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex);
};

View File

@ -56,7 +56,7 @@ public class XFactory50 {
}
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_SMOKE = (stack, ctx) -> {
Lego.handleStandardSmoke(ctx.player, stack, 2000, 0.05D, 1.1D, 0);
Lego.handleStandardSmoke(ctx.entity, stack, 2000, 0.05D, 1.1D, 0);
};
@SuppressWarnings("incomplete-switch") public static BiFunction<ItemStack, AnimType, BusAnimation> LAMBDA_M2_ANIMS = (stack, type) -> {

View File

@ -14,6 +14,7 @@ import com.hbm.items.weapon.sedna.mags.MagazineFluid;
import com.hbm.render.anim.HbmAnimations.AnimType;
import api.hbm.fluid.IFillableItem;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
@ -77,7 +78,8 @@ public class ItemGunChemthrower extends ItemGunBaseNT implements IFillableItem {
public static BiFunction<ItemStack, LambdaContext, Boolean> LAMBDA_CAN_FIRE = (stack, ctx) -> { return ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmount(stack) >= CONSUMPTION; };
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_FIRE = (stack, ctx) -> {
EntityPlayer player = ctx.player;
EntityLivingBase entity = ctx.entity;
EntityPlayer player = ctx.getPlayer();
int index = ctx.configIndex;
ItemGunBaseNT.playAnimation(player, stack, AnimType.CYCLE, ctx.configIndex);
@ -89,9 +91,9 @@ public class ItemGunChemthrower extends ItemGunBaseNT implements IFillableItem {
double heightOffset = offset.yCoord;
double sideOffset = offset.zCoord;
EntityChemical chem = new EntityChemical(player.worldObj, player, sideOffset, heightOffset, forwardOffset);
EntityChemical chem = new EntityChemical(entity.worldObj, entity, sideOffset, heightOffset, forwardOffset);
chem.setFluid((FluidType) mag.getType(stack));
player.worldObj.spawnEntityInWorld(chem);
entity.worldObj.spawnEntityInWorld(chem);
mag.setAmount(stack, mag.getAmount(stack) - CONSUMPTION);
ItemGunBaseNT.setWear(stack, index, Math.min(ItemGunBaseNT.getWear(stack, index) + 1F, ctx.config.getDurability(stack)));

View File

@ -24,9 +24,9 @@ public interface IMagazine<T> {
/** Sets the mag's ammo level */
public void setAmount(ItemStack stack, int amount);
/** If a reload can even be initiated, i.e. the player even has bullets to load, inventory can be null */
public boolean canReload(ItemStack stack, IInventory player);
public boolean canReload(ItemStack stack, IInventory inventory);
/** The action done at the end of one reload cycle, either loading one shell or replacing the whole mag, inventory can be null */
public void reloadAction(ItemStack stack, IInventory player);
public void reloadAction(ItemStack stack, IInventory inventory);
/** The stack that should be displayed for the ammo HUD */
public ItemStack getIconForHUD(ItemStack stack);
/** It explains itself */

View File

@ -6,7 +6,9 @@ import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
import com.hbm.particle.SpentCasing;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class MagazineFluid implements IMagazine<FluidType> {
@ -45,8 +47,8 @@ public class MagazineFluid implements IMagazine<FluidType> {
@Override public int getAmount(ItemStack stack) { return getMagCount(stack, index); }
@Override public void setAmount(ItemStack stack, int amount) { setMagCount(stack, index, amount); }
@Override public boolean canReload(ItemStack stack, EntityPlayer player) { return false; }
@Override public void reloadAction(ItemStack stack, EntityPlayer player) { }
@Override public boolean canReload(ItemStack stack, IInventory inventory) { return false; }
@Override public void reloadAction(ItemStack stack, IInventory inventory) { }
@Override public SpentCasing getCasing(ItemStack stack) { return null; }
@Override public ItemStack getIconForHUD(ItemStack stack) { return new ItemStack(ModItems.fluid_icon, 1, this.getMagType(stack, index)); }