Skip to content

Commit ba2fb6c

Browse files
authored
Merge pull request #96 from LukeisStuff/8.0
fix client crash when you die, fix drowning string and add a death cause for acid
2 parents d9e75e8 + 6107252 commit ba2fb6c

7 files changed

Lines changed: 30 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- Make the client not crash instantly due to trying to load server classes.
1+
- Client no longer crashes when dying.
2+
- Fix drowning death cause lang and add acid death cause

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Follow the setup instructions on [the example mod](https://github.com/Turnip-Lab
1515
Update the ``/gradle/libs.versions.toml`` config file:
1616
```toml
1717
[versions]
18-
halplibe = "6.0.2"
18+
halplibe = "6.1.4+8.0"
1919

2020
[libraries]
2121
halplibe = { group = "turniplabs", name = "halplibe", version.ref = "halplibe" }

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ org.gradle.warning.mode = all
88
org.gradle.configuration-cache = false
99
##########################################################################
1010
# Mod Properties
11-
mod_version = 6.1.3
11+
mod_version = 6.1.4
1212
mod_group = turniplabs
1313
mod_name = halplibe
1414
##########################################################################

src/main/java/turniplabs/halplibe/helper/network/NetworkHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ public static void internalSendHandshakeAck(@NonNull PacketHandlerClient packetH
8686
/**
8787
* Whether the given Player's client confirmed it can decode the native UniversalPacket.
8888
*/
89-
@Environment(EnvType.SERVER)
9089
public static boolean canReceiveNativePackets(Player player) {
90+
if (EnvironmentHelper.isSingleplayerClient() || !EnvironmentHelper.isMultiplayerServer()) {
91+
return true;
92+
}
93+
9194
return player instanceof PlayerServer playerServer
9295
&& nativeReadyConnections.contains(playerServer.playerNetServerHandler);
9396
}

src/main/java/turniplabs/halplibe/mixin/deathcause/MobMixin.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public void hijackDeathMessage(
5353

5454
// the projectile death message only triggers if one or both of the entities is a player.
5555
if (entityKilledBy instanceof Projectile projectile) {
56-
if (thisAs instanceof Player) {
57-
this.deathCause = new DeathCauseProjectile((Player) thisAs, projectile);
56+
if (thisAs instanceof Player player) {
57+
this.deathCause = new DeathCauseProjectile(player, projectile);
5858
}
5959

6060
// so if a skeleton shoots down your dog, just mark it as a skelie.
@@ -68,6 +68,10 @@ else if (thisAs.isInLava()) {
6868
this.deathCause = new DeathCauseRegistry.DeathCauseLava(thisAs);
6969
}
7070

71+
else if (thisAs.isInAcid()) {
72+
this.deathCause = new DeathCauseRegistry.DeathCauseAcid(thisAs);
73+
}
74+
7175
else {
7276
TilePos tilePos = new TilePos(thisAs);
7377

src/main/java/turniplabs/halplibe/util/deathcause/DeathCause.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ public abstract class DeathCause {
3535
protected boolean isPlayer = false;
3636
protected EntityName victim = EntityName.empty();
3737

38-
public DeathCause() {};
38+
public DeathCause() {
39+
}
3940

4041
public DeathCause(Mob victim) {
4142
this.isPlayer = victim instanceof Player;
4243
this.victim = EntityName.fromEntity(victim);
43-
};
44+
}
4445

4546
public void serialize(CompoundTag tag) {
4647
var victimTag = new CompoundTag();

src/main/java/turniplabs/halplibe/util/deathcause/DeathCauseRegistry.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ public String getKeyForClass(Class<? extends DeathCause> clazz) {
4848
static {
4949
var inst = getInstance();
5050

51-
inst.register("halplibe:drown", DeathCauseDrown::new);
51+
inst.register("halplibe:drowned", DeathCauseDrown::new);
5252
inst.register("halplibe:fall", DeathCauseFall::new);
5353
inst.register("halplibe:fire", DeathCauseFire::new);
5454
inst.register("halplibe:generic", DeathCauseGeneric::new);
5555
inst.register("halplibe:killed_by", DeathCauseKilledBy::new);
5656
inst.register("halplibe:projectile", DeathCauseProjectile::new);
5757
inst.register("halplibe:lava", DeathCauseLava::new);
58+
inst.register("halplibe:acid", DeathCauseAcid::new);
5859
inst.register("halplibe:spikes", DeathCauseSpikes::new);
5960
inst.register("halplibe:herobrine", DeathCauseHerobrine::new);
6061
}
@@ -65,7 +66,7 @@ public static class DeathCauseDrown extends DeathCause {
6566

6667
@Override
6768
protected String getTranslationKeyShard() {
68-
return "drown";
69+
return "drowned";
6970
}
7071
}
7172

@@ -110,6 +111,16 @@ protected String getTranslationKeyShard() {
110111
}
111112
}
112113

114+
public static class DeathCauseAcid extends DeathCause {
115+
public DeathCauseAcid(Mob mob) { super(mob); }
116+
public DeathCauseAcid() { super(); }
117+
118+
@Override
119+
protected String getTranslationKeyShard() {
120+
return "acid";
121+
}
122+
}
123+
113124
public static class DeathCauseSpikes extends DeathCause {
114125
public DeathCauseSpikes(Mob mob) { super(mob); }
115126
public DeathCauseSpikes() { super(); }

0 commit comments

Comments
 (0)