Becoming android sound
This commit is contained in:
parent
f016e10dd2
commit
99340baf30
@ -2,15 +2,17 @@ package ru.dbotthepony.mc.otm.network.android;
|
|||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
||||||
import ru.dbotthepony.mc.otm.capability.android.AndroidCapabilityPlayer;
|
import ru.dbotthepony.mc.otm.capability.android.AndroidCapabilityPlayer;
|
||||||
|
import ru.dbotthepony.mc.otm.registry.MSoundEvents;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public record AndroidStatusPacket(Type type, boolean status) {
|
public record AndroidStatusPacket(Type type, boolean status, boolean playSound) {
|
||||||
public enum Type {
|
public enum Type {
|
||||||
IS_ANDROID,
|
IS_ANDROID,
|
||||||
WILL_BECOME_ANDROID,
|
WILL_BECOME_ANDROID,
|
||||||
@ -19,6 +21,7 @@ public record AndroidStatusPacket(Type type, boolean status) {
|
|||||||
public void write(FriendlyByteBuf buffer) {
|
public void write(FriendlyByteBuf buffer) {
|
||||||
buffer.writeByte(type.ordinal());
|
buffer.writeByte(type.ordinal());
|
||||||
buffer.writeBoolean(status);
|
buffer.writeBoolean(status);
|
||||||
|
buffer.writeBoolean(playSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play(Supplier<NetworkEvent.Context> context) {
|
public void play(Supplier<NetworkEvent.Context> context) {
|
||||||
@ -39,11 +42,15 @@ public record AndroidStatusPacket(Type type, boolean status) {
|
|||||||
else if (type == Type.WILL_BECOME_ANDROID)
|
else if (type == Type.WILL_BECOME_ANDROID)
|
||||||
pcap.willBecomeAndroid = status;
|
pcap.willBecomeAndroid = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playSound) {
|
||||||
|
ply.level.playSound(ply, ply, MSoundEvents.INSTANCE.getPLAYER_BECOME_ANDROID(), SoundSource.PLAYERS, 1f, 1f);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AndroidStatusPacket read(FriendlyByteBuf buffer) {
|
public static AndroidStatusPacket read(FriendlyByteBuf buffer) {
|
||||||
return new AndroidStatusPacket(Type.values()[buffer.readByte()], buffer.readBoolean());
|
return new AndroidStatusPacket(Type.values()[buffer.readByte()], buffer.readBoolean(), buffer.readBoolean());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class AndroidCapabilityPlayer(@JvmField val ply: Player) : AndroidCapability(ply
|
|||||||
@JvmField
|
@JvmField
|
||||||
var willBecomeAndroid = false
|
var willBecomeAndroid = false
|
||||||
private var willBecomeAndroidNetwork = false
|
private var willBecomeAndroidNetwork = false
|
||||||
|
private var shouldPlaySound = false
|
||||||
private val research = ArrayList<AndroidResearch>()
|
private val research = ArrayList<AndroidResearch>()
|
||||||
|
|
||||||
override fun invalidateNetworkState() {
|
override fun invalidateNetworkState() {
|
||||||
@ -60,6 +61,7 @@ class AndroidCapabilityPlayer(@JvmField val ply: Player) : AndroidCapability(ply
|
|||||||
|
|
||||||
isAndroid = true
|
isAndroid = true
|
||||||
willBecomeAndroid = false
|
willBecomeAndroid = false
|
||||||
|
shouldPlaySound = false
|
||||||
battery = ImpreciseFraction(60000)
|
battery = ImpreciseFraction(60000)
|
||||||
maxBattery = ImpreciseFraction(60000)
|
maxBattery = ImpreciseFraction(60000)
|
||||||
}
|
}
|
||||||
@ -76,6 +78,7 @@ class AndroidCapabilityPlayer(@JvmField val ply: Player) : AndroidCapability(ply
|
|||||||
if (!isAndroid) return
|
if (!isAndroid) return
|
||||||
|
|
||||||
isAndroid = false
|
isAndroid = false
|
||||||
|
shouldPlaySound = false
|
||||||
battery = ImpreciseFraction(0)
|
battery = ImpreciseFraction(0)
|
||||||
maxBattery = ImpreciseFraction(60000)
|
maxBattery = ImpreciseFraction(60000)
|
||||||
dropBattery()
|
dropBattery()
|
||||||
@ -167,12 +170,13 @@ class AndroidCapabilityPlayer(@JvmField val ply: Player) : AndroidCapability(ply
|
|||||||
super.tickNetwork()
|
super.tickNetwork()
|
||||||
if (isAndroid != isAndroidNetwork) {
|
if (isAndroid != isAndroidNetwork) {
|
||||||
isAndroidNetwork = isAndroid
|
isAndroidNetwork = isAndroid
|
||||||
sendNetwork(AndroidStatusPacket(AndroidStatusPacket.Type.IS_ANDROID, isAndroid))
|
sendNetwork(AndroidStatusPacket(AndroidStatusPacket.Type.IS_ANDROID, isAndroid, shouldPlaySound))
|
||||||
|
shouldPlaySound = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (willBecomeAndroid != willBecomeAndroidNetwork) {
|
if (willBecomeAndroid != willBecomeAndroidNetwork) {
|
||||||
willBecomeAndroidNetwork = willBecomeAndroid
|
willBecomeAndroidNetwork = willBecomeAndroid
|
||||||
sendNetwork(AndroidStatusPacket(AndroidStatusPacket.Type.WILL_BECOME_ANDROID, willBecomeAndroid))
|
sendNetwork(AndroidStatusPacket(AndroidStatusPacket.Type.WILL_BECOME_ANDROID, willBecomeAndroid, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (instance in research) {
|
for (instance in research) {
|
||||||
@ -207,6 +211,7 @@ class AndroidCapabilityPlayer(@JvmField val ply: Player) : AndroidCapability(ply
|
|||||||
|
|
||||||
if (sleep_ticks > SLEEP_TICKS_LIMIT) {
|
if (sleep_ticks > SLEEP_TICKS_LIMIT) {
|
||||||
becomeAndroid()
|
becomeAndroid()
|
||||||
|
shouldPlaySound = true
|
||||||
sleep_ticks = 0
|
sleep_ticks = 0
|
||||||
|
|
||||||
(ply as? ServerPlayer)?.displayClientMessage(TranslatableComponent("otm.pill.message_finish").withStyle(ChatFormatting.DARK_RED), false)
|
(ply as? ServerPlayer)?.displayClientMessage(TranslatableComponent("otm.pill.message_finish").withStyle(ChatFormatting.DARK_RED), false)
|
||||||
|
@ -16,6 +16,7 @@ object MSoundEvents {
|
|||||||
|
|
||||||
val RIFLE_SHOT: SoundEvent by make("item.rifle_shot")
|
val RIFLE_SHOT: SoundEvent by make("item.rifle_shot")
|
||||||
val PLASMA_WEAPON_OVERHEAT: SoundEvent by make("item.plasma_weapon_overheat")
|
val PLASMA_WEAPON_OVERHEAT: SoundEvent by make("item.plasma_weapon_overheat")
|
||||||
|
val PLAYER_BECOME_ANDROID: SoundEvent by make("player_become_android")
|
||||||
|
|
||||||
internal fun register() {
|
internal fun register() {
|
||||||
registry.register(FMLJavaModLoadingContext.get().modEventBus)
|
registry.register(FMLJavaModLoadingContext.get().modEventBus)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"otm.sound.rifle_shoot": "Plasma rifle fires",
|
"otm.sound.rifle_shoot": "Plasma rifle fires",
|
||||||
"otm.sound.plasma_weapon_overheat": "Plasma weapon overheats",
|
"otm.sound.plasma_weapon_overheat": "Plasma weapon overheats",
|
||||||
|
"otm.sound.player_become_android": "Player became android",
|
||||||
|
|
||||||
"itemGroup.otm": "Overdrive That Matters",
|
"itemGroup.otm": "Overdrive That Matters",
|
||||||
|
|
||||||
|
@ -10,6 +10,17 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"player_become_android": {
|
||||||
|
"subtitle": "otm.sound.player_become_android",
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "overdrive_that_matters:player_become_android",
|
||||||
|
"volume": 1.0,
|
||||||
|
"weight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
"item.plasma_weapon_overheat": {
|
"item.plasma_weapon_overheat": {
|
||||||
"subtitle": "otm.sound.plasma_weapon_overheat",
|
"subtitle": "otm.sound.plasma_weapon_overheat",
|
||||||
"sounds": [
|
"sounds": [
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user