mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-19 15:09:24 +00:00
custom hit box
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class CustomHitBoxPacket extends CustomPayloadPacket {
|
||||
private int entityId;
|
||||
private float height;
|
||||
private float width;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -8,6 +10,8 @@ import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomSkinPayloadPacket extends CustomPayloadPacket {
|
||||
private int entityId;
|
||||
private String skinId;
|
||||
|
||||
@@ -210,8 +210,14 @@ public class GeyserUtils implements Extension {
|
||||
sendSkinPacket(session, player, data);
|
||||
}
|
||||
}
|
||||
} else if (customPacket instanceof CustomHitBoxPacket customHitBoxPacket) {
|
||||
Entity entity = (session.getEntityCache().getEntityByJavaId(customHitBoxPacket.getEntityId()));
|
||||
if (entity != null) {
|
||||
entity.setBoundingBoxHeight(customHitBoxPacket.getHeight());
|
||||
entity.setBoundingBoxWidth(customHitBoxPacket.getWidth());
|
||||
entity.updateBedrockMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,10 @@ public class PlayerUtils {
|
||||
player.sendPluginMessage(GeyserUtils.getInstance(), GeyserUtilsChannels.MAIN, GeyserUtils.getPacketManager().encodePacket(skinPayloadPacket));
|
||||
|
||||
}
|
||||
|
||||
public static void sendCustomHitBox(Player player, Entity entity, float height, float width) {
|
||||
CustomHitBoxPacket packet = new CustomHitBoxPacket(entity.getEntityId(), height, width);
|
||||
player.sendPluginMessage(GeyserUtils.getInstance(), GeyserUtilsChannels.MAIN, GeyserUtils.getPacketManager().encodePacket(packet));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user