Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b8942a2
premier test RealisticSound
Charpyy Dec 2, 2024
5db987a
Update MWC.java
Charpyy Dec 3, 2024
76fa5c7
Update WeaponFireAspect.java
Charpyy Dec 3, 2024
f8601f5
Update RealisticSoundHandler.java
Charpyy Dec 3, 2024
f61b4e0
Update TypeRegistry.java
Charpyy Dec 3, 2024
094e896
Merge branch 'Cubed-Development:next' into next
Charpyy Dec 4, 2024
98c8d38
Update MWC.java
Charpyy Dec 4, 2024
7e4de1d
Merge branch 'next' of https://github.com/Charpyy/Modern-Warfare-Cubeโ€ฆ
Charpyy Dec 4, 2024
b9a507a
Update RealisticSoundClientHandler.java
Charpyy Dec 4, 2024
72d3aa7
Update RealisticSoundHandler.java
Charpyy Dec 4, 2024
b3eac1b
Update RealisticSoundClientMessage.java
Charpyy Dec 4, 2024
42e3f20
Update RealisticSoundMessage.java
Charpyy Dec 4, 2024
e950e25
Update RealisticSound.java
Charpyy Dec 4, 2024
904d277
Update WeaponFireAspect.java
Charpyy Dec 4, 2024
1b5994b
Update RealisticSoundClientHandler.java
Charpyy Dec 6, 2024
1a4ce5e
Update WeaponFireAspect.java
Charpyy Dec 6, 2024
4cafc53
Update RealisticSound.java
Charpyy Dec 6, 2024
1dd2c45
Update RealisticSoundHandler.java
Charpyy Dec 6, 2024
4d38923
Update TypeRegistry.java
Charpyy Dec 6, 2024
a5803bb
Create ClientSoundPlayer.java
Charpyy Dec 6, 2024
a0babf9
Update RealisticSoundClientHandler.java
Charpyy Dec 6, 2024
84cd5e9
Update RealisticSoundHandler.java
Charpyy Dec 7, 2024
c41ee0c
Update MWC.java
Charpyy Dec 7, 2024
e427716
Update src/main/java/com/paneedah/mwc/network/handlers/RealisticSoundโ€ฆ
Desoroxxx Dec 17, 2024
bb5fa53
Update build.gradle.kts
Desoroxxx Dec 17, 2024
c8842f0
Update src/main/java/com/paneedah/weaponlib/sound/RealisticSound.java
Desoroxxx Dec 17, 2024
46a925b
Update src/main/java/com/paneedah/weaponlib/sound/RealisticSound.java
Desoroxxx Dec 17, 2024
3c905e5
Apply suggestions from code review
Desoroxxx Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/paneedah/mwc/MWC.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
import com.paneedah.weaponlib.command.CraftingFileCommand;
import com.paneedah.weaponlib.command.DebugCommand;
import com.paneedah.weaponlib.config.BalancePackManager;
import com.paneedah.weaponlib.config.ModernConfigManager;
import io.redstudioragnarok.redcore.RedCore;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
Expand Down Expand Up @@ -125,6 +123,7 @@ public void init(FMLInitializationEvent initializationEvent) {
CHANNEL.registerMessage(new VehicleClientMessageHandler(), VehicleClientMessage.class, -13, Side.CLIENT);
CHANNEL.registerMessage(new EntityInventorySyncMessageClientHandler(modContext), EntityInventorySyncMessage.class, -14, Side.CLIENT);
CHANNEL.registerMessage(new ExposureMessageHandler(), ExposureMessage.class, -15, Side.CLIENT);
CHANNEL.registerMessage(new RealisticSoundClientHandler(), RealisticSoundClientMessage.class, -16, Side.CLIENT);

CHANNEL.registerMessage(new TryFireMessageHandler(modContext.getWeaponFireAspect()), TryFireMessage.class, 1, Side.SERVER);
CHANNEL.registerMessage(new PermitMessageServerHandler((CommonModContext) modContext), PermitMessage.class, 2, Side.SERVER);
Expand All @@ -139,6 +138,7 @@ public void init(FMLInitializationEvent initializationEvent) {
CHANNEL.registerMessage(new WorkbenchServerMessageHandler(), WorkbenchServerMessage.class, 11, Side.SERVER);
CHANNEL.registerMessage(new CraftingServerMessageHandler(), CraftingServerMessage.class, 12, Side.SERVER);
CHANNEL.registerMessage(new EntityPickupMessageHandler(), EntityPickupMessage.class, 13, Side.SERVER);
CHANNEL.registerMessage(new RealisticSoundHandler(), RealisticSoundMessage.class, 14, Side.SERVER);
}

@Mod.EventHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.paneedah.mwc.network.handlers;

import com.paneedah.mwc.network.messages.RealisticSoundClientMessage;
import com.paneedah.weaponlib.sound.ClientSoundPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.util.SoundCategory;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class RealisticSoundClientHandler implements IMessageHandler<RealisticSoundClientMessage, IMessage> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be RealisticSoundClientMessageHandler, also should be final


@Override
public IMessage onMessage(final RealisticSoundClientMessage message, final MessageContext ctx) {
Minecraft.getMinecraft().addScheduledTask(() -> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NetworkUtil (See other place in the project it was used with ctrl + shift + f in IDEA and search NetworkUtil)

Minecraft minecraft = Minecraft.getMinecraft();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the constant MC with a static import (See other place in the project it was used with ctrl + shift + f in IDEA and search MC)

if (minecraft.world != null) {
ClientSoundPlayer csp = new ClientSoundPlayer();
csp.PlaySoundClient(message.getDistance(), message.getSound(), SoundCategory.PLAYERS, message.getVolume(), message.getPitch(), (float)message.getPos().getX(), (float)message.getPos().getY(), (float)message.getPos().getZ());
Comment on lines +18 to +19
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case using a local variable is useless as you aren't using it twice, simply do new ClientSoundPlayer.PlaySoundClient.

Although for better performance get rid of ClientSoundPlayer and simply put the code here since it's the only usage

}
Comment thread
Desoroxxx marked this conversation as resolved.
});

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.paneedah.mwc.network.handlers;

import com.paneedah.mwc.network.messages.RealisticSoundClientMessage;
import com.paneedah.mwc.network.messages.RealisticSoundMessage;
import com.paneedah.weaponlib.sound.RealisticSound;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

import java.util.Objects;

import static com.paneedah.mwc.MWC.CHANNEL;

public class RealisticSoundHandler implements IMessageHandler<RealisticSoundMessage, IMessage> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be RealisticSoundServerMessageHandler, also should be final


@Override
public IMessage onMessage(final RealisticSoundMessage message, final MessageContext ctx) {
ctx.getServerHandler().player.getServerWorld().addScheduledTask(() -> {
Comment thread
strubium marked this conversation as resolved.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NetworkUtil (See other place in the project it was used with ctrl + shift + f in IDEA and search NetworkUtil)

final EntityPlayer player = ctx.getServerHandler().player;
final World world = player.getEntityWorld();
for (EntityPlayer playerInWorld : world.playerEntities) {
final double distance = Math.sqrt(message.getPos().distanceSq(playerInWorld.getPosition()));
final RealisticSound sound = RealisticSound.createSound(message.getSilencer(), message.getSound(), message.getPos(), playerInWorld.getPosition());
if (sound.getVolumeIn() > 0) {
if (playerInWorld instanceof EntityPlayerMP) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an early return

EntityPlayerMP playerMP = (EntityPlayerMP) playerInWorld;

This comment was marked as off-topic.

playerMP.getServerWorld().addScheduledTask(() -> {
CHANNEL.sendTo(new RealisticSoundClientMessage(sound.getSound(), message.getPos(), sound.getVolumeIn(), sound.getPitchIn(), distance), playerMP);
});
}
}
}
});

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.paneedah.mwc.network.messages;

import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;


@Getter
@NoArgsConstructor
@AllArgsConstructor
public final class RealisticSoundClientMessage implements IMessage {

private float volume;
private float pitch;

private double distance;

private SoundEvent sound;
private BlockPos pos;

@Override
public void fromBytes(final ByteBuf buf) {
int length = buf.readInt();
byte[] soundBytes = new byte[length];
buf.readBytes(soundBytes);
String soundName = new String(soundBytes);
sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(soundName));
Comment on lines +28 to +32
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sound event ID instead SoundEvent.REGISTRY.getObjectById() SoundEvent.REGISTRY.getIDForObject()


final int x = buf.readInt();
final int y = buf.readInt();
final int z = buf.readInt();
pos = new BlockPos(x, y, z);

volume = buf.readFloat();
pitch = buf.readFloat();
distance = buf.readDouble();
}

@Override
public void toBytes(ByteBuf buf) {
String soundName = sound.getRegistryName().toString();
byte[] soundBytes = soundName.getBytes();
buf.writeInt(soundBytes.length);
buf.writeBytes(soundBytes);
Comment on lines +46 to +49
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sound event ID instead SoundEvent.REGISTRY.getObjectById() SoundEvent.REGISTRY.getIDForObject()


buf.writeInt(pos.getX());
buf.writeInt(pos.getY());
buf.writeInt(pos.getZ());

buf.writeFloat(volume);
buf.writeFloat(pitch);
buf.writeDouble(distance);
}
Comment thread
Desoroxxx marked this conversation as resolved.

public SoundEvent getSound() {return this.sound;}
public BlockPos getPos() { return this.pos;}
public float getVolume() {return this.volume;}
public float getPitch() {return this.pitch;}
public double getDistance() {return this.distance;}
Comment thread
Desoroxxx marked this conversation as resolved.
Comment on lines +60 to +64
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless because of the @Getter install the IntelliJ plugin Lombok to know that and be able to use it correctly

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.paneedah.mwc.network.messages;

import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public final class RealisticSoundMessage implements IMessage {
private boolean silencer;

private int dimensionId;

private SoundEvent sound;
private BlockPos pos;

@Override
public void fromBytes(final ByteBuf buf) {
int length = buf.readInt();
byte[] soundBytes = new byte[length];
buf.readBytes(soundBytes);
String soundName = new String(soundBytes);
sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(soundName));
Comment thread
Desoroxxx marked this conversation as resolved.
Comment on lines +25 to +29
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sound event ID instead SoundEvent.REGISTRY.getObjectById() SoundEvent.REGISTRY.getIDForObject()

final int x = buf.readInt();
final int y = buf.readInt();
final int z = buf.readInt();
pos = new BlockPos(x, y, z);

dimensionId = buf.readInt();
silencer = buf.readBoolean();
}

@Override
public void toBytes(final ByteBuf buf) {
String soundName = sound.getRegistryName().toString();
byte[] soundBytes = soundName.getBytes();
Comment thread
Desoroxxx marked this conversation as resolved.
buf.writeInt(soundBytes.length);
buf.writeBytes(soundBytes);
Comment on lines +41 to +44
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sound event ID instead SoundEvent.REGISTRY.getObjectById() SoundEvent.REGISTRY.getIDForObject()


buf.writeInt(pos.getX());
buf.writeInt(pos.getY());
buf.writeInt(pos.getZ());
Comment thread
Desoroxxx marked this conversation as resolved.

buf.writeInt(dimensionId);
buf.writeBoolean(silencer);
}
public SoundEvent getSound() {return this.sound;}
public BlockPos getPos() { return this.pos;}
public int getWorldId() {return this.dimensionId;}
public boolean getSilencer() {return this.silencer;}
Comment on lines +53 to +56
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless because of the @Getter install the IntelliJ plugin Lombok to know that and be able to use it correctly

}
36 changes: 17 additions & 19 deletions src/main/java/com/paneedah/weaponlib/WeaponFireAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.paneedah.mwc.instancing.Tags;
import com.paneedah.mwc.network.NetworkPermitManager;
import com.paneedah.mwc.network.messages.MuzzleFlashMessage;
import com.paneedah.mwc.network.messages.RealisticSoundMessage;
import com.paneedah.mwc.network.messages.ShellMessageClient;
import com.paneedah.mwc.network.messages.TryFireMessage;
import com.paneedah.weaponlib.animation.ClientValueRepo;
Expand Down Expand Up @@ -285,11 +286,7 @@ private void fire(PlayerWeaponInstance weaponInstance) {
// Should prevent sound from being one sided

if (!FMLCommonHandler.instance().getSide().isServer()) {

//
PositionedSoundRecord psr = new PositionedSoundRecord(shootSound, SoundCategory.PLAYERS, silencerOn ? weapon.getSilencedShootSoundVolume() * 0.4f : weapon.getShootSoundVolume() * 0.4f, 1.0F, MC.player.getPosition().up(5));
playShootSound(psr);
//MC.getSoundHandler().playSound(psr);
CHANNEL.sendToServer(new RealisticSoundMessage(silencerOn, shootSound, player.getPosition(), player.getEntityWorld().getWorldType().getId()));
}


Expand All @@ -301,11 +298,12 @@ private void fire(PlayerWeaponInstance weaponInstance) {

int currentAmmo = weaponInstance.getAmmo();
if (currentAmmo == 1 && weapon.getEndOfShootSound() != null && !FMLCommonHandler.instance().getSide().isServer()) {
PositionedSoundRecord psr = new PositionedSoundRecord(weapon.getEndOfShootSound(), SoundCategory.PLAYERS, 1.0F, 1.0F, MC.player.getPosition().up(5));
playShootSound(psr);
CHANNEL.sendToServer(new RealisticSoundMessage(silencerOn,weapon.getEndOfShootSound(), player.getPosition(), player.getEntityWorld().getWorldType().getId()));
// PositionedSoundRecord psr = new PositionedSoundRecord(weapon.getEndOfShootSound(), SoundCategory.PLAYERS, 1.0F, 1.0F, MC.player.getPosition().up(5));
// playShootSound(psr);
//MC.getSoundHandler().playSound(psr);
}
Comment thread
Desoroxxx marked this conversation as resolved.

if (currentAmmo == 1) {
weaponInstance.setSlideLock(true);
}
Expand Down Expand Up @@ -353,22 +351,22 @@ private void fire(PlayerWeaponInstance weaponInstance) {
ClientEventHandler.SHELL_MANAGER.enqueueShell(shell);

//Shell

/*
// Change the raw position
Vec3d rawPosition = new Vec3d(ClientEventHandler.NEW_POS.get(0), ClientEventHandler.NEW_POS.get(1), ClientEventHandler.NEW_POS.get(2));


// Calculate the final position of the bullet spawn point
// by changing it's position along its own vector
double distance = 0.5;
Vec3d eyePos = MC.player.getPositionEyes(1.0f);
Vec3d finalPosition = rawPosition.subtract(eyePos).normalize().scale(distance).add(eyePos);

// Calculate velocity as 90 degrees to player
Vec3d velocity = new Vec3d(-0.3, 0.1, 0.0);
velocity = velocity.rotateYaw((float) Math.toRadians(-MC.player.rotationYaw));

// Spawn in shell
Shell shell = new Shell(weaponInstance.getWeapon().getShellType(), new Vec3d(finalPosition.x, finalPosition.y, finalPosition.z), new Vec3d(90, 0, 90), velocity);
ClientEventHandler.shellManager.enqueueShell(shell);
Expand All @@ -393,7 +391,7 @@ private void ejectSpentRound(PlayerWeaponInstance weaponInstance) {
player.playSound(weaponInstance.getWeapon().getEjectSpentRoundSound(), 1, 1);
}

//(weapon, player)
//(weapon, player)
public void serverFire(EntityLivingBase player, boolean isBurst, boolean isAimed) {
serverFire(player, player.getHeldItemMainhand(), null, isBurst, isAimed, 1.0f);
}
Expand Down Expand Up @@ -423,7 +421,7 @@ public void serverFire(EntityLivingBase player, ItemStack itemStack, BiFunction<
}

//System.out.println(isAimed);

/*
int itemIndex = 0;
EntityPlayer realPlayer = (EntityPlayer) player;
Expand All @@ -432,9 +430,9 @@ public void serverFire(EntityLivingBase player, ItemStack itemStack, BiFunction<
itemIndex = i;
}
}



PlayerWeaponInstance pwi = new PlayerWeaponInstance(itemIndex, player, itemStack);
System.out.println(pwi.isAimed());
*/
Expand Down Expand Up @@ -509,4 +507,4 @@ public void serverFire(EntityLivingBase player, ItemStack itemStack, BiFunction<

}

}
}
25 changes: 25 additions & 0 deletions src/main/java/com/paneedah/weaponlib/sound/ClientSoundPlayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.paneedah.weaponlib.sound;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public final class ClientSoundPlayer {

@SideOnly(Side.CLIENT)
public void PlaySoundClient(double distance, SoundEvent soundIn, SoundCategory categoryIn, float volumeIn, float pitchIn, float xIn, float yIn, float zIn) {
Comment on lines +13 to +14
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be camelCase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final, too much to do in GitHub

Minecraft mc = Minecraft.getMinecraft();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the constant MC with a static import (See other place in the project it was used with ctrl + shift + f in IDEA and search MC)

PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord(soundIn.getSoundName(), categoryIn, volumeIn, pitchIn, false, 0, ISound.AttenuationType.NONE, xIn,yIn, zIn);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

if (distance > 100.0D)
{
final double d1 = Math.sqrt(distance) / 40D;
mc.getSoundHandler().playDelayedSound(positionedsoundrecord, (int)(d1 * 20.0D));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double mathed, you first diveded it by 40 and then multiplied by 20, justice for poor CPU

} else {
mc.getSoundHandler().playSound(positionedsoundrecord);
}
}
}
51 changes: 51 additions & 0 deletions src/main/java/com/paneedah/weaponlib/sound/RealisticSound.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.paneedah.weaponlib.sound;

import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;

public final class RealisticSound {

private static final double MAX_DISTANCE = 400D;
private static final double MAX_DISTANCE_SILENCER = 100D;

private final float volumeIn;
private final float pitchIn;

private final SoundEvent sound;

public RealisticSound(SoundEvent sound, float volumeIn, float pitchIn) {
this.sound = sound;
this.volumeIn = volumeIn;
this.pitchIn = pitchIn;
}
Comment on lines +17 to +21
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an @AllArgsConstructor instead


public static RealisticSound createSound(Boolean silencer, SoundEvent soundIn, BlockPos origin, BlockPos playercoord) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final (too much for github)

double distance = Math.sqrt(playercoord.distanceSq(origin));
float volume = (float) adjustVolumeForDistance(silencer, distance);
return new RealisticSound(soundIn, volume, 1.0F);
Comment on lines +24 to +26
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variables are unecessary here

}

public static double adjustVolumeForDistance(final boolean silencer, final double distance) {
final double maxDistance = silencer ? MAX_DISTANCE_SILENCER : MAX_DISTANCE;
if (distance >= maxDistance)
return 0;

if (distance <= 0)
return 1;

return 1 - (distance / maxDistance);
}

public SoundEvent getSound() {
return sound;
}

public float getVolumeIn() {
return volumeIn;
}

public float getPitchIn() {
return pitchIn;
}
Comment on lines +40 to +50
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @Getter on these fields

}