Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21 #4

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java {
}

group = "net.thenextlvl.holograms"
version = "2.1.2"
version = "2.1.3"

repositories {
mavenCentral()
Expand All @@ -21,7 +21,7 @@ repositories {

dependencies {
compileOnly("org.projectlombok:lombok:1.18.32")
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")

compileOnly("net.thenextlvl.core:annotations:2.0.1")

Expand Down
4 changes: 2 additions & 2 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}

dependencies {
paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT")

compileOnly("org.projectlombok:lombok:1.18.32")
compileOnly("net.thenextlvl.core:annotations:2.0.1")
Expand All @@ -39,7 +39,7 @@ dependencies {
paper {
name = "HologramAPI"
main = "net.thenextlvl.hologram.HologramAPI"
apiVersion = "1.20"
apiVersion = "1.21"
prefix = "Holograms"
load = BukkitPluginDescription.PluginLoadOrder.STARTUP
website = "https://thenextlvl.net"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.world.phys.Vec3;
import net.thenextlvl.hologram.api.HologramLoader;
import net.thenextlvl.hologram.api.hologram.Hologram;
import org.bukkit.Location;
Expand Down Expand Up @@ -64,11 +67,27 @@ private static class ClientHologramLoader extends WeakHashMap<Player, Set<Hologr

private void load(Hologram hologram, CraftPlayer player) {
addHologram(player, hologram);
var display = ((CraftDisplay) hologram).getHandle();
player.getHandle().connection.send(display.getAddEntityPacket());
CraftDisplay display = (CraftDisplay) hologram;
player.getHandle().connection.send(createAddEntityPacket(display));
update(hologram, player);
}

private Packet<?> createAddEntityPacket(CraftDisplay display) {
return new ClientboundAddEntityPacket(
display.getEntityId(),
display.getUniqueId(),
display.getX(),
display.getY(),
display.getZ(),
display.getPitch(),
display.getYaw(),
display.getHandle().getType(),
0,
new Vec3(0, 0, 0),
display.getYaw()
);
}

private void unload(Hologram hologram, CraftPlayer player) {
player.getHandle().connection.send(new ClientboundRemoveEntitiesPacket(hologram.getEntityId()));
removeHologram(player, hologram);
Expand Down
Loading