Skip to content

Commit 64dc3e8

Browse files
committed
Fix main world items being lost on death in demo
1 parent bfceb50 commit 64dc3e8

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

changelog/1.1.1+1.21.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Fixed an issue where player data could be lost upon dying in a demo

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ minecraft_version=1.21.1
55
yarn_mappings=1.21.1+build.3
66
loader_version=0.16.10
77

8-
mod_version=1.1.0
8+
mod_version=1.1.1
99
maven_group=io.github.mattidragon.demobox
1010
archives_base_name=DemoBox
1111

src/main/java/io/github/mattidragon/demobox/DemoBoxGame.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minecraft.server.world.ServerWorld;
1313
import net.minecraft.structure.StructurePlacementData;
1414
import net.minecraft.text.Text;
15+
import net.minecraft.util.ActionResult;
1516
import net.minecraft.util.Formatting;
1617
import net.minecraft.util.Identifier;
1718
import net.minecraft.util.math.BlockPos;
@@ -33,6 +34,7 @@
3334
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptorResult;
3435
import xyz.nucleoid.plasmid.api.game.player.JoinOffer;
3536
import xyz.nucleoid.plasmid.api.game.player.JoinOfferResult;
37+
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;
3638

3739
import java.util.Arrays;
3840
import java.util.List;
@@ -67,6 +69,11 @@ private static GameOpenProcedure open(GameOpenContext<Settings> context) {
6769
activity.listen(GamePlayerEvents.JOIN, instance::onPlayerJoin);
6870
activity.listen(GamePlayerEvents.JOIN_MESSAGE, instance::onJoinMessage);
6971
activity.listen(GamePlayerEvents.LEAVE_MESSAGE, instance::onLeaveMessage);
72+
activity.listen(PlayerDeathEvent.EVENT, (player, source) -> {
73+
instance.gameSpace.getPlayers().kick(player);
74+
player.sendMessage(Text.translatable("demobox.demo.death").formatted(Formatting.RED));
75+
return ActionResult.FAIL;
76+
});
7077
});
7178
}
7279

src/main/resources/data/demobox/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"command.demobox.open.fail": "Failed to open demo box",
33
"demobox.demo.join": "%s joined the demo",
44
"demobox.demo.leave": "%s left the game",
5+
"demobox.demo.death": "You have died in the demo and thus removed from it. You can open another one if your want to.",
56
"gameType.demobox.demo_box": "Demo Box",
67

78
"demobox.info.1": "Welcome to the DemoBox!",

0 commit comments

Comments
 (0)