Skip to content

Commit ba554fa

Browse files
committed
Update to 1.21.3
1 parent 63de945 commit ba554fa

27 files changed

+109
-102
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
- name: Set up JDK
2222
uses: actions/setup-java@v1
2323
with:
24-
java-version: 17
24+
java-version: 21
2525

2626
- name: Grant execute permission for gradlew
2727
run: chmod +x gradlew
2828

2929
- name: Build with Gradle
3030
run: ./gradlew build
3131

32-
- uses: actions/upload-artifact@v2
32+
- uses: actions/upload-artifact@v4
3333
with:
3434
name: artifacts
3535
path: build/libs

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up JDK
2525
uses: actions/setup-java@v1
2626
with:
27-
java-version: 17
27+
java-version: 21
2828

2929
- name: Grant execute permission for gradlew
3030
run: chmod +x gradlew
@@ -33,7 +33,7 @@ jobs:
3333
run: ./gradlew build
3434

3535
- name: Upload GitHub release
36-
uses: AButler/upload-release-assets@v2.0
36+
uses: AButler/upload-release-assets@v3.0
3737
with:
3838
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
3939
repo-token: ${{ secrets.GITHUB_TOKEN }}

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
2-
id 'fabric-loom' version '1.6.+'
2+
id 'fabric-loom' version '1.7.+'
33
id 'maven-publish'
44
}
55

6-
sourceCompatibility = JavaVersion.VERSION_17
7-
targetCompatibility = JavaVersion.VERSION_17
6+
sourceCompatibility = JavaVersion.VERSION_21
7+
targetCompatibility = JavaVersion.VERSION_21
88

99
archivesBaseName = project.archives_base_name
1010
version = project.mod_version
@@ -34,7 +34,7 @@ processResources {
3434

3535
tasks.withType(JavaCompile).configureEach {
3636
it.options.encoding = "UTF-8"
37-
it.options.release = 17
37+
it.options.release = 21
3838
}
3939

4040
java {

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
5-
minecraft_version=1.20.4
6-
yarn_mappings=1.20.4+build.3
7-
loader_version=0.15.11
5+
minecraft_version=1.21.3
6+
yarn_mappings=1.21.3+build.1
7+
loader_version=0.16.9
88

99
# Dependencies
10-
fabric_version=0.97.1+1.20.4
11-
plasmid_version=0.5.102-SNAPSHOT+1.20.4
10+
fabric_version=0.106.1+1.21.3
11+
plasmid_version=0.6.0+1.21.3
1212

1313
# Mod Properties
14-
mod_version=1.2.1
14+
mod_version=1.2.2
1515
maven_group=io.github.restioson
1616
archives_base_name=loopdeloop

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/io/github/restioson/loopdeloop/LoopDeLoop.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
import net.minecraft.util.Identifier;
77
import org.apache.logging.log4j.LogManager;
88
import org.apache.logging.log4j.Logger;
9-
import xyz.nucleoid.plasmid.game.GameType;
10-
import xyz.nucleoid.plasmid.game.stats.StatisticKey;
9+
import xyz.nucleoid.plasmid.api.game.GameType;
10+
import xyz.nucleoid.plasmid.api.game.stats.StatisticKey;
1111

1212
public final class LoopDeLoop implements ModInitializer {
1313
public static final String ID = "loopdeloop";
1414
public static final Logger LOGGER = LogManager.getLogger(ID);
1515

1616
public static final GameType<LoopDeLoopConfig> TYPE = GameType.register(
17-
new Identifier(LoopDeLoop.ID, "loopdeloop"),
17+
Identifier.of(LoopDeLoop.ID, "loopdeloop"),
1818
LoopDeLoopConfig.CODEC,
1919
LoopDeLoopWaiting::open
2020
);
2121

22-
public static final StatisticKey<Integer> TOTAL_HOOPS = StatisticKey.intKey(new Identifier(ID, "total_hoops"));
23-
public static final StatisticKey<Integer> MISSED_HOOPS = StatisticKey.intKey(new Identifier(ID, "missed_hoops"));
24-
public static final StatisticKey<Integer> BOOSTS_USED = StatisticKey.intKey(new Identifier(ID, "boosts_used"));
22+
public static final StatisticKey<Integer> TOTAL_HOOPS = StatisticKey.intKey(Identifier.of(ID, "total_hoops"));
23+
public static final StatisticKey<Integer> MISSED_HOOPS = StatisticKey.intKey(Identifier.of(ID, "missed_hoops"));
24+
public static final StatisticKey<Integer> BOOSTS_USED = StatisticKey.intKey(Identifier.of(ID, "boosts_used"));
2525

2626
@Override
2727
public void onInitialize() {

src/main/java/io/github/restioson/loopdeloop/game/LoopDeLoopActive.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
99
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
1010
import net.minecraft.block.Blocks;
11+
import net.minecraft.component.DataComponentTypes;
12+
import net.minecraft.component.type.FireworkExplosionComponent;
13+
import net.minecraft.component.type.FireworksComponent;
1114
import net.minecraft.entity.Entity;
1215
import net.minecraft.entity.EntityType;
1316
import net.minecraft.entity.EquipmentSlot;
1417
import net.minecraft.entity.damage.DamageSource;
1518
import net.minecraft.entity.player.ItemCooldownManager;
1619
import net.minecraft.entity.projectile.FireworkRocketEntity;
17-
import net.minecraft.item.FireworkRocketItem;
1820
import net.minecraft.item.ItemStack;
1921
import net.minecraft.item.Items;
2022
import net.minecraft.nbt.NbtCompound;
21-
import net.minecraft.nbt.NbtElement;
22-
import net.minecraft.nbt.NbtInt;
2323
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
2424
import net.minecraft.scoreboard.AbstractTeam;
2525
import net.minecraft.server.network.ServerPlayerEntity;
@@ -32,28 +32,28 @@
3232
import net.minecraft.util.ActionResult;
3333
import net.minecraft.util.Formatting;
3434
import net.minecraft.util.Hand;
35-
import net.minecraft.util.TypedActionResult;
3635
import net.minecraft.util.math.BlockPos;
3736
import net.minecraft.util.math.MathHelper;
3837
import net.minecraft.util.math.Vec3d;
3938
import net.minecraft.util.math.random.Random;
4039
import net.minecraft.world.GameMode;
4140
import org.jetbrains.annotations.Nullable;
42-
import xyz.nucleoid.plasmid.game.GameCloseReason;
43-
import xyz.nucleoid.plasmid.game.GameSpace;
44-
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
45-
import xyz.nucleoid.plasmid.game.common.team.GameTeam;
46-
import xyz.nucleoid.plasmid.game.common.team.GameTeamConfig;
47-
import xyz.nucleoid.plasmid.game.common.team.GameTeamKey;
48-
import xyz.nucleoid.plasmid.game.common.team.TeamManager;
49-
import xyz.nucleoid.plasmid.game.event.GameActivityEvents;
50-
import xyz.nucleoid.plasmid.game.event.GamePlayerEvents;
51-
import xyz.nucleoid.plasmid.game.player.PlayerOffer;
52-
import xyz.nucleoid.plasmid.game.player.PlayerOfferResult;
53-
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
54-
import xyz.nucleoid.plasmid.game.stats.StatisticKey;
55-
import xyz.nucleoid.plasmid.game.stats.StatisticKeys;
56-
import xyz.nucleoid.plasmid.util.ItemStackBuilder;
41+
import xyz.nucleoid.plasmid.api.game.GameCloseReason;
42+
import xyz.nucleoid.plasmid.api.game.GameSpace;
43+
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
44+
import xyz.nucleoid.plasmid.api.game.common.team.GameTeam;
45+
import xyz.nucleoid.plasmid.api.game.common.team.GameTeamConfig;
46+
import xyz.nucleoid.plasmid.api.game.common.team.GameTeamKey;
47+
import xyz.nucleoid.plasmid.api.game.common.team.TeamManager;
48+
import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents;
49+
import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents;
50+
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptor;
51+
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptorResult;
52+
import xyz.nucleoid.plasmid.api.game.player.JoinOffer;
53+
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;
54+
import xyz.nucleoid.plasmid.api.game.stats.StatisticKeys;
55+
import xyz.nucleoid.plasmid.api.util.ItemStackBuilder;
56+
import xyz.nucleoid.stimuli.event.EventResult;
5757
import xyz.nucleoid.stimuli.event.item.ItemUseEvent;
5858
import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent;
5959
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;
@@ -142,7 +142,8 @@ public static void open(ServerWorld world, GameSpace gameSpace, LoopDeLoopMap ma
142142

143143
activity.listen(GameActivityEvents.ENABLE, active::onOpen);
144144

145-
activity.listen(GamePlayerEvents.OFFER, active::offerPlayer);
145+
activity.listen(GamePlayerEvents.OFFER, JoinOffer::acceptSpectators);
146+
activity.listen(GamePlayerEvents.ACCEPT, active::acceptPlayer);
146147
activity.listen(GamePlayerEvents.REMOVE, active::removePlayer);
147148

148149
activity.listen(GameActivityEvents.TICK, active::tick);
@@ -154,34 +155,35 @@ public static void open(ServerWorld world, GameSpace gameSpace, LoopDeLoopMap ma
154155
});
155156
}
156157

157-
private TypedActionResult<ItemStack> onUseItem(ServerPlayerEntity player, Hand hand) {
158+
private ActionResult onUseItem(ServerPlayerEntity player, Hand hand) {
158159
ItemStack heldStack = player.getStackInHand(hand);
159160

160161
LoopDeLoopPlayer state = this.playerStates.get(player);
161162
if (state != null) {
162163
if (heldStack.getItem() == Items.FEATHER) {
163164
ItemCooldownManager cooldown = player.getItemCooldownManager();
164-
if (!cooldown.isCoolingDown(heldStack.getItem())) {
165+
if (!cooldown.isCoolingDown(heldStack)) {
165166
Vec3d rotationVec = player.getRotationVec(1.0F);
166167
player.setVelocity(rotationVec.multiply(LEAP_VELOCITY));
167168
Vec3d oldVel = player.getVelocity();
168169
player.setVelocity(oldVel.x, oldVel.y + 0.5f, oldVel.z);
169170
player.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(player));
170171

171-
player.playSound(SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 1.0F, 1.0F);
172-
cooldown.set(heldStack.getItem(), LEAP_INTERVAL_TICKS);
172+
player.playSoundToPlayer(SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 1.0F, 1.0F);
173+
cooldown.set(heldStack, LEAP_INTERVAL_TICKS);
173174

174175
state.boostUsed++;
176+
return ActionResult.SUCCESS_SERVER;
175177
}
176178
} else if (heldStack.getItem() == Items.FIREWORK_ROCKET) {
177179
ItemCooldownManager cooldown = player.getItemCooldownManager();
178-
if (!cooldown.isCoolingDown(heldStack.getItem())) {
180+
if (!cooldown.isCoolingDown(heldStack)) {
179181
state.boostUsed++;
180182
}
181183
}
182184
}
183185

184-
return TypedActionResult.pass(ItemStack.EMPTY);
186+
return ActionResult.PASS;
185187
}
186188

187189
private void onOpen() {
@@ -218,7 +220,7 @@ private void onOpen() {
218220
this.sidebar.render(this.buildLeaderboard());
219221
}
220222

221-
private PlayerOfferResult offerPlayer(PlayerOffer offer) {
223+
private JoinAcceptorResult acceptPlayer(JoinAcceptor offer) {
222224
return this.spawnLogic.acceptPlayer(offer, GameMode.SPECTATOR);
223225
}
224226

@@ -292,7 +294,7 @@ private void tickPlayers(long time) {
292294

293295
private boolean tickPlayer(ServerPlayerEntity player, LoopDeLoopPlayer state, long time) {
294296
if (time < this.fallFlyingTime) {
295-
player.startFallFlying();
297+
player.startGliding();
296298
}
297299

298300
int nextHoopIdx = state.lastHoop + 1;
@@ -314,7 +316,7 @@ private boolean tickPlayer(ServerPlayerEntity player, LoopDeLoopPlayer state, lo
314316
state.lastPos = currentPos;
315317

316318
if (nextHoop.intersectsSegment(lastPos, currentPos)) {
317-
player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 1.0F, 1.0F);
319+
player.playSoundToPlayer(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 1.0F, 1.0F);
318320

319321
if (!this.config.flappyMode()) {
320322
giveRocket(player, 1, this.config.rocketPower());
@@ -387,7 +389,7 @@ private void onPlayerFinish(ServerPlayerEntity player, LoopDeLoopPlayer state, l
387389
.append(" place!");
388390

389391
player.sendMessage(message, true);
390-
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1.0F, 1.0F);
392+
player.playSoundToPlayer(SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1.0F, 1.0F);
391393
player.changeGameMode(GameMode.SPECTATOR);
392394
if (this.finished.size() == 1 && (long) playerStates.entrySet().size() > 1) isFirst = true;
393395
this.publishPlayerStatistics(player, state, time, isFirst);
@@ -442,7 +444,7 @@ private void failHoop(ServerPlayerEntity player, LoopDeLoopPlayer state, long ti
442444
);
443445
}
444446

445-
player.playSound(SoundEvents.ENTITY_VILLAGER_NO, SoundCategory.PLAYERS, 1.0F, 1.0F);
447+
player.playSoundToPlayer(SoundEvents.ENTITY_VILLAGER_NO, SoundCategory.PLAYERS, 1.0F, 1.0F);
446448
}
447449

448450
private void broadcastWin() {
@@ -471,16 +473,16 @@ private void broadcastWin() {
471473
this.broadcastSound(SoundEvents.ENTITY_VILLAGER_YES);
472474
}
473475

474-
private ActionResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) {
476+
private EventResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) {
475477
long time = this.world.getTime();
476478
this.failHoop(player, this.playerStates.get(player), time);
477-
return ActionResult.FAIL;
479+
return EventResult.DENY;
478480
}
479481

480-
private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
482+
private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) {
481483
long time = this.world.getTime();
482484
this.failHoop(player, this.playerStates.get(player), time);
483-
return ActionResult.FAIL;
485+
return EventResult.DENY;
484486
}
485487

486488
private void spawnParticipant(ServerPlayerEntity player) {
@@ -504,9 +506,7 @@ private void spawnParticipant(ServerPlayerEntity player) {
504506

505507
private static void giveRocket(ServerPlayerEntity player, int n, int flightPower) {
506508
ItemStack rockets = new ItemStack(Items.FIREWORK_ROCKET, n);
507-
NbtCompound rocketPowered = new NbtCompound();
508-
rocketPowered.putInt("Flight", flightPower);
509-
rockets.getOrCreateNbt().put("Fireworks", rocketPowered);
509+
rockets.set(DataComponentTypes.FIREWORKS, new FireworksComponent(flightPower, List.of()));
510510
player.getInventory().insertStack(rockets);
511511
}
512512

@@ -515,7 +515,7 @@ private void broadcastSound(SoundEvent sound, float pitch) {
515515
if (player.equals(this.lastCompleter)) {
516516
continue;
517517
}
518-
player.playSound(sound, SoundCategory.PLAYERS, 1.0F, pitch);
518+
player.playSoundToPlayer(sound, SoundCategory.PLAYERS, 1.0F, pitch);
519519
}
520520
}
521521

src/main/java/io/github/restioson/loopdeloop/game/LoopDeLoopConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package io.github.restioson.loopdeloop.game;
22

33
import com.mojang.serialization.Codec;
4+
import com.mojang.serialization.MapCodec;
45
import com.mojang.serialization.codecs.RecordCodecBuilder;
56
import io.github.restioson.loopdeloop.LoopDeLoop;
67
import net.minecraft.block.Block;
78
import net.minecraft.block.Blocks;
89
import net.minecraft.registry.RegistryCodecs;
910
import net.minecraft.registry.RegistryKeys;
1011
import net.minecraft.registry.entry.RegistryEntryList;
11-
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
12+
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;
1213

1314
public record LoopDeLoopConfig(
14-
PlayerConfig players,
15+
WaitingLobbyConfig players,
1516
int timeLimit,
1617
int loops,
1718
int loopRadius,
@@ -26,8 +27,8 @@ public record LoopDeLoopConfig(
2627
boolean infiniteMode,
2728
boolean debugMode
2829
) {
29-
public static final Codec<LoopDeLoopConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
30-
PlayerConfig.CODEC.fieldOf("players").orElse(new PlayerConfig(1, 100)).forGetter(LoopDeLoopConfig::players),
30+
public static final MapCodec<LoopDeLoopConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
31+
WaitingLobbyConfig.CODEC.fieldOf("players").orElse(new WaitingLobbyConfig(1, 100)).forGetter(LoopDeLoopConfig::players),
3132
Codec.INT.fieldOf("time_limit_secs").forGetter(LoopDeLoopConfig::timeLimit),
3233
Codec.INT.fieldOf("loops").forGetter(LoopDeLoopConfig::loops),
3334
Codec.INT.fieldOf("loop_radius").orElse(5).forGetter(LoopDeLoopConfig::loopRadius),

src/main/java/io/github/restioson/loopdeloop/game/LoopDeLoopPlayer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import net.minecraft.server.network.ServerPlayerEntity;
55
import net.minecraft.server.world.ServerWorld;
66
import net.minecraft.util.math.Vec3d;
7-
import xyz.nucleoid.plasmid.game.stats.StatisticMap;
7+
import xyz.nucleoid.plasmid.api.game.stats.StatisticMap;
8+
9+
import java.util.Set;
810

911
public class LoopDeLoopPlayer {
1012
public final ServerPlayerEntity player;
@@ -26,7 +28,7 @@ public LoopDeLoopPlayer(ServerPlayerEntity player) {
2628

2729
public void teleport(double x, double y, double z) {
2830
ServerWorld world = this.player.getServerWorld();
29-
this.player.teleport(world, x, y, z, 0.0F, 0.0F);
31+
this.player.teleport(world, x, y, z, Set.of(), 0.0F, 0.0F, false);
3032
this.lastPos = new Vec3d(x, y, z);
3133
}
3234

src/main/java/io/github/restioson/loopdeloop/game/LoopDeLoopSideBar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import net.minecraft.scoreboard.number.FixedNumberFormat;
44
import net.minecraft.text.Text;
55
import net.minecraft.util.Formatting;
6-
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
7-
import xyz.nucleoid.plasmid.game.common.widget.SidebarWidget;
6+
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
7+
import xyz.nucleoid.plasmid.api.game.common.widget.SidebarWidget;
88

99
import java.util.List;
1010

0 commit comments

Comments
 (0)