Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrptonaught committed Jun 10, 2024
1 parent 6ed6f34 commit a19fe64
Show file tree
Hide file tree
Showing 43 changed files with 80 additions and 152 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")

//SGui
modImplementation include("eu.pb4:sgui:1.5.1+1.20.5") { exclude group: "net.fabricmc.fabric-api" }
modImplementation include("eu.pb4:sgui:1.6.0+1.21") { exclude group: "net.fabricmc.fabric-api" }

//Fantasy
modImplementation include('xyz.nucleoid:fantasy:0.6.0+1.20.6') { exclude group: "net.fabricmc.fabric-api" }
Expand All @@ -40,7 +40,7 @@ dependencies {
modImplementation "com.moandjiezana.toml:toml4j:0.7.2"

//carpet
modImplementation('carpet:fabric-carpet:1.20.6-1.4.141+v240429') { exclude group: "net.fabricmc.fabric-api" }
modImplementation('carpet:fabric-carpet:1.21-pre3-1.4.146+v240605') { exclude group: "net.fabricmc.fabric-api" }

//NoChatReports
modImplementation('maven.modrinth:no-chat-reports:Fabric-1.20.6-v2.7.0') { exclude group: "net.fabricmc.fabric-api" }
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

# Fabric Properties
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.2
minecraft_version=1.21-pre4
yarn_mappings=1.21-pre4+build.3
loader_version=0.15.11

# Fabric API
fabric_version=0.99.0+1.20.6
fabric_version=0.100.0+1.21

# Mod Properties
mod_version=1.1.0-1.20.6
mod_version=1.1.0-1.21
maven_group=net.kyrptonaught
archives_base_name=ServerUtils

4 changes: 2 additions & 2 deletions src/main/java/net/kyrptonaught/serverutils/CMDHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static Supplier<Text> getFeedback(Text text) {

public static Collection<CommandFunction<ServerCommandSource>> getFunctions(MinecraftServer server, String id) {
if (id.startsWith("#")) {
return server.getCommandFunctionManager().getTag(new Identifier(id.replaceAll("#", "")));
return server.getCommandFunctionManager().getTag(Identifier.of(id.replaceAll("#", "")));
}

Optional<CommandFunction<ServerCommandSource>> function = server.getCommandFunctionManager().getFunction(new Identifier(id));
Optional<CommandFunction<ServerCommandSource>> function = server.getCommandFunctionManager().getFunction(Identifier.of(id));
if (function.isPresent()) return Collections.singleton(function.get());

return Collections.emptySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.util.Identifier;

public record ServerUtilsPresencePacket(boolean enabled) implements CustomPayload {
public static final CustomPayload.Id<ServerUtilsPresencePacket> PACKET_ID = new CustomPayload.Id<>(new Identifier(ServerUtilsMod.MOD_ID, "presence"));
public static final CustomPayload.Id<ServerUtilsPresencePacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of(ServerUtilsMod.MOD_ID, "presence"));
public static final PacketCodec<RegistryByteBuf, ServerUtilsPresencePacket> codec = PacketCodecs.BOOL.xmap(ServerUtilsPresencePacket::new, ServerUtilsPresencePacket::enabled).cast();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.util.Identifier;

public record SqueakPacket(boolean enabled) implements CustomPayload {
public static final Id<SqueakPacket> PACKET_ID = new Id<>(new Identifier(ServerUtilsMod.SpectatorSqueakModule.getMOD_ID(), "squeak_packet"));
public static final Id<SqueakPacket> PACKET_ID = new Id<>(Identifier.of(ServerUtilsMod.SpectatorSqueakModule.getMOD_ID(), "squeak_packet"));
public static final PacketCodec<RegistryByteBuf, SqueakPacket> codec = PacketCodecs.BOOL.xmap(SqueakPacket::new, SqueakPacket::enabled).cast();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.util.Identifier;

public record ArmorHudPacket(boolean enabled) implements CustomPayload {
public static final CustomPayload.Id<ArmorHudPacket> PACKET_ID = new CustomPayload.Id<>(new Identifier("armorhud", "armor_hud_render_enable"));
public static final CustomPayload.Id<ArmorHudPacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of("armorhud", "armor_hud_render_enable"));
public static final PacketCodec<RegistryByteBuf, ArmorHudPacket> codec = PacketCodecs.BOOL.xmap(ArmorHudPacket::new, ArmorHudPacket::enabled).cast();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ResourcePackList deserialize(JsonElement json, Type typeOfT, JsonDeserial
if (array.get(i).isJsonObject()) {
packList.packs.add(context.deserialize(array.get(i), ResourcePack.class));
} else {
packList.packs.add(SwitchableResourcepacksMod.ResourcePacks.get(new Identifier(array.get(i).getAsString())));
packList.packs.add(SwitchableResourcepacksMod.ResourcePacks.get(Identifier.of(array.get(i).getAsString())));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.kyrptonaught.serverutils.customMapLoader.converter;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.gson.JsonObject;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -11,9 +10,7 @@
import net.kyrptonaught.serverutils.customMapLoader.addons.BattleMusic;
import net.kyrptonaught.serverutils.customMapLoader.addons.LobbyMapAddon;
import net.kyrptonaught.serverutils.customMapLoader.addons.ResourcePackList;
import net.kyrptonaught.serverutils.switchableresourcepacks.MusicPack;
import net.kyrptonaught.serverutils.switchableresourcepacks.ResourcePack;
import net.kyrptonaught.serverutils.switchableresourcepacks.ResourcePackConfig;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtIo;
Expand All @@ -39,19 +36,6 @@ public static void ConvertAll() {
}

public static void BattleConvert() {
Map<String, MusicPackData> musicPacks = new HashMap<>();
musicPacks.put("lem.battle:chinese", new MusicPackData(ImmutableMap.of("1", 199, "2", 145, "3", 206, "4", 211)));
musicPacks.put("lem.battle:city", new MusicPackData(ImmutableMap.of("1", 179, "2", 196, "3", 194, "4", 228, "5", 183)));
musicPacks.put("lem.battle:fallout", new MusicPackData(ImmutableMap.of("1", 183, "2", 179, "3", 193, "4", 188, "5", 208, "6", 126, "7", 103)));
musicPacks.put("lem.battle:fantasy", new MusicPackData(ImmutableMap.of("1", 130, "2", 214, "3", 222)));
musicPacks.put("lem.battle:festive", new MusicPackData(ImmutableMap.of("1", 138, "2", 156, "3", 165)));
musicPacks.put("lem.battle:greek", new MusicPackData(ImmutableMap.of("1", 155, "2", 215, "3", 216)));
musicPacks.put("lem.battle:halloween", new MusicPackData(ImmutableMap.of("1", 151, "2", 166, "3", 164)));
musicPacks.put("lem.battle:plastic", new MusicPackData(ImmutableMap.of("1", 135, "2", 155, "3", 150)));
musicPacks.put("lem.battle:steampunk", new MusicPackData(ImmutableMap.of("1", 170, "2", 179, "3", 223, "4", 190)));
musicPacks.put("lem.battle:vanilla", new MusicPackData(ImmutableMap.of("1", 491, "2", 489, "3", 508, "4", 528)));
musicPacks.put("lem.battle:western", new MusicPackData(ImmutableMap.of("1", 140, "2", 148, "3", 172)));

BattleMapData[] battlemaps = new BattleMapData[]{
new BattleMapData("cavern", "lem.base:vanilla", "mappack0", "lem.battle.mapdecider.menu.voting.mappack0"),
new BattleMapData("cove", "lem.base:vanilla", "mappack0", "lem.battle.mapdecider.menu.voting.mappack0"),
Expand Down Expand Up @@ -110,7 +94,7 @@ public static void BattleConvert() {
FileHelper.createDir(tempOut);

BattleMapAddon addon = new BattleMapAddon();
addon.addon_id = new Identifier("4jstudios", map.mapName);
addon.addon_id = Identifier.of("4jstudios", map.mapName);
addon.addon_type = BattleMapAddon.TYPE;
addon.addon_pack = map.mappack;
addon.addon_pack_key = map.mappackkey;
Expand Down Expand Up @@ -207,7 +191,7 @@ public static void LobbyConvert() {
FileHelper.createDir(tempOut);

LobbyMapAddon addon = new LobbyMapAddon();
addon.addon_id = new Identifier("4jstudios", lobby.mapName);
addon.addon_id = Identifier.of("4jstudios", lobby.mapName);
addon.addon_type = LobbyMapAddon.TYPE;
addon.addon_pack = "base";
addon.name_key = "lem.menu.host.config.update.lobby." + lobby.mapName;
Expand Down Expand Up @@ -270,7 +254,7 @@ public static void LEBModsConvert() {
FileHelper.createDir(tempOut);

BattleMapAddon addon = new BattleMapAddon();
addon.addon_id = new Identifier("lemcommunity", rawConfig.get("id").getAsString());
addon.addon_id = Identifier.of("lemcommunity", rawConfig.get("id").getAsString());
addon.addon_type = BattleMapAddon.TYPE;
addon.addon_pack = "Other";
addon.name = mapname;
Expand Down Expand Up @@ -402,35 +386,17 @@ public record BattleMapData(String mapName, String resourcepack, String mappack,
public record LobbyMapData(String mapName, String resourcepack, String winnercoords) {
}

public record MusicPackData(Map<String, Integer> songs) {

public MusicPack build(String id) {
MusicPack pack = new MusicPack();
pack.packID = new Identifier(id);
pack.play_order = MusicPack.PLAY_ORDER.CHRONOLOGICAL;

LinkedHashMap<Identifier, Integer> map = new LinkedHashMap<>();
for (String song : songs.keySet()) {
map.put(new Identifier(id.replace("lem.battle:", "lem.battle:music.") + "." + song), songs.get(song));
}
pack.songs = map;

return pack;
}
}


public static class DummyPack extends ResourcePack {
public DummyPack(String pack) {
super();
this.packID = new Identifier(pack);
this.packID = Identifier.of(pack);
}
}

public static class DummyMusic extends BattleMusic {
public DummyMusic(String pack) {
super();
this.packID = new Identifier(pack);
this.packID = Identifier.of(pack);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ public static void enableDisableMap(MinecraftServer server, Identifier map, bool
}

public static Identifier getMapResourcePackKey(Identifier mapID, Identifier packID) {
return new Identifier("acceptedpacks", mapID.toUnderscoreSeparatedString() + "." + packID.toUnderscoreSeparatedString());
return Identifier.of("acceptedpacks", mapID.toUnderscoreSeparatedString() + "." + packID.toUnderscoreSeparatedString());
}

public static boolean getMapResourcePackValue(ServerPlayerEntity player, Identifier mapID, Identifier packID) {
return Boolean.parseBoolean(UserConfigStorage.getValue(player, getMapResourcePackKey(mapID, packID)));
}

public static Identifier getGlobalAcceptKey() {
return new Identifier("acceptedpacks", "global_accept");
return Identifier.of("acceptedpacks", "global_accept");
}

public static boolean getGlobalAcceptValue(ServerPlayerEntity player) {
return Boolean.parseBoolean(UserConfigStorage.getValue(player, getGlobalAcceptKey()));
}

public static Identifier getOverwriteKey(Identifier mapID) {
return new Identifier("acceptedpacks", "acceptance_policy." + mapID.toUnderscoreSeparatedString() + ".dontaskagain");
return Identifier.of("acceptedpacks", "acceptance_policy." + mapID.toUnderscoreSeparatedString() + ".dontaskagain");
}

public static boolean getOverwriteValue(ServerPlayerEntity player, Identifier mapID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private static void generateMapEnableDisable(DynamicData data, BookPage bookPage
}

private static void generateMapExtras(DynamicData data, BookPage bookPage) {
BattleMapAddon addon = CustomMapLoaderMod.BATTLE_MAPS.get(new Identifier(data.arg(2)));
BattleMapAddon addon = CustomMapLoaderMod.BATTLE_MAPS.get(Identifier.of(data.arg(2)));

Text requiredHeader = withHover(dashTrans("lem.mapdecider.menu.requiredpacks"), trimName(addon.getNameText(), 20));
if (addon.required_packs == null || addon.required_packs.packs.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static ScreenConfig.SlotDefinition getSlotDefinition(ScreenConfig.SlotDe
}
}

slotDefinition.generatedStack = Registries.ITEM.get(new Identifier(slotDefinition.itemID)).getDefaultStack();
slotDefinition.generatedStack = Registries.ITEM.get(Identifier.of(slotDefinition.itemID)).getDefaultStack();

if (slotDefinition.itemNBT != null)
try {
Expand Down Expand Up @@ -217,7 +217,7 @@ private static Text getAsText(String text) {

private static void playSound(ServerPlayerEntity player, String soundID) {
if (soundID != null) {
RegistryEntry<SoundEvent> sound = RegistryEntry.of(SoundEvent.of(new Identifier(soundID)));
RegistryEntry<SoundEvent> sound = RegistryEntry.of(SoundEvent.of(Identifier.of(soundID)));
Vec3d pos = player.getPos();
player.networkHandler.sendPacket(new PlaySoundS2CPacket(sound, SoundCategory.MASTER, pos.x, pos.y, pos.z, 1, 1, player.getRandom().nextLong()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;

public class ScreenConfigLoader implements SimpleSynchronousResourceReloadListener {
public static final Identifier ID = new Identifier(ServerUtilsMod.MOD_ID, ServerUtilsMod.CustomUIModule.getMOD_ID());
public static final Identifier ID = Identifier.of(ServerUtilsMod.MOD_ID, ServerUtilsMod.CustomUIModule.getMOD_ID());

@Override
public Identifier getFabricId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ public void tickPlayer(ServerPlayerEntity player, WorldBorder worldBorder) {

private static void checkBounds(ServerPlayerEntity player, WorldBorder worldBorder, double maxY) {
if (player.getX() > worldBorder.getBoundEast())
player.teleport(worldBorder.getBoundEast() - .5, player.getY(), player.getZ());
player.requestTeleport(worldBorder.getBoundEast() - .5, player.getY(), player.getZ());
if (player.getX() < worldBorder.getBoundWest())
player.teleport(worldBorder.getBoundWest() + .5, player.getY(), player.getZ());
player.requestTeleport(worldBorder.getBoundWest() + .5, player.getY(), player.getZ());
if (player.getZ() > worldBorder.getBoundSouth())
player.teleport(player.getX(), player.getY(), worldBorder.getBoundSouth() - .5);
player.requestTeleport(player.getX(), player.getY(), worldBorder.getBoundSouth() - .5);
if (player.getZ() < worldBorder.getBoundNorth())
player.teleport(player.getX(), player.getY(), worldBorder.getBoundNorth() + .5);
player.requestTeleport(player.getX(), player.getY(), worldBorder.getBoundNorth() + .5);
if (player.getY() > maxY)
player.teleport(player.getX(), maxY - .5, player.getZ());
player.requestTeleport(player.getX(), maxY - .5, player.getZ());
}

public static void sendWorldBorderPacket(ServerPlayerEntity player, WorldBorder worldBorder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.util.Identifier;

public class CustomWorldBorderNetworking {
public static final Identifier CUSTOM_BORDER_PACKET = new Identifier(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder");
public static final Identifier CUSTOM_BORDER_PACKET = Identifier.of(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder");


public static void sendCustomWorldBorderPacket(ServerPlayerEntity player, double xCenter, double zCenter, double xSize, double zSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public record CustomWorldBorderPacket(double xCenter, double zCenter, double xSize,
double zSize) implements CustomPayload {
public static final CustomPayload.Id<CustomWorldBorderPacket> PACKET_ID = new CustomPayload.Id<>(new Identifier(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder"));
public static final CustomPayload.Id<CustomWorldBorderPacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder"));
public static final PacketCodec<RegistryByteBuf, CustomWorldBorderPacket> codec = PacketCodec.of(CustomWorldBorderPacket::write, CustomWorldBorderPacket::read);

public static CustomWorldBorderPacket read(RegistryByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ private static void addToBlockList(Set<Identifier> blockIDs, boolean clear, Map<

for (String id : blockIds.keySet()) {
if (!id.startsWith("#")) {
if (blockIds.get(id)) blockIDs.add(new Identifier(id));
else blockIDs.remove(new Identifier(id));
if (blockIds.get(id)) blockIDs.add(Identifier.of(id));
else blockIDs.remove(Identifier.of(id));
} else {
if (blockIds.get(id))
blockIDs.addAll(getBlockIDsInTag(new Identifier(id.replaceAll("#", ""))));
blockIDs.addAll(getBlockIDsInTag(Identifier.of(id.replaceAll("#", ""))));
else
blockIDs.removeAll(getBlockIDsInTag(new Identifier(id.replaceAll("#", ""))));
blockIDs.removeAll(getBlockIDsInTag(Identifier.of(id.replaceAll("#", ""))));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Map;

public class DatapackLoader implements SimpleSynchronousResourceReloadListener {
public static final Identifier ID = new Identifier(ServerUtilsMod.MOD_ID, ServerUtilsMod.DatapackInteractablesModule.getMOD_ID());
public static final Identifier ID = Identifier.of(ServerUtilsMod.MOD_ID, ServerUtilsMod.DatapackInteractablesModule.getMOD_ID());

@Override
public Identifier getFabricId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class StructureMixin {
@Redirect(method = "spawnEntities", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;next()Ljava/lang/Object;"))
public <E> E fixPaintings(Iterator<StructureTemplate.StructureEntityInfo> instance) {
StructureTemplate.StructureEntityInfo nextStructureEntityInfo = instance.next();
Optional<EntityType<?>> entityType = Registries.ENTITY_TYPE.getOrEmpty(new Identifier(nextStructureEntityInfo.nbt.getString("id")));
Optional<EntityType<?>> entityType = Registries.ENTITY_TYPE.getOrEmpty(Identifier.of(nextStructureEntityInfo.nbt.getString("id")));
if (entityType.isPresent() && entityType.get().equals(EntityType.PAINTING)) {
return (E) new StructureTemplate.StructureEntityInfo(Vec3d.of(nextStructureEntityInfo.blockPos), nextStructureEntityInfo.blockPos, nextStructureEntityInfo.nbt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AbstractBlock.AbstractBlockState.class)
public abstract class AbstractBlockStateMixin implements BlockEntityTickerWrapper {

@Unique
private BlockEntityTicker<BlockEntity> wrapper;

@Inject(method = "scheduledTick", at = @At("TAIL"))
Expand Down
Loading

0 comments on commit a19fe64

Please sign in to comment.