Skip to content

Commit

Permalink
Update FurnitureLib to support 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ste3et committed Nov 16, 2024
1 parent 4e64501 commit d1c5b66
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.InternalStructure;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
Expand All @@ -20,6 +21,7 @@
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;

import java.util.List;
Expand Down Expand Up @@ -82,7 +84,14 @@ private PacketListener steer_vehicle() {
public void onPacketReceiving(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE) {
final Player p = event.getPlayer();
EntityMoving moving = event.getPacket().getBooleans().readSafely(1) ? EntityMoving.SNEAKING : null;
final EntityMoving moving;

if(FurnitureLib.isVersionOrAbove("1.21.2")) {
final InternalStructure input = event.getPacket().getStructures().read(0);
moving = input.getBooleans().readSafely(5) ? EntityMoving.SNEAKING : null;
}else {
moving = event.getPacket().getBooleans().readSafely(1) ? EntityMoving.SNEAKING : null;
}

if (moving != null && moving.equals(EntityMoving.SNEAKING)) {
List<fEntity> e = FurnitureManager.getInstance().getArmorStandFromPassenger(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.Ste3et_C0st.FurnitureLib.Utilitis.BoundingBox;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.CenterType;
import de.Ste3et_C0st.FurnitureLib.main.Type.PlaceableSide;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void spawn(ObjectID id) {
id.addEntities(addEntity(startLocation, direction, id));
id.addBlockLocations(addBlocks(startLocation, direction));
FurnitureLib.debug("FurnitureLib {ModelHandler} -> Spawn Send Models [" + id.getProject() + "]");
id.send(startLocation.getWorld().getPlayers());
FurnitureManager.getInstance().sendObject(id);
FurnitureLib.debug("FurnitureLib {ModelHandler} -> Spawn Finish [" + id.getProject() + "]");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void updatePlayerView(Player player) {
if (getPacketList().isEmpty()) {
return;
}
if (getSQLAction().equals(SQLAction.REMOVE)) {
if (getSQLAction() == SQLAction.REMOVE) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public void updatePlayerViewWithRange(Player player, Location location) {
}
}

public void sendObject(ObjectID objectID) {
objectID.getPlayerList().stream().forEach(player -> objectID.updatePlayerView(player));
}

public void updatePlayerView(Player player, int chunkX, int chunkZ) {
getAllExistObjectIDs().filter(entry -> entry.isInChunk(chunkX, chunkZ)).forEach(entry -> entry.updatePlayerView(player));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class fArmorStand extends fContainerEntity implements SizeableEntity, Sca
private final PacketContainer attribute = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
private final HashMap<BodyPart, DefaultKey<EulerAngle>> angle = new HashMap<Type.BodyPart, DefaultKey<EulerAngle>>();
private final DefaultKey<EntitySize> entitySize = new DefaultKey<EntitySize>(new EntitySize(0.5, 1.975));
private final WrappedAttribute.Builder scaleAttribute = FurnitureLib.isVersionOrAbove("1.20.5") ? FurnitureLib.isVersionOrAbove("1.21.3") ? WrappedAttribute.newBuilder().attributeKey("scale") : WrappedAttribute.newBuilder().attributeKey("generic.scale").baseValue(1D) : null;
private final WrappedAttribute.Builder scaleAttribute = FurnitureLib.isVersionOrAbove("1.20.5") ? FurnitureLib.isVersionOrAbove("1.21.3") ? WrappedAttribute.newBuilder().attributeKey("scale").baseValue(1D) : WrappedAttribute.newBuilder().attributeKey("generic.scale").baseValue(1D) : null;
private final DefaultKey<Double> scaleValue = new DefaultKey<Double>(0D);

@SuppressWarnings("deprecation")
Expand Down

0 comments on commit d1c5b66

Please sign in to comment.