Skip to content

Commit

Permalink
Merge pull request #4 from Tatnux/master
Browse files Browse the repository at this point in the history
Update to 1.21
  • Loading branch information
NonSwag authored Jun 28, 2024
2 parents 9148c2e + 0898552 commit 5ccf5f9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
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

0 comments on commit 5ccf5f9

Please sign in to comment.