Skip to content

Commit e987a00

Browse files
authored
Merge pull request #61 from FTBTeam/dev
Dev
2 parents fa45e45 + 30ce972 commit e987a00

File tree

20 files changed

+82
-98
lines changed

20 files changed

+82
-98
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
with:
1919
curse-publish-task: ""
2020
maven-snapshots: true
21+
java-version: 21
2122
secrets:
2223
ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }}
23-
saps-token: ${{ secrets.SAPS_TOKEN }}
24+
saps-token: ${{ secrets.SAPS_TOKEN }}

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
uses: FTBTeam/mods-meta/.github/workflows/standard-release.yml@main
1212
with:
1313
curse-publish-task: curseforge
14+
java-version: 21
1415
secrets:
1516
ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }}
1617
saps-token: ${{ secrets.SAPS_TOKEN }}
17-
curse-token: ${{ secrets.CURSEFORGE_KEY }}
18+
curse-token: ${{ secrets.CURSEFORGE_KEY }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2006.1.0]
8+
9+
### Changed
10+
* Ported to Minecraft 1.20.6. Support for Fabric and NeoForge.
11+
* Forge support may be re-added if/when Architectury adds support for Forge
12+
713
## [2004.1.2]
814

915
### Changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
3+
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
44
}
55

66
architectury {
@@ -36,7 +36,7 @@ allprojects {
3636
// needs to be done AFTER version is set
3737
apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/publishing.gradle"
3838

39-
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 17
39+
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 21
4040

4141
compileJava {
4242
options.encoding = "UTF-8"

common/src/main/java/dev/ftb/mods/ftbessentials/FTBEssentialsClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
public class FTBEssentialsClient extends FTBEssentialsCommon {
1212
@Override
1313
public void updateTabName(UpdateTabNameMessage packet) {
14-
PlayerInfo info = Minecraft.getInstance().getConnection().getPlayerInfo(packet.uuid);
14+
PlayerInfo info = Minecraft.getInstance().getConnection().getPlayerInfo(packet.uuid());
1515

1616
if (info == null) {
1717
return;
1818
}
1919

2020
MutableComponent component = Component.literal("");
21-
if (packet.recording != RecordingStatus.NONE) {
22-
component.append(Component.literal("⏺").withStyle(packet.recording.getStyle()));
21+
if (packet.recording() != RecordingStatus.NONE) {
22+
component.append(Component.literal("⏺").withStyle(packet.recording().getStyle()));
2323
}
2424

25-
MutableComponent nameComponent = Component.literal(packet.nickname.isEmpty() ? packet.name : packet.nickname);
26-
if (packet.afk) {
25+
MutableComponent nameComponent = Component.literal(packet.nickname().isEmpty() ? packet.name() : packet.nickname());
26+
if (packet.afk()) {
2727
nameComponent.withStyle(ChatFormatting.GRAY);
2828
}
2929

common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/cheat/SpeedCommand.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.commands.CommandSourceStack;
88
import net.minecraft.commands.Commands;
99
import net.minecraft.commands.arguments.EntityArgument;
10+
import net.minecraft.core.Holder;
1011
import net.minecraft.network.chat.Component;
1112
import net.minecraft.server.level.ServerPlayer;
1213
import net.minecraft.world.entity.ai.attributes.Attribute;
@@ -42,7 +43,7 @@ public List<LiteralArgumentBuilder<CommandSourceStack>> register() {
4243
);
4344
}
4445

45-
private static int speed(CommandSourceStack source, Attribute attr, ServerPlayer player) {
46+
private static int speed(CommandSourceStack source, Holder<Attribute> attr, ServerPlayer player) {
4647
AttributeInstance attrInstance = player.getAttribute(attr);
4748

4849
showSpeed(source, player, attrInstance);
@@ -51,15 +52,15 @@ private static int speed(CommandSourceStack source, Attribute attr, ServerPlayer
5152
}
5253

5354

54-
private static int speed(CommandSourceStack source, Attribute attr, ServerPlayer target, int boostPct) {
55+
private static int speed(CommandSourceStack source, Holder<Attribute> attr, ServerPlayer target, int boostPct) {
5556
AttributeInstance attrInstance = target.getAttribute(attr);
5657

5758
if (attrInstance != null) {
5859
float speedMult = boostPct / 100f;
5960
attrInstance.removeModifier(ESSENTIALS_SPEED_UUID);
6061
if (speedMult != 0f) {
6162
attrInstance.addPermanentModifier(new AttributeModifier(ESSENTIALS_SPEED_UUID,
62-
"FTB Essentials speed boost", speedMult, AttributeModifier.Operation.MULTIPLY_BASE
63+
"FTB Essentials speed boost", speedMult, AttributeModifier.Operation.ADD_MULTIPLIED_BASE
6364
));
6465
}
6566
showSpeed(source, target, attrInstance);
@@ -71,11 +72,11 @@ private static int speed(CommandSourceStack source, Attribute attr, ServerPlayer
7172
private static void showSpeed(CommandSourceStack source, ServerPlayer target, AttributeInstance attrInstance) {
7273
Component msg;
7374
if (attrInstance != null && attrInstance.getModifier(ESSENTIALS_SPEED_UUID) != null) {
74-
double speedMult = attrInstance.getModifier(ESSENTIALS_SPEED_UUID).getAmount();
75+
double speedMult = attrInstance.getModifier(ESSENTIALS_SPEED_UUID).amount();
7576
int boostPct = (int) (speedMult * 100);
7677
msg = Component.literal("Speed boost for ")
7778
.append(target.getDisplayName())
78-
.append(" (").append(Component.translatable(attrInstance.getAttribute().getDescriptionId())).append(") = " + boostPct + "%");
79+
.append(" (").append(Component.translatable(attrInstance.getAttribute().value().getDescriptionId())).append(") = " + boostPct + "%");
7980
} else {
8081
msg = Component.literal("No speed boost for ").append(target.getDisplayName());
8182
}

common/src/main/java/dev/ftb/mods/ftbessentials/kit/Kit.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.ftb.mods.ftbessentials.util.FTBEPlayerData;
44
import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag;
55
import dev.ftb.mods.ftblibrary.util.TimeUtils;
6+
import net.minecraft.core.HolderLookup;
67
import net.minecraft.nbt.CompoundTag;
78
import net.minecraft.nbt.ListTag;
89
import net.minecraft.nbt.Tag;
@@ -47,11 +48,11 @@ public boolean isAutoGrant() {
4748
return autoGrant;
4849
}
4950

50-
public CompoundTag toNBT() {
51+
public CompoundTag toNBT(HolderLookup.Provider provider) {
5152
CompoundTag tag = new CompoundTag();
5253

5354
ListTag list = new ListTag();
54-
items.forEach(stack -> list.add(saveStack(stack)));
55+
items.forEach(stack -> list.add(saveStack(stack, provider)));
5556

5657
tag.put("items", list);
5758

@@ -61,19 +62,19 @@ public CompoundTag toNBT() {
6162
return tag;
6263
}
6364

64-
private SNBTCompoundTag saveStack(ItemStack stack) {
65+
private SNBTCompoundTag saveStack(ItemStack stack, HolderLookup.Provider provider) {
6566
SNBTCompoundTag tag = new SNBTCompoundTag();
6667
tag.singleLine();
67-
stack.save(tag);
68+
stack.save(provider, tag);
6869
return tag;
6970
}
7071

71-
public static Kit fromNBT(String kitName, CompoundTag tag) {
72+
public static Kit fromNBT(String kitName, CompoundTag tag, HolderLookup.Provider provider) {
7273
List<ItemStack> items = new ArrayList<>();
7374
ListTag list = tag.getList("items", Tag.TAG_COMPOUND);
7475
list.forEach(el -> {
7576
if (el instanceof CompoundTag c) {
76-
items.add(ItemStack.of(c));
77+
ItemStack.parse(provider, c).ifPresent(items::add);
7778
}
7879
});
7980
return new Kit(kitName, items, tag.getLong("cooldown"), tag.getBoolean("auto_grant"));

common/src/main/java/dev/ftb/mods/ftbessentials/kit/KitManager.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.Util;
77
import net.minecraft.core.BlockPos;
88
import net.minecraft.core.Direction;
9+
import net.minecraft.core.HolderLookup;
910
import net.minecraft.core.NonNullList;
1011
import net.minecraft.nbt.CompoundTag;
1112
import net.minecraft.server.level.ServerPlayer;
@@ -25,13 +26,13 @@ public static KitManager getInstance() {
2526
return INSTANCE;
2627
}
2728

28-
public void load(CompoundTag kits) {
29+
public void load(CompoundTag kits, HolderLookup.Provider provider) {
2930
allKits.clear();
30-
kits.getAllKeys().forEach(key -> allKits.put(key, Kit.fromNBT(key, kits.getCompound(key))));
31+
kits.getAllKeys().forEach(key -> allKits.put(key, Kit.fromNBT(key, kits.getCompound(key), provider)));
3132
}
3233

33-
public CompoundTag save() {
34-
return Util.make(new CompoundTag(), tag -> allKits.forEach((name, kit) -> tag.put(name, kit.toNBT())));
34+
public CompoundTag save(HolderLookup.Provider provider) {
35+
return Util.make(new CompoundTag(), tag -> allKits.forEach((name, kit) -> tag.put(name, kit.toNBT(provider))));
3536
}
3637

3738
public Optional<Kit> get(String kitName) {
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package dev.ftb.mods.ftbessentials.net;
22

3-
import dev.architectury.networking.simple.MessageType;
4-
import dev.architectury.networking.simple.SimpleNetworkManager;
5-
import dev.ftb.mods.ftbessentials.FTBEssentials;
3+
import dev.ftb.mods.ftblibrary.util.NetworkHelper;
64

7-
public interface FTBEssentialsNet {
8-
SimpleNetworkManager NET = SimpleNetworkManager.create(FTBEssentials.MOD_ID);
9-
10-
MessageType UPDATE_TAB_NAME = NET.registerS2C("update_tab_name", UpdateTabNameMessage::new);
11-
12-
static void init() {
5+
public class FTBEssentialsNet {
6+
public static void init() {
7+
NetworkHelper.registerS2C(UpdateTabNameMessage.TYPE, UpdateTabNameMessage.STREAM_CODEC, UpdateTabNameMessage::handle);
138
}
149
}
Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,36 @@
11
package dev.ftb.mods.ftbessentials.net;
22

33
import dev.architectury.networking.NetworkManager;
4-
import dev.architectury.networking.simple.BaseS2CMessage;
5-
import dev.architectury.networking.simple.MessageType;
64
import dev.ftb.mods.ftbessentials.FTBEssentials;
75
import dev.ftb.mods.ftbessentials.util.FTBEPlayerData.RecordingStatus;
6+
import dev.ftb.mods.ftblibrary.util.NetworkHelper;
7+
import net.minecraft.core.UUIDUtil;
88
import net.minecraft.network.FriendlyByteBuf;
9+
import net.minecraft.network.codec.ByteBufCodecs;
10+
import net.minecraft.network.codec.StreamCodec;
11+
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
12+
import net.minecraft.resources.ResourceLocation;
913

1014
import java.util.UUID;
1115

12-
public class UpdateTabNameMessage extends BaseS2CMessage {
13-
public final UUID uuid;
14-
public final String name;
15-
public final String nickname;
16-
public final RecordingStatus recording;
17-
public final boolean afk;
16+
public record UpdateTabNameMessage(UUID uuid, String name, String nickname, RecordingStatus recording, boolean afk) implements CustomPacketPayload {
17+
public static final Type<UpdateTabNameMessage> TYPE = new Type<>(new ResourceLocation(FTBEssentials.MOD_ID, "update_tab_name"));
1818

19-
public UpdateTabNameMessage(UUID id, String n, String nn, RecordingStatus r, boolean a) {
20-
uuid = id;
21-
name = n;
22-
nickname = nn;
23-
recording = r;
24-
afk = a;
25-
}
26-
27-
public UpdateTabNameMessage(FriendlyByteBuf buf) {
28-
uuid = new UUID(buf.readLong(), buf.readLong());
29-
name = buf.readUtf(Short.MAX_VALUE);
30-
nickname = buf.readUtf(Short.MAX_VALUE);
31-
recording = buf.readEnum(RecordingStatus.class);
32-
afk = buf.readBoolean();
33-
}
19+
public static StreamCodec<FriendlyByteBuf, UpdateTabNameMessage> STREAM_CODEC = StreamCodec.composite(
20+
UUIDUtil.STREAM_CODEC, UpdateTabNameMessage::uuid,
21+
ByteBufCodecs.STRING_UTF8, UpdateTabNameMessage::name,
22+
ByteBufCodecs.STRING_UTF8, UpdateTabNameMessage::nickname,
23+
NetworkHelper.enumStreamCodec(RecordingStatus.class), UpdateTabNameMessage::recording,
24+
ByteBufCodecs.BOOL, UpdateTabNameMessage::afk,
25+
UpdateTabNameMessage::new
26+
);
3427

35-
@Override
36-
public MessageType getType() {
37-
return FTBEssentialsNet.UPDATE_TAB_NAME;
38-
}
39-
40-
@Override
41-
public void write(FriendlyByteBuf buf) {
42-
buf.writeLong(uuid.getMostSignificantBits());
43-
buf.writeLong(uuid.getLeastSignificantBits());
44-
buf.writeUtf(name, Short.MAX_VALUE);
45-
buf.writeUtf(nickname, Short.MAX_VALUE);
46-
buf.writeEnum(recording);
47-
buf.writeBoolean(afk);
28+
public static void handle(UpdateTabNameMessage message, NetworkManager.PacketContext packetContext) {
29+
packetContext.queue(() -> FTBEssentials.PROXY.updateTabName(message));
4830
}
4931

5032
@Override
51-
public void handle(NetworkManager.PacketContext packetContext) {
52-
FTBEssentials.PROXY.updateTabName(this);
33+
public Type<UpdateTabNameMessage> type() {
34+
return TYPE;
5335
}
5436
}

0 commit comments

Comments
 (0)