Skip to content

Commit

Permalink
Add variable block hit sounds playing ranged correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldSloth committed Jul 26, 2024
1 parent 0ef151a commit 04feeef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/flansmod/common/guns/BulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BulletType extends ShootableType
public EnumWeaponType weaponType = EnumWeaponType.NONE;

public String hitSound;
public float hitSoundRange;
public float hitSoundRange = 64;
public boolean hitSoundEnable = false;
public boolean entityHitSoundEnable = false;

Expand Down
26 changes: 18 additions & 8 deletions src/main/java/com/flansmod/common/guns/EntityBullet.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ else if (motionZ != 0)
}

if (type.hitSoundEnable)
PacketPlaySound.sendSoundPacket(posX, posY, posZ, type.hitSoundRange, dimension, type.hitSound, true);


//If the bullet breaks glass, and can do so according to FlansMod, do so.
if (type.breaksGlass && mat == Material.glass) {
Expand All @@ -756,19 +756,29 @@ else if (motionZ != 0)
}
}
if (type.hitSoundEnable) {
if (block.equals(Blocks.brick_block)) {
worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_bricks").toString(), 0.5F, 1);
String hitToUse = null;
if (type.hitSound != null) {
hitToUse = type.hitSound;
} else if (block.equals(Blocks.brick_block)) {
hitToUse = "impact_bricks";
//worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_bricks").toString(), 0.5F, 1);
} else if (mat == Material.ground || mat == Material.grass || mat == Material.sand || mat == Material.clay || mat == Material.tnt) {
worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_dirt").toString(), 0.5F, 1);
hitToUse = "impact_dirt";
//worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_dirt").toString(), 0.5F, 1);
} else if (mat == Material.glass || mat == Material.redstoneLight || mat == Material.ice || mat == Material.packedIce) {
worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_glass").toString(), 0.5F, 1);
hitToUse = "impact_glass";
//worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_glass").toString(), 0.5F, 1);
} else if (mat == Material.iron || mat == Material.anvil) {
worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_metal").toString(), 0.5F, 1);
hitToUse = "impact_metal";
//worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_metal").toString(), 0.5F, 1);
} else if (mat == Material.rock) {
worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_rock").toString(), 0.5F, 1);
hitToUse = "impact_rock";
//worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_rock").toString(), 0.5F, 1);
} else if (mat == Material.wood) {
worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_wood").toString(), 0.5F, 1);
hitToUse = "impact_wood";
//worldObj.playSoundEffect(posX, posY, posZ, FlansModResourceHandler.getSound("impact_wood").toString(), 0.5F, 1);
}
PacketPlaySound.sendSoundPacket(posX, posY, posZ, type.hitSoundRange, dimension, hitToUse, true);
}


Expand Down

0 comments on commit 04feeef

Please sign in to comment.