Skip to content

Commit

Permalink
Add Gauntlet medals and feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemaniak committed Apr 28, 2024
1 parent ca4c4d3 commit f0297a9
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private record Medal(MedalType type, int count, int ch) {}
private static final long FRAG_TIME_THRESHOLD = MiscUtils.toTicks(2);
private long killTick = 0;
private int killCount = 0;
private int gauntletKills = 0;

public boolean lastHitRailgun = false;
private int railHitCount = 0;
Expand All @@ -47,6 +48,10 @@ public void pushEvent(Event ev, boolean arg) {
killCount++;
medals.add(new Medal(MedalType.EXCELLENT, killCount, '\uFFFA'));
}
if (arg) {
gauntletKills++;
medals.add(new Medal(MedalType.GAUNTLET, gauntletKills, '\uFFFC'));
}
}
case WEAPON_HIT -> {
if (lastHitRailgun && arg) {
Expand Down Expand Up @@ -79,8 +84,7 @@ public void onHudRender(MatrixStack matrixStack, float tickDelta) {
switch (currentMedal.type) {
case EXCELLENT -> SoundUtils.playSoundLocally(Sounds.EXCELLENT);
case IMPRESSIVE -> SoundUtils.playSoundLocally(Sounds.IMPRESSIVE);
case GAUNTLET -> {
}
case GAUNTLET -> SoundUtils.playSoundLocally(Sounds.GAUNTLET);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
public class FeedbackSender implements ServerLivingEntityEvents.AllowDamage, ServerEntityCombatEvents.AfterKilledOtherEntity {
@Override
public void afterKilledOtherEntity(ServerWorld world, Entity entity, LivingEntity killedEntity) {
if (entity instanceof PlayerEntity && killedEntity instanceof PlayerEntity)
ServerPlayNetworking.send((ServerPlayerEntity) entity, Packets.KILLED_PLAYER, PacketByteBufs.empty());
if (entity instanceof PlayerEntity && killedEntity instanceof PlayerEntity) {
boolean gauntletKill = false;
if (killedEntity.getRecentDamageSource() != null)
gauntletKill = killedEntity.getRecentDamageSource().isOf(Q3DamageSources.GAUNTLET_DAMAGE);

PacketByteBuf buf = PacketByteBufs.create();
buf.writeBoolean(gauntletKill);
ServerPlayNetworking.send((ServerPlayerEntity) entity, Packets.KILLED_PLAYER, buf);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

public class KilledPlayerS2CPacket {
public static void receive(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender sender) {
Renderers.feedbacks.pushEvent(FeedbackManager.Event.PLAYER_KILL, false);
Renderers.feedbacks.pushEvent(FeedbackManager.Event.PLAYER_KILL, buf.readBoolean());
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/bytemaniak/mcquake3/registry/Sounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Sounds {
public static final SoundEvent EXCELLENT = SoundEvent.of(EXCELLENT_IDENT);
private static final Identifier IMPRESSIVE_IDENT = new Identifier("mcquake3:impressive");
public static final SoundEvent IMPRESSIVE = SoundEvent.of(IMPRESSIVE_IDENT);
private static final Identifier GAUNTLET_IDENT = new Identifier("mcquake3:gauntlet");
public static final SoundEvent GAUNTLET = SoundEvent.of(GAUNTLET_IDENT);

private static final Identifier MACHINEGUN_FIRE_IDENT = new Identifier("mcquake3:machinegun");
public static final SoundEvent MACHINEGUN_FIRE = SoundEvent.of(MACHINEGUN_FIRE_IDENT);
Expand Down Expand Up @@ -172,6 +174,7 @@ public static void loadSounds()
Registry.register(Registries.SOUND_EVENT, DAMAGE_DEALT_IDENT, DAMAGE_DEALT);
Registry.register(Registries.SOUND_EVENT, EXCELLENT_IDENT, EXCELLENT);
Registry.register(Registries.SOUND_EVENT, IMPRESSIVE_IDENT, IMPRESSIVE);
Registry.register(Registries.SOUND_EVENT, GAUNTLET_IDENT, GAUNTLET);
Registry.register(Registries.SOUND_EVENT, MACHINEGUN_FIRE_IDENT, MACHINEGUN_FIRE);
Registry.register(Registries.SOUND_EVENT, PLASMAGUN_FIRE_IDENT, PLASMAGUN_FIRE);
Registry.register(Registries.SOUND_EVENT, LIGHTNING_FIRE_IDENT, LIGHTNING_FIRE);
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/assets/mcquake3/font/quake_hud.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@
"chars": [
"\uFFFB"
]
},
{
"type": "bitmap",
"file": "mcquake3:font/gauntlet.png",
"ascent": -16,
"height": 32,
"chars": [
"\uFFFC"
]
}
]
}
5 changes: 5 additions & 0 deletions src/main/resources/assets/mcquake3/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"mcquake3:impressive"
]
},
"gauntlet": {
"sounds": [
"mcquake3:gauntlet"
]
},

"gauntlet_idle": {
"sounds": [
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f0297a9

Please sign in to comment.