Skip to content

Commit

Permalink
Update to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 8, 2024
1 parent 9952b0b commit 95508f0
Show file tree
Hide file tree
Showing 51 changed files with 336 additions and 300 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 @@ -24,7 +24,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 @@ -33,7 +33,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 }}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'fabric-loom' version '1.4.+'
id 'fabric-loom' version '1.7.+'
id 'maven-publish'
}

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

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -36,7 +36,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9

# Dependencies
fabric_version=0.91.1+1.20.4
plasmid_version=0.5.102-SNAPSHOT+1.20.4
fabric_version=0.110.2+1.21.4
plasmid_version=0.6.2+1.21.4

# Mod Properties
mod_version=1.0.0
mod_version=1.0.1
maven_group=io.github.restioson
archives_base_name=siege
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-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions src/main/java/io/github/restioson/siege/Siege.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import xyz.nucleoid.plasmid.game.GameType;
import xyz.nucleoid.plasmid.api.game.GameType;

public class Siege implements ModInitializer {
public static final String ID = "siege";
Expand All @@ -18,7 +18,7 @@ public void onInitialize() {
SiegeItems.register();

GameType.register(
new Identifier(ID, "siege"),
Identifier.of(ID, "siege"),
SiegeConfig.CODEC,
SiegeWaiting::open
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.plasmid.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeam;

public final class SiegeKitStandEntity extends ArmorStandEntity {
@Nullable
Expand Down Expand Up @@ -72,13 +72,13 @@ public ActionResult interactAt(PlayerEntity playerEntity, Vec3d hitPos, Hand han
}

var cooldownMgr = player.getItemCooldownManager();
if (cooldownMgr.isCoolingDown(SiegeKit.KIT_SELECT_ITEM)) {
if (cooldownMgr.isCoolingDown(SiegeKit.KIT_SELECT_ITEM.getDefaultStack())) {
player.sendMessage(Text.translatable("game.siege.kit.cooldown").formatted(Formatting.RED), true);
return ActionResult.FAIL;
}

this.kit.equipPlayer(player, participant, this.game.config, player.getWorld().getTime());
cooldownMgr.set(SiegeKit.KIT_SELECT_ITEM, SiegeKit.KIT_SWAP_COOLDOWN);
cooldownMgr.set(SiegeKit.KIT_SELECT_ITEM.getDefaultStack(), SiegeKit.KIT_SWAP_COOLDOWN);

return ActionResult.SUCCESS;
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/io/github/restioson/siege/game/SiegeConfig.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package io.github.restioson.siege.game;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.github.restioson.siege.game.map.SiegeMapConfig;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeam;

public record SiegeConfig(
PlayerConfig players,
WaitingLobbyConfig players,
SiegeMapConfig map,
int timeLimitMins,
int capturingGiveTimeSecs,
boolean recapture,
boolean defenderEnderPearl,
boolean attackerEnderPearl
) {
public static final Codec<SiegeConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
PlayerConfig.CODEC.fieldOf("players").forGetter(config -> config.players),
public static final MapCodec<SiegeConfig> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(config -> config.players),
SiegeMapConfig.CODEC.fieldOf("map").forGetter(config -> config.map),
Codec.INT.fieldOf("time_limit_mins").forGetter(config -> config.timeLimitMins),
Codec.INT.fieldOf("capturing_give_time_secs").orElse(0).forGetter(config -> config.capturingGiveTimeSecs),
Expand Down
59 changes: 30 additions & 29 deletions src/main/java/io/github/restioson/siege/game/SiegeKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@
import io.github.restioson.siege.game.active.SiegePersonalResource;
import io.github.restioson.siege.game.active.SiegePlayer;
import io.github.restioson.siege.item.SiegeHorn;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.FireworkExplosionComponent;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.*;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.plasmid.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.util.ItemStackBuilder;
import xyz.nucleoid.plasmid.api.game.common.team.GameTeam;
import xyz.nucleoid.plasmid.api.util.ItemStackBuilder;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;

import static eu.pb4.polymer.core.api.item.PolymerItemUtils.NON_ITALIC_STYLE;

public final class SiegeKit {
public static final int KIT_SWAP_COOLDOWN = 10 * 20;
public static final List<SiegeKit> KITS = new ArrayList<>();
Expand Down Expand Up @@ -65,14 +69,11 @@ public EquipmentSlot getArmorStandSlot() {
}

@Override
public ItemStack buildItemStack(GameTeam team) {
var stack = ItemStackBuilder.of(Items.SHIELD)
public ItemStack buildItemStack(GameTeam team, RegistryWrapper.WrapperLookup lookup) {
return ItemStackBuilder.of(Items.SHIELD)
.setUnbreakable()
.set(DataComponentTypes.BASE_COLOR, team.config().blockDyeColor())
.build();
var tag = new NbtCompound();
tag.putInt("Base", team.config().colors().blockDyeColor().getId());
stack.getOrCreateNbt().put("BlockEntityTag", tag);
return stack;
}
}
),
Expand Down Expand Up @@ -138,11 +139,11 @@ public EquipmentSlot getArmorStandSlot() {
}

@Override
public ItemStack buildItemStack(GameTeam team) {
return SiegeHorn.getStack(
public ItemStack buildItemStack(GameTeam team, RegistryWrapper.WrapperLookup lookup) {
return SiegeHorn.getStack(lookup,
team == SiegeTeams.DEFENDERS ? Instruments.SING_GOAT_HORN :
Instruments.SEEK_GOAT_HORN,
Stream.of(
List.of(
new StatusEffectInstance(StatusEffects.STRENGTH, 10 * 20),
new StatusEffectInstance(StatusEffects.SPEED, 10 * 20)
)
Expand Down Expand Up @@ -171,7 +172,7 @@ private SiegeKit(String id, Item icon, List<KitEquipable> equipment, List<Abstra
KITS.add(this);
}

private static StatusEffectInstance kitEffect(StatusEffect effect) {
private static StatusEffectInstance kitEffect(RegistryEntry<StatusEffect> effect) {
return new StatusEffectInstance(effect, -1, 0, false, false, true);
}

Expand Down Expand Up @@ -221,24 +222,24 @@ private static Text restockMessage(List<RestockResult> restockResults, long time
}

public static ItemStack kitSelectItemStack() {
return KitEquipment.KIT_SELECT.buildItemStack(null);
return KitEquipment.KIT_SELECT.buildItemStack(null, null);
}

public void equipArmourStand(SiegeKitStandEntity stand) {
var team = stand.getTeam();

for (var item : this.equipment) {
ItemStack stack = item.buildItemStack(team);
ItemStack stack = item.buildItemStack(team, stand.getRegistryManager());
EquipmentSlot slot;
if (item.getArmorStandSlot() != null) {
slot = item.getArmorStandSlot();
} else if (stack.getItem() instanceof Equipment equipmentItem) {
slot = equipmentItem.getSlotType();
} else if (stack.contains(DataComponentTypes.EQUIPPABLE)) {
slot = Objects.requireNonNull(stack.get(DataComponentTypes.EQUIPPABLE)).slot();
} else {
continue;
}

stand.equipStack(slot, item.buildItemStack(team));
stand.equipStack(slot, item.buildItemStack(team, stand.getRegistryManager()));
}

for (var item : this.resources) {
Expand Down Expand Up @@ -277,11 +278,11 @@ public void equipPlayer(ServerPlayerEntity player, SiegePlayer participant, Sieg
var team = participant.team;

for (var item : this.equipment) {
var stack = item.buildItemStack(team);
var stack = item.buildItemStack(team, player.getRegistryManager());
if (item.getPlayerSlot() != null) {
player.equipStack(item.getPlayerSlot(), stack);
} else if (stack.getItem() instanceof Equipment equipmentItem) {
player.equipStack(equipmentItem.getSlotType(), stack);
} else if (stack.contains(DataComponentTypes.EQUIPPABLE)) {
player.equipStack(Objects.requireNonNull(stack.get(DataComponentTypes.EQUIPPABLE)).slot(), stack);
} else {
inventory.offerOrDrop(stack);
}
Expand All @@ -305,7 +306,7 @@ private void maybeGiveEnderPearl(ServerPlayerEntity player, SiegePlayer particip
player.getInventory()
.insertStack(ItemStackBuilder.of(Items.ENDER_PEARL)
.setCount(1)
.setName(Text.literal("Warp to Front Lines").setStyle(NON_ITALIC_STYLE))
.setName(Text.literal("Warp to Front Lines"))
.addEnchantment(null, 1)
.addLore(Text.literal("This ender pearl will take you"))
.addLore(Text.literal("to a flag in need of assistance!"))
Expand Down Expand Up @@ -344,7 +345,7 @@ default EquipmentSlot getPlayerSlot() {
return null;
}

ItemStack buildItemStack(GameTeam team);
ItemStack buildItemStack(GameTeam team, RegistryWrapper.WrapperLookup lookup);
}

public interface AbstractKitResource {
Expand Down Expand Up @@ -400,11 +401,11 @@ private record KitEquipment(Item attackerItem, Item defenderItem, List<Enchantme
@SuppressWarnings("Convert2Lambda") // That would be hard to understand
public final static KitEquipable KIT_SELECT = new KitEquipable() {
@Override
public ItemStack buildItemStack(@Nullable GameTeam team) {
public ItemStack buildItemStack(@Nullable GameTeam team, RegistryWrapper.WrapperLookup lookup) {
return ItemStackBuilder.of(KIT_SELECT_ITEM)
.setCount(1)
.setName(Text.literal("Kit Select").setStyle(NON_ITALIC_STYLE))
.addEnchantment(null, 1)
.setName(Text.literal("Kit Select"))
.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true)
.addLore(Text.literal("This compass allows you"))
.addLore(Text.literal("to change your kit!"))
.build();
Expand Down Expand Up @@ -438,7 +439,7 @@ public EquipmentSlot getPlayerSlot() {
return this.playerSlot;
}

public ItemStack buildItemStack(GameTeam team) {
public ItemStack buildItemStack(GameTeam team, RegistryWrapper.WrapperLookup lookup) {
var builder = ItemStackBuilder.of(this.itemForTeam(team))
.setCount(1)
.setUnbreakable()
Expand Down Expand Up @@ -473,7 +474,7 @@ public ItemStackBuilder itemStackBuilder(GameTeam team) {
return ItemStackBuilder.firework(
team.config().fireworkColor().getRgb(),
2,
FireworkRocketItem.Type.SMALL_BALL
FireworkExplosionComponent.Type.SMALL_BALL
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
import net.minecraft.util.math.random.Random;
import net.minecraft.world.GameMode;
import xyz.nucleoid.map_templates.BlockBounds;
import xyz.nucleoid.plasmid.game.player.PlayerOffer;
import xyz.nucleoid.plasmid.game.player.PlayerOfferResult;
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptor;
import xyz.nucleoid.plasmid.api.game.player.JoinAcceptorResult;

import java.util.Set;

public class SiegeSpawnLogic {
public static PlayerOfferResult.Accept acceptPlayer(PlayerOffer offer, ServerWorld world, SiegeSpawn spawn, GameMode gameMode) {
var player = offer.player();
var pos = SiegeSpawnLogic.choosePos(player.getRandom(), spawn.bounds(), 0.5F);
return offer.accept(world, pos)
.and(() -> {
public static JoinAcceptorResult.Teleport acceptPlayer(JoinAcceptor offer, ServerWorld world, SiegeSpawn spawn, GameMode gameMode) {
var pos = SiegeSpawnLogic.choosePos(world.getRandom(), spawn.bounds(), 0.5F);
return offer.teleport(world, pos)
.thenRunForEach((player) -> {
player.setYaw(spawn.yaw());
resetPlayer(player, gameMode);
});
Expand Down Expand Up @@ -54,6 +55,6 @@ public static Vec3d choosePos(Random random, BlockBounds bounds, float aboveGrou

public static void spawnPlayer(ServerPlayerEntity player, SiegeSpawn spawn, ServerWorld world) {
Vec3d pos = SiegeSpawnLogic.choosePos(player.getRandom(), spawn.bounds(), 0.5f);
player.teleport(world, pos.x, pos.y, pos.z, spawn.yaw(), 0.0F);
player.teleport(world, pos.x, pos.y, pos.z, Set.of(), spawn.yaw(), 0.0F, false);
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/restioson/siege/game/SiegeTeams.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import net.minecraft.text.Text;
import net.minecraft.util.DyeColor;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.plasmid.game.GameActivity;
import xyz.nucleoid.plasmid.game.common.team.*;
import xyz.nucleoid.plasmid.api.game.GameActivity;
import xyz.nucleoid.plasmid.api.game.common.team.*;

import java.util.List;

Expand Down
Loading

0 comments on commit 95508f0

Please sign in to comment.