Skip to content

Commit

Permalink
Update to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Nov 10, 2024
1 parent 344fbcb commit 5faa24e
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

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

- name: Build with Gradle
run: ./gradlew build

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/libs
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -32,7 +32,7 @@ jobs:
run: ./gradlew build

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
uses: AButler/upload-release-assets@v3.0
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 4 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.1.+'
id 'fabric-loom' version '1.7.+'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -30,8 +30,7 @@ dependencies {
include "kdotjpg:open-simplex:2.0"

// Plasmid
modImplementation "xyz.nucleoid:plasmid:0.5+1.20.1-SNAPSHOT"
modImplementation "xyz.nucleoid:substrate:0.2.1+1.19.4"
modImplementation "xyz.nucleoid:plasmid:0.6.0-SNAPSHOT+1.21.3"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
Expand All @@ -56,7 +55,6 @@ tasks.withType(JavaCompile) {
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.21
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.1
loader_version=0.16.9
# Mod Properties
mod_version=0.1.1
mod_version=0.1.2
maven_group=supercoder79
archives_base_name=rocketspleef
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.83.0+1.20.1
fabric_version=0.106.1+1.21.3
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions src/main/java/supercoder79/rocketspleef/RocketSpleef.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import net.minecraft.util.Identifier;
import supercoder79.rocketspleef.game.RsConfig;
import supercoder79.rocketspleef.game.RsWaiting;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.api.game.GameType;
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;

public final class RocketSpleef implements ModInitializer {
public static final GameRuleType REDUCE_EXPLOSION_DAMAGE = GameRuleType.create();
Expand All @@ -14,7 +14,7 @@ public final class RocketSpleef implements ModInitializer {
@Override
public void onInitialize() {
GameType.register(
new Identifier("rocketspleef", "rocketspleef"),
Identifier.of("rocketspleef", "rocketspleef"),
RsConfig.CODEC,
RsWaiting::open
);
Expand Down
99 changes: 51 additions & 48 deletions src/main/java/supercoder79/rocketspleef/game/RsActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,27 @@
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.GameMode;
import supercoder79.rocketspleef.RocketSpleef;
import supercoder79.rocketspleef.util.WeightedList;
import xyz.nucleoid.plasmid.game.GameCloseReason;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.game.player.PlayerSet;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.util.ItemStackBuilder;
import xyz.nucleoid.plasmid.api.game.GameCloseReason;
import xyz.nucleoid.plasmid.api.game.GameSpace;
import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.api.game.player.JoinIntent;
import xyz.nucleoid.plasmid.api.game.player.PlayerSet;
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.api.util.ItemStackBuilder;
import xyz.nucleoid.stimuli.event.EventResult;
import xyz.nucleoid.stimuli.event.item.ItemUseEvent;
import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent;

import java.util.Set;

public class RsActive {
private static final WeightedList<ItemStack> DROPS = new WeightedList<ItemStack>()
.add(new ItemStack(Blocks.TNT), 10)
Expand All @@ -42,7 +45,6 @@ public class RsActive {
private final GameSpace space;
private final RsMap map;
private final RsConfig config;
private final PlayerSet players;
private final GlobalWidgets widgets;
private long gameEndTimer = -1;

Expand All @@ -51,29 +53,30 @@ public RsActive(ServerWorld world, GameSpace space, RsMap map, RsConfig config,
this.space = space;
this.map = map;
this.config = config;
this.players = players;
this.widgets = widgets;
}

public static void open(ServerWorld world, GameSpace space, RsMap map, RsConfig config) {
space.setActivity(game -> {
GlobalWidgets widgets = GlobalWidgets.addTo(game);
RsActive active = new RsActive(world, space, map, config, space.getPlayers(), widgets);

game.setRule(GameRuleType.BREAK_BLOCKS, ActionResult.SUCCESS);
game.setRule(GameRuleType.PLACE_BLOCKS, ActionResult.SUCCESS);
game.setRule(GameRuleType.CRAFTING, ActionResult.FAIL);
game.setRule(GameRuleType.PORTALS, ActionResult.FAIL);
game.setRule(GameRuleType.PVP, ActionResult.SUCCESS);
game.setRule(GameRuleType.BLOCK_DROPS, ActionResult.SUCCESS);
game.setRule(GameRuleType.FALL_DAMAGE, ActionResult.FAIL);
game.setRule(GameRuleType.HUNGER, ActionResult.FAIL);
game.setRule(GameRuleType.THROW_ITEMS, ActionResult.SUCCESS);
game.setRule(GameRuleType.UNSTABLE_TNT, ActionResult.SUCCESS);
game.setRule(RocketSpleef.REDUCE_EXPLOSION_DAMAGE, ActionResult.SUCCESS);
game.setRule(RocketSpleef.REJECT_ITEMS, ActionResult.SUCCESS);
RsActive active = new RsActive(world, space, map, config, space.getPlayers().participants(), widgets);

game.setRule(GameRuleType.BREAK_BLOCKS, EventResult.ALLOW);
game.setRule(GameRuleType.PLACE_BLOCKS, EventResult.ALLOW);
game.setRule(GameRuleType.CRAFTING, EventResult.DENY);
game.setRule(GameRuleType.PORTALS, EventResult.DENY);
game.setRule(GameRuleType.PVP, EventResult.ALLOW);
game.setRule(GameRuleType.BLOCK_DROPS, EventResult.ALLOW);
game.setRule(GameRuleType.FALL_DAMAGE, EventResult.DENY);
game.setRule(GameRuleType.HUNGER, EventResult.DENY);
game.setRule(GameRuleType.THROW_ITEMS, EventResult.ALLOW);
game.setRule(GameRuleType.UNSTABLE_TNT, EventResult.ALLOW);
game.setRule(RocketSpleef.REDUCE_EXPLOSION_DAMAGE, EventResult.ALLOW);
game.setRule(RocketSpleef.REJECT_ITEMS, EventResult.ALLOW);

game.listen(GameActivityEvents.CREATE, active::open);
game.listen(GamePlayerEvents.OFFER, offer -> offer.intent() == JoinIntent.SPECTATE ? offer.accept() : offer.pass());
game.listen(GamePlayerEvents.ACCEPT, offer -> offer.teleport(world, new Vec3d(0, 70, 0)));
game.listen(GamePlayerEvents.ADD, player -> {});

game.listen(ItemUseEvent.EVENT, active::onUseItem);
Expand All @@ -89,7 +92,7 @@ public static void open(ServerWorld world, GameSpace space, RsMap map, RsConfig
});
}

private static void cooldown(ServerPlayerEntity player, Item item, int ticks) {
private static void cooldown(ServerPlayerEntity player, ItemStack item, int ticks) {
player.getItemCooldownManager().set(item, ticks);
}

Expand All @@ -107,7 +110,7 @@ private void tick() {

for (ServerPlayerEntity player : this.space.getPlayers()) {
if (player.getY() < 16 && player.isAlive() && !player.isSpectator()) {
player.kill();
player.kill(player.getServerWorld());
}
}

Expand All @@ -120,40 +123,40 @@ private void tick() {
}
}

public TypedActionResult<ItemStack> onUseItem(ServerPlayerEntity player, Hand hand) {
public ActionResult onUseItem(ServerPlayerEntity player, Hand hand) {
ItemStack stack = player.getStackInHand(hand);

if (stack.getItem() == Items.IRON_HOE) {
if (!player.getItemCooldownManager().isCoolingDown(stack.getItem())) {
cooldown(player, stack.getItem(), 20);
if (!player.getItemCooldownManager().isCoolingDown(stack)) {
cooldown(player, stack, 20);

Vec3d dir = player.getRotationVec(1.0F);

FireballEntity fireballEntity = new FireballEntity(player.getWorld(), player, dir.x * 4, dir.y * 4, dir.z * 4, 3);
FireballEntity fireballEntity = new FireballEntity(player.getWorld(), player, new Vec3d(dir.x * 4, dir.y * 4, dir.z * 4), 3);
fireballEntity.updatePosition(player.getX() + dir.x, player.getEyeY() + dir.y, fireballEntity.getZ() + dir.z);
player.getWorld().spawnEntity(fireballEntity);

return TypedActionResult.success(stack);
return ActionResult.SUCCESS_SERVER;
}
}

if (stack.getItem() == Items.GOLDEN_HOE) {
if (!player.getItemCooldownManager().isCoolingDown(stack.getItem())) {
cooldown(player, stack.getItem(),12);
if (!player.getItemCooldownManager().isCoolingDown(stack)) {
cooldown(player, stack,12);

Vec3d dir = player.getRotationVec(1.0F);

FireballEntity fireballEntity = new FireballEntity(player.getWorld(), player, dir.x * 6, dir.y * 6, dir.z * 6, 1);
FireballEntity fireballEntity = new FireballEntity(player.getWorld(), player, dir.multiply(6), 1);
fireballEntity.updatePosition(player.getX() + dir.x, player.getEyeY() + dir.y, fireballEntity.getZ() + dir.z);
player.getWorld().spawnEntity(fireballEntity);

return TypedActionResult.success(stack);
return ActionResult.SUCCESS_SERVER;
}
}

if (stack.getItem() == Items.DIAMOND_HOE) {
if (!player.getItemCooldownManager().isCoolingDown(stack.getItem())) {
cooldown(player, stack.getItem(), 70);
if (!player.getItemCooldownManager().isCoolingDown(stack)) {
cooldown(player, stack, 70);

Random random = player.getRandom();
for (int i = 0; i < 4; i++) {
Expand All @@ -162,7 +165,7 @@ public TypedActionResult<ItemStack> onUseItem(ServerPlayerEntity player, Hand ha
double dz = random.nextDouble() - random.nextDouble() * random.nextDouble() * 0.1;
Vec3d dir = player.getRotationVec(1.0F).multiply(dx, dy, dz);

FireballEntity fireballEntity = new FireballEntity(player.getWorld(), player, dir.x * 8, dir.y * 8, dir.z * 8, 4 + random.nextInt(3));
FireballEntity fireballEntity = new FireballEntity(player.getWorld(), player, dir.multiply(8), 4 + random.nextInt(3));
fireballEntity.updatePosition(player.getX() + dir.x, player.getEyeY() + dir.y, fireballEntity.getZ() + dir.z);
player.getWorld().spawnEntity(fireballEntity);
}
Expand Down Expand Up @@ -190,7 +193,7 @@ public TypedActionResult<ItemStack> onUseItem(ServerPlayerEntity player, Hand ha
}
}*/

return TypedActionResult.success(stack);
return ActionResult.SUCCESS_SERVER;
}
}

Expand All @@ -205,38 +208,38 @@ public TypedActionResult<ItemStack> onUseItem(ServerPlayerEntity player, Hand ha
stack.decrement(1);
}

return TypedActionResult.pass(stack);
return ActionResult.PASS;
}

public ActionResult onDeath(ServerPlayerEntity player, DamageSource source) {
public EventResult onDeath(ServerPlayerEntity player, DamageSource source) {
if (player.isSpectator() || this.gameEndTimer != -1) {
player.teleport(player.getServerWorld(), 0, 66, 0, 0.0F, 0.0F);
player.teleport(player.getServerWorld(), 0, 66, 0, Set.of(), 0.0F, 0.0F, true);
RsWaiting.resetPlayer(player, GameMode.SPECTATOR);
return ActionResult.FAIL;
return EventResult.DENY;
}

this.space.getPlayers().sendMessage(Text.empty().formatted(Formatting.RED).append(source.getDeathMessage(player)));

RsWaiting.resetPlayer(player, GameMode.SPECTATOR);
player.teleport(player.getServerWorld(), 0, 66, 0, 0.0F, 0.0F);
player.teleport(player.getServerWorld(), 0, 66, 0, Set.of(), 0.0F, 0.0F, true);

long remaining = this.space.getPlayers().stream().filter(p -> p.interactionManager.isSurvivalLike()).count();
if (remaining <= 1) {
if (remaining == 1) {
ServerPlayerEntity lastPlayer = this.space.getPlayers().stream().filter(p -> p.interactionManager.isSurvivalLike()).findFirst().orElse(null);
if (lastPlayer != null) {
this.space.getPlayers().sendMessage(Text.translatable("text.rocket_spleef.player_won", lastPlayer.getEntityName()).formatted(Formatting.GOLD));
this.space.getPlayers().sendMessage(Text.translatable("text.rocket_spleef.player_won", lastPlayer.getName()).formatted(Formatting.GOLD));
}
}
this.space.getPlayers().sendMessage(Text.translatable("text.rocket_spleef.game_ended").formatted(Formatting.AQUA));
this.gameEndTimer = 20 * 5;
}

return ActionResult.FAIL;
return EventResult.DENY;
}

private void open() {
for (ServerPlayerEntity player : this.players) {
for (ServerPlayerEntity player : this.space.getPlayers().participants()) {
player.getInventory().insertStack(ItemStackBuilder.of(Items.IRON_HOE).setUnbreakable().setName(Text.literal("Fireball Cannon")).build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.Blender;
import net.minecraft.world.gen.noise.NoiseConfig;
import xyz.nucleoid.plasmid.game.world.generator.GameChunkGenerator;
import xyz.nucleoid.plasmid.api.game.world.generator.GameChunkGenerator;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
Expand All @@ -26,7 +26,7 @@ public RsChunkGenerator(MinecraftServer server) {
}

@Override
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender, NoiseConfig config, StructureAccessor accessor, Chunk chunk) {
public CompletableFuture<Chunk> populateNoise(Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk) {
int startX = chunk.getPos().getStartX();
int startZ = chunk.getPos().getStartZ();

Expand Down
15 changes: 5 additions & 10 deletions src/main/java/supercoder79/rocketspleef/game/RsConfig.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package supercoder79.rocketspleef.game;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;

public class RsConfig {
public static final Codec<RsConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
PlayerConfig.CODEC.fieldOf("players").forGetter(config -> config.playerConfig)
public record RsConfig(WaitingLobbyConfig playerConfig) {
public static final MapCodec<RsConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(config -> config.playerConfig)
).apply(instance, RsConfig::new));

public final PlayerConfig playerConfig;

public RsConfig(PlayerConfig playerConfig) {
this.playerConfig = playerConfig;
}
}
Loading

0 comments on commit 5faa24e

Please sign in to comment.