mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Improvements to fix for #15; smooth out sounds and detect ongoing attempts to muffle
The previous commit made the assumption that detection of sound being complete was fast enough that restarting a well-designed sound would be seamless -- this is not true. As such, had to change sounds to run for as long as machine is active on repeat with ongoing detection of muffling attempts. In addition, if sound was INITIALLY muffled, it would never have been unmuffled, so this also fixes that problem.
This commit is contained in:
1 parent
c78ae6dd1d
commit
f675590372
18 files changed
+332
-86
No files matched your search
@@ -40,33 +40,30 @@ public class PlayerState {
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private boolean isLocalPlayer(String playerId) {
|
||||
return Minecraft.getMinecraft().player.getName().equals(playerId);
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
//
|
||||
// Jetpack state tracking
|
||||
//
|
||||
// ----------------------
|
||||
|
||||
public void setJetpackState(String playerId, boolean isActive) {
|
||||
public void setJetpackState(String playerId, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeJetpacks.contains(playerId);
|
||||
boolean changed = (alreadyActive != isActive);
|
||||
|
||||
if (alreadyActive && !isActive) {
|
||||
// On -> off
|
||||
Mekanism.logger.info("{} jetpack is now off", playerId);
|
||||
activeJetpacks.remove(playerId);
|
||||
} else if (!alreadyActive && isActive) {
|
||||
// Off -> on
|
||||
Mekanism.logger.info("{} jetpack is now on", playerId);
|
||||
activeJetpacks.add(playerId);
|
||||
}
|
||||
|
||||
// If something changed and we're in a remote world, take appropriate action
|
||||
if (changed && world.isRemote) {
|
||||
// If the player is the "local" player, we need to tell the server the state has changed
|
||||
if (isLocalPlayer(playerId)) {
|
||||
if (isLocal) {
|
||||
Mekanism.packetHandler.sendToServer(PacketJetpackData.JetpackDataMessage.UPDATE(playerId, isActive));
|
||||
}
|
||||
|
||||
@@ -79,7 +76,7 @@ public class PlayerState {
|
||||
|
||||
public void setActiveJetpacks(Set<String> newActiveJetpacks) {
|
||||
for (String activeUser: newActiveJetpacks) {
|
||||
setJetpackState(activeUser, true);
|
||||
setJetpackState(activeUser, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +94,7 @@ public class PlayerState {
|
||||
//
|
||||
// ----------------------
|
||||
|
||||
public void setGasmaskState(String playerId, boolean isActive) {
|
||||
public void setGasmaskState(String playerId, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeGasmasks.contains(playerId);
|
||||
boolean changed = (alreadyActive != isActive);
|
||||
|
||||
@@ -110,7 +107,7 @@ public class PlayerState {
|
||||
// If something changed and we're in a remote world, take appropriate action
|
||||
if (changed && world.isRemote) {
|
||||
// If the player is the "local" player, we need to tell the server the state has changed
|
||||
if (isLocalPlayer(playerId)) {
|
||||
if (isLocal) {
|
||||
Mekanism.packetHandler.sendToServer(PacketScubaTankData.ScubaTankDataMessage.UPDATE(playerId, isActive));
|
||||
}
|
||||
|
||||
@@ -123,7 +120,7 @@ public class PlayerState {
|
||||
|
||||
public void setActiveGasmasks(Set<String> newActiveGasmasks) {
|
||||
for (String activeUser: newActiveGasmasks) {
|
||||
setGasmaskState(activeUser, true);
|
||||
setGasmaskState(activeUser, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +138,7 @@ public class PlayerState {
|
||||
//
|
||||
// ----------------------
|
||||
|
||||
public void setFlamethrowerState(String playerId, boolean isActive) {
|
||||
public void setFlamethrowerState(String playerId, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeFlamethrowers.contains(playerId);
|
||||
boolean changed = (alreadyActive != isActive);
|
||||
|
||||
@@ -154,7 +151,7 @@ public class PlayerState {
|
||||
// If something changed and we're in a remote world, take appropriate action
|
||||
if (changed && world.isRemote) {
|
||||
// If the player is the "local" player, we need to tell the server the state has changed
|
||||
if (isLocalPlayer(playerId)) {
|
||||
if (isLocal) {
|
||||
Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(FlamethrowerPacket.UPDATE, null,
|
||||
playerId, isActive));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user