Skip to content

Commit

Permalink
Add support for 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Oct 31, 2024
1 parent c5a448b commit 7798bc9
Show file tree
Hide file tree
Showing 28 changed files with 129 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public enum ServerVersion {

v1_21_3("1.21.3", 768),
v1_21_1("1.21.1", 767),
v1_21("1.21", 767),
v1_20_6("1.20.6", 766),
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

allprojects {
group = "de.oliver"
version = "0.0.10.1"
version = "0.0.10.2"
description = "Simple, lightweight and fast library for minecraft internals"

repositories {
Expand Down
1 change: 1 addition & 0 deletions factories/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies {
compileOnly("io.papermc.paper:paper-api:${findProperty("minecraftVersion")}-R0.1-SNAPSHOT")
compileOnly(project(":api"))
compileOnly(project(":implementations:1_20_6"))
compileOnly(project(":implementations:1_21_3"))
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public FS_ClientboundPlayerInfoUpdatePacket createPlayerInfoUpdatePacket(
ServerVersion serverVersion, EnumSet<FS_ClientboundPlayerInfoUpdatePacket.Action> actions,
List<FS_ClientboundPlayerInfoUpdatePacket.Entry> entries) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundPlayerInfoUpdatePacketImpl(actions, entries);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundPlayerInfoUpdatePacketImpl(actions, entries);
}
Expand Down Expand Up @@ -68,6 +71,9 @@ public FS_ClientboundAddEntityPacket createAddEntityPacket(
int velocityZ,
int data) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundAddEntityPacketImpl(entityId, entityUUID, entityType, x, y, z, yaw, pitch, headYaw, velocityX, velocityY, velocityZ, data);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundAddEntityPacketImpl(entityId, entityUUID, entityType, x, y, z, yaw, pitch, headYaw, velocityX, velocityY, velocityZ, data);
}
Expand Down Expand Up @@ -106,6 +112,9 @@ public FS_ClientboundAddEntityPacket createAddEntityPacket(
*/
public FS_ClientboundPlayerInfoRemovePacket createPlayerInfoRemovePacket(ServerVersion serverVersion, List<UUID> uuids) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundPlayerInfoRemovePacketImpl(uuids);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundPlayerInfoRemovePacketImpl(uuids);
}
Expand Down Expand Up @@ -147,6 +156,9 @@ public FS_ClientboundPlayerInfoRemovePacket createPlayerInfoRemovePacket(UUID uu
*/
public FS_ClientboundRemoveEntitiesPacket createRemoveEntitiesPacket(ServerVersion serverVersion, List<Integer> entityIds) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundRemoveEntitiesPacketImpl(entityIds);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundRemoveEntitiesPacketImpl(entityIds);
}
Expand Down Expand Up @@ -185,6 +197,9 @@ public FS_ClientboundTeleportEntityPacket createTeleportEntityPacket(
boolean onGround
) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundTeleportEntityPacketImpl(entityId, x, y, z, yaw, pitch, onGround);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundTeleportEntityPacketImpl(entityId, x, y, z, yaw, pitch, onGround);
}
Expand Down Expand Up @@ -223,6 +238,9 @@ public FS_ClientboundTeleportEntityPacket createTeleportEntityPacket(
*/
public FS_ClientboundRotateHeadPacket createRotateHeadPacket(ServerVersion serverVersion, int entityId, float headYaw) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundRotateHeadPacketImpl(entityId, headYaw);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundRotateHeadPacketImpl(entityId, headYaw);
}
Expand All @@ -249,6 +267,9 @@ public FS_ClientboundRotateHeadPacket createRotateHeadPacket(int entityId, float
public FS_ClientboundSetEntityDataPacket createSetEntityDataPacket(
ServerVersion serverVersion, int entityId, List<FS_ClientboundSetEntityDataPacket.EntityData> entityData) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundSetEntityDataPacketImpl(entityId, entityData);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundSetEntityDataPacketImpl(entityId, entityData);
}
Expand All @@ -274,6 +295,9 @@ public FS_ClientboundSetEntityDataPacket createSetEntityDataPacket(int entityId,
*/
public FS_ClientboundSetEquipmentPacket createSetEquipmentPacket(ServerVersion serverVersion, int entityId, Map<FS_EquipmentSlot, ItemStack> equipment) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundSetEquipmentPacketImpl(entityId, equipment);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundSetEquipmentPacketImpl(entityId, equipment);
}
Expand All @@ -300,6 +324,9 @@ public FS_ClientboundSetEquipmentPacket createSetEquipmentPacket(int entityId, M
public FS_ClientboundSetPassengersPacket createSetPassengersPacket(
ServerVersion serverVersion, int entityId, List<Integer> passengers) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundSetPassengersPacketImpl(entityId, passengers);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundSetPassengersPacketImpl(entityId, passengers);
}
Expand Down Expand Up @@ -329,6 +356,9 @@ public FS_ClientboundSetPassengersPacket createSetPassengersPacket(int entityId,
*/
public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(ServerVersion serverVersion, String teamName, FS_ClientboundCreateOrUpdateTeamPacket.CreateTeam createTeam) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, createTeam);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, createTeam);
}
Expand Down Expand Up @@ -358,6 +388,9 @@ public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(Str
*/
public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(ServerVersion serverVersion, String teamName, FS_ClientboundCreateOrUpdateTeamPacket.RemoveTeam removeTeam) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, removeTeam);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, removeTeam);
}
Expand Down Expand Up @@ -387,6 +420,9 @@ public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(Str
*/
public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(ServerVersion serverVersion, String teamName, FS_ClientboundCreateOrUpdateTeamPacket.UpdateTeam updateTeam) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, updateTeam);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, updateTeam);
}
Expand Down Expand Up @@ -416,6 +452,9 @@ public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(Str
*/
public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(ServerVersion serverVersion, String teamName, FS_ClientboundCreateOrUpdateTeamPacket.AddEntity addEntity) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, addEntity);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, addEntity);
}
Expand Down Expand Up @@ -445,6 +484,9 @@ public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(Str
*/
public FS_ClientboundCreateOrUpdateTeamPacket createCreateOrUpdateTeamPacket(ServerVersion serverVersion, String teamName, FS_ClientboundCreateOrUpdateTeamPacket.RemoveEntity removeEntity) {
switch (serverVersion) {
case v1_21_3 -> {
return new de.oliver.fancysitula.versions.v1_21_3.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, removeEntity);
}
case v1_20_5, v1_20_6, v1_21, v1_21_1 -> {
return new de.oliver.fancysitula.versions.v1_20_6.packets.ClientboundCreateOrUpdateTeamPacketImpl(teamName, removeEntity);
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
minecraftVersion=1.21
minecraftVersion=1.21.3
fancyLoggerVersion=0.0.4

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundAddEntityPacket;
import de.oliver.fancysitula.api.utils.AngelConverter;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.server.level.ServerPlayer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundCreateOrUpdateTeamPacket;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import io.papermc.paper.adventure.PaperAdventure;
import net.minecraft.ChatFormatting;
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundPlayerInfoRemovePacket;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.server.level.ServerPlayer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundPlayerInfoUpdatePacket;
import de.oliver.fancysitula.versions.v1_20_6.utils.GameProfileImpl;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.GameProfileImpl;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import io.papermc.paper.adventure.PaperAdventure;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.server.level.ServerPlayer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundRemoveEntitiesPacket;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.server.level.ServerPlayer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundRotateHeadPacket;
import de.oliver.fancysitula.api.utils.AngelConverter;
import de.oliver.fancysitula.api.utils.reflections.ReflectionUtils;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
import net.minecraft.server.level.ServerPlayer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEntityDataPacket;
import de.oliver.fancysitula.api.utils.reflections.ReflectionUtils;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import io.papermc.paper.adventure.PaperAdventure;
import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import com.mojang.datafixers.util.Pair;
import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundSetEquipmentPacket;
import de.oliver.fancysitula.api.utils.FS_EquipmentSlot;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.oliver.fancysitula.versions.v1_20_6.packets;
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundSetPassengersPacket;
import de.oliver.fancysitula.api.utils.reflections.ReflectionUtils;
import de.oliver.fancysitula.versions.v1_20_6.utils.VanillaPlayerAdapter;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
import net.minecraft.server.level.ServerPlayer;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.oliver.fancysitula.versions.v1_21_3.packets;

import de.oliver.fancysitula.api.entities.FS_RealPlayer;
import de.oliver.fancysitula.api.packets.FS_ClientboundTeleportEntityPacket;
import de.oliver.fancysitula.versions.v1_21_3.utils.VanillaPlayerAdapter;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.PositionMoveRotation;
import net.minecraft.world.phys.Vec3;

import java.util.Set;

public class ClientboundTeleportEntityPacketImpl extends FS_ClientboundTeleportEntityPacket {

public ClientboundTeleportEntityPacketImpl(int entityId, double x, double y, double z, float yaw, float pitch, boolean onGround) {
super(entityId, x, y, z, yaw, pitch, onGround);
}

@Override
public Object createPacket() {
ClientboundTeleportEntityPacket packet = new ClientboundTeleportEntityPacket(
entityId,
new PositionMoveRotation(
new Vec3(x, y, z),
Vec3.ZERO,
yaw,
pitch
),
Set.of(),
onGround
);

return packet;
}

@Override
public void sendPacketTo(FS_RealPlayer player) {
ClientboundTeleportEntityPacket packet = (ClientboundTeleportEntityPacket) createPacket();

ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer());
vanillaPlayer.connection.send(packet);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.oliver.fancysitula.versions.v1_20_6.utils;
package de.oliver.fancysitula.versions.v1_21_3.utils;

import com.mojang.authlib.GameProfile;
import de.oliver.fancysitula.api.utils.FS_GameProfile;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.oliver.fancysitula.versions.v1_20_6.utils;
package de.oliver.fancysitula.versions.v1_21_3.utils;

import net.minecraft.server.level.ServerPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
Expand Down
Loading

0 comments on commit 7798bc9

Please sign in to comment.