Compare commits
10 commits
f6ef89c715
...
e1477bb599
Author | SHA1 | Date | |
---|---|---|---|
|
e1477bb599 | ||
|
debb91e642 | ||
|
19f9cb156f | ||
|
1f4aeef600 | ||
|
47f47b5653 | ||
|
fc4983e221 | ||
|
3b1333218a | ||
|
7f3bec929f | ||
|
3be18ca8c3 | ||
|
3b78cc1fae |
9 changed files with 126 additions and 33 deletions
29
.github/workflows/close-invalid-prs.yml
vendored
Normal file
29
.github/workflows/close-invalid-prs.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Thanks paper: https://github.com/papermc/paper/blob/master/.github/workflows/close_invalid_prs.yml
|
||||
name: Close invalid PRs
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [ opened ]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
name: Close invalid PRs
|
||||
if: |
|
||||
github.repository != github.event.pull_request.head.repo.full_name &&
|
||||
(
|
||||
github.head_ref == 'master' ||
|
||||
github.event.pull_request.head.repo.owner.type != 'User'
|
||||
)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: superbrothers/close-pull-request@v3
|
||||
id: "master_branch"
|
||||
if: github.head_ref == 'master'
|
||||
with:
|
||||
comment: "Please do not open pull requests from the `master` branch, create a new branch instead."
|
||||
|
||||
- uses: superbrothers/close-pull-request@v3
|
||||
id: "org_account"
|
||||
if: github.event.pull_request.head.repo.owner.type != 'User' && steps.master_branch.outcome == 'skipped'
|
||||
with:
|
||||
comment: "Please do not open pull requests from non-user accounts like organisations. Create a fork on a user account instead."
|
|
@ -18,10 +18,18 @@ jobs:
|
|||
TYCOONS_REPO_PASS: ${{ secrets.EVOKE_REPO_PASSWORD }}
|
||||
steps:
|
||||
- name: Clone project
|
||||
uses: actions/checkou@v4
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install JDK 21
|
||||
- name: Install JDK 8
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
check-latest: true
|
||||
|
||||
- name: Setup gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: Run build & publish with Gradle Wrapper
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository
|
|
@ -1,6 +1,7 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class APIConfig {
|
||||
|
@ -11,6 +12,7 @@ public final class APIConfig {
|
|||
private boolean tickTickables = false;
|
||||
private boolean platformLogger = false;
|
||||
private boolean bstats = true;
|
||||
private boolean forceBundle = false;
|
||||
|
||||
public APIConfig(PacketEventsAPI<?> packetEvents) {
|
||||
this.packetEvents = packetEvents;
|
||||
|
@ -26,6 +28,11 @@ public final class APIConfig {
|
|||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APIConfig forceBundles() {
|
||||
this.forceBundle = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APIConfig usePlatformLogger() {
|
||||
this.platformLogger = true;
|
||||
return this;
|
||||
|
@ -70,4 +77,10 @@ public final class APIConfig {
|
|||
return bstats;
|
||||
}
|
||||
|
||||
public boolean shouldForceBundles() {
|
||||
return this.forceBundle
|
||||
&& EntityLib.getOptionalApi().isPresent()
|
||||
&& EntityLib.getOptionalApi().get().getPacketEvents().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_4);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,18 +14,13 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEn
|
|||
import me.tofaa.entitylib.EntityLib;
|
||||
import me.tofaa.entitylib.extras.InvalidVersionException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static me.tofaa.entitylib.meta.MetaOffsetConverter.EntityMetaOffsets.*;
|
||||
|
||||
public class EntityMeta implements EntityMetadataProvider {
|
||||
|
||||
private static final MetaConverterRegistry registry = new MetaConverterRegistry();
|
||||
|
@ -145,60 +140,60 @@ public class EntityMeta implements EntityMetadataProvider {
|
|||
}
|
||||
|
||||
public short getAirTicks() {
|
||||
return this.metadata.getIndex(airTicksOffset(), (short) 300);
|
||||
return this.metadata.getIndex((byte)1, (short) 300);
|
||||
}
|
||||
|
||||
public void setAirTicks(short value) {
|
||||
this.metadata.setIndex(airTicksOffset(), EntityDataTypes.SHORT, value);
|
||||
this.metadata.setIndex((byte)1, EntityDataTypes.SHORT, value);
|
||||
}
|
||||
|
||||
public Component getCustomName() {
|
||||
Optional<Component> component = this.metadata.getIndex(customNameOffset(), Optional.empty());
|
||||
Optional<Component> component = this.metadata.getIndex((byte)2, Optional.empty());
|
||||
return component.orElse(null);
|
||||
}
|
||||
|
||||
public void setCustomName(Component value) {
|
||||
this.metadata.setIndex(customNameOffset(), EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value));
|
||||
this.metadata.setIndex((byte)2, EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value));
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return this.metadata.getIndex(customNameVisibleOffset(), false);
|
||||
return this.metadata.getIndex((byte)3, false);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean value) {
|
||||
this.metadata.setIndex(customNameVisibleOffset(), EntityDataTypes.BOOLEAN, value);
|
||||
this.metadata.setIndex((byte)3, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return this.metadata.getIndex(silentOffset(), false);
|
||||
return this.metadata.getIndex((byte)4, false);
|
||||
}
|
||||
|
||||
public void setSilent(boolean value) {
|
||||
this.metadata.setIndex(silentOffset(), EntityDataTypes.BOOLEAN, value);
|
||||
this.metadata.setIndex((byte)4, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean hasNoGravity() {
|
||||
return this.metadata.getIndex(hasNoGravityOffset(), true);
|
||||
return this.metadata.getIndex((byte)5, true);
|
||||
}
|
||||
|
||||
public void setHasNoGravity(boolean value) {
|
||||
this.metadata.setIndex(hasNoGravityOffset(), EntityDataTypes.BOOLEAN, value);
|
||||
this.metadata.setIndex((byte)5, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public EntityPose getPose() {
|
||||
return this.metadata.getIndex(poseOffset(), EntityPose.STANDING);
|
||||
return this.metadata.getIndex((byte)6, EntityPose.STANDING);
|
||||
}
|
||||
|
||||
public void setPose(EntityPose value) {
|
||||
this.metadata.setIndex(poseOffset(), EntityDataTypes.ENTITY_POSE, value);
|
||||
this.metadata.setIndex((byte)6, EntityDataTypes.ENTITY_POSE, value);
|
||||
}
|
||||
|
||||
public int getTicksFrozenInPowderedSnow() {
|
||||
return this.metadata.getIndex(ticksFrozenInPowderedSnowOffset(), 0);
|
||||
return this.metadata.getIndex((byte)7, 0);
|
||||
}
|
||||
|
||||
public void setTicksFrozenInPowderedSnow(int value) {
|
||||
this.metadata.setIndex(ticksFrozenInPowderedSnowOffset(), EntityDataTypes.INT, value);
|
||||
this.metadata.setIndex((byte)7, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public WrapperPlayServerEntityMetadata createPacket() {
|
||||
|
|
|
@ -8,10 +8,14 @@ import org.jetbrains.annotations.ApiStatus;
|
|||
|
||||
@ApiStatus.Internal
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public final class MetaOffsetConverter {
|
||||
private MetaOffsetConverter() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static final class EntityMetaOffsets {
|
||||
private EntityMetaOffsets() {
|
||||
}
|
||||
|
@ -73,6 +77,8 @@ public final class MetaOffsetConverter {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static final class AreaEffectCloudOffsets {
|
||||
private AreaEffectCloudOffsets() {
|
||||
}
|
||||
|
@ -87,10 +93,10 @@ public final class MetaOffsetConverter {
|
|||
|
||||
public static byte waitingOffset() {
|
||||
int protocolVersion = getApi().getPacketEvents().getServerManager().getVersion().getProtocolVersion();
|
||||
if (protocolVersion >= 769 && protocolVersion <= 757) {
|
||||
return 9;
|
||||
}
|
||||
throw new RuntimeException("Unknown protocol version for this method");
|
||||
// if (protocolVersion >= 769 && protocolVersion <= 757) {
|
||||
// }
|
||||
// throw new RuntimeException("Unknown protocol version for this method");
|
||||
}
|
||||
|
||||
public static byte particleOffset() {
|
||||
|
@ -102,6 +108,8 @@ public final class MetaOffsetConverter {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static final class AbstractDisplayMetaOffsets {
|
||||
private AbstractDisplayMetaOffsets() {
|
||||
}
|
||||
|
@ -263,6 +271,8 @@ public final class MetaOffsetConverter {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static final class BlockDisplayMetaOffsets {
|
||||
private BlockDisplayMetaOffsets() {
|
||||
}
|
||||
|
@ -279,6 +289,8 @@ public final class MetaOffsetConverter {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static final class ItemDisplayMetaOffsets {
|
||||
private ItemDisplayMetaOffsets() {
|
||||
}
|
||||
|
@ -306,6 +318,8 @@ public final class MetaOffsetConverter {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public static final class TextDisplayMetaOffsets {
|
||||
private TextDisplayMetaOffsets() {
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public class WrapperEntity implements Tickable {
|
|||
this.passengers = ConcurrentHashMap.newKeySet();
|
||||
this.location = new Location(0, 0, 0, 0, 0);
|
||||
this.viewerRules = new CopyOnWriteArrayList<>();
|
||||
this.velocity = Vector3d.zero();
|
||||
}
|
||||
|
||||
public WrapperEntity(int entityId, EntityType entityType) {
|
||||
|
@ -73,7 +74,7 @@ public class WrapperEntity implements Tickable {
|
|||
if (spawned) return false;
|
||||
this.location = location;
|
||||
this.spawned = true;
|
||||
sendPacketToViewers(
|
||||
sendPacketsToViewers(
|
||||
new WrapperPlayServerSpawnEntity(
|
||||
entityId,
|
||||
Optional.of(this.uuid),
|
||||
|
@ -84,9 +85,12 @@ public class WrapperEntity implements Tickable {
|
|||
location.getYaw(),
|
||||
getObjectData(),
|
||||
createVeloPacket()
|
||||
)
|
||||
),
|
||||
entityMeta.createPacket()
|
||||
);
|
||||
sendPacketToViewers(entityMeta.createPacket());
|
||||
if (this instanceof WrapperLivingEntity) {
|
||||
sendPacketsToViewers(((WrapperLivingEntity)this).getAttributes().createPacket());
|
||||
}
|
||||
this.parent = parent;
|
||||
parent.addEntity(this);
|
||||
return true;
|
||||
|
@ -196,6 +200,9 @@ public class WrapperEntity implements Tickable {
|
|||
sendPacket(uuid, createSpawnPacket());
|
||||
sendPacket(uuid, entityMeta.createPacket());
|
||||
sendPacket(uuid, createPassengerPacket());
|
||||
if (this instanceof WrapperLivingEntity) {
|
||||
sendPacket(uuid, ((WrapperLivingEntity)this).getAttributes().createPacket());
|
||||
}
|
||||
}
|
||||
if (EntityLib.getApi().getSettings().isDebugMode()) {
|
||||
EntityLib.getPlatform().getLogger().info("Added viewer " + uuid + " to entity " + entityId);
|
||||
|
@ -341,7 +348,6 @@ public class WrapperEntity implements Tickable {
|
|||
consumer.accept(entityMeta);
|
||||
}
|
||||
|
||||
|
||||
public @NotNull UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
@ -393,7 +399,7 @@ public class WrapperEntity implements Tickable {
|
|||
return viewerRules.get(index);
|
||||
}
|
||||
|
||||
private WrapperPlayServerEntityVelocity getVelocityPacket() {
|
||||
public WrapperPlayServerEntityVelocity getVelocityPacket() {
|
||||
Vector3d velocity = this.velocity.multiply(8000.0f / 20.0f);
|
||||
return new WrapperPlayServerEntityVelocity(entityId, velocity);
|
||||
}
|
||||
|
@ -441,13 +447,21 @@ public class WrapperEntity implements Tickable {
|
|||
|
||||
public void refresh() {
|
||||
if (!spawned) return;
|
||||
sendPacketToViewers(entityMeta.createPacket());
|
||||
sendPacketToViewers(createPassengerPacket());
|
||||
sendPacketsToViewers(entityMeta.createPacket(), createPassengerPacket());
|
||||
}
|
||||
|
||||
public void sendPacketToViewers(PacketWrapper<?> packet) {
|
||||
if (EntityLib.getApi().getSettings().shouldForceBundles()) {
|
||||
viewers.forEach(uuid -> {
|
||||
sendPacket(uuid, new WrapperPlayServerBundle());
|
||||
sendPacket(uuid, packet);
|
||||
sendPacket(uuid, new WrapperPlayServerBundle());
|
||||
});
|
||||
}
|
||||
else {
|
||||
viewers.forEach(uuid -> sendPacket(uuid, packet));
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPacketsToViewers(PacketWrapper<?>... wrappers) {
|
||||
for (PacketWrapper<?> wrapper : wrappers) {
|
||||
|
|
|
@ -45,6 +45,8 @@ public interface Hologram {
|
|||
|
||||
void setLine(int index, @Nullable Component line);
|
||||
|
||||
void removeLine(int index);
|
||||
|
||||
void addLine(@Nullable Component line);
|
||||
|
||||
void addViewer(@NotNull UUID viewer);
|
||||
|
|
|
@ -110,6 +110,15 @@ final class LegacyHologram implements Hologram.Legacy {
|
|||
teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
if (index < 0 || index >= lines.size()) {
|
||||
return;
|
||||
}
|
||||
this.lines.get(index).remove();
|
||||
this.lines.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLine(@Nullable Component line) {
|
||||
setLine(lines.size(), line);
|
||||
|
|
|
@ -89,6 +89,15 @@ final class ModernHologram implements Hologram.Modern {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
if (index < 0 || index >= lines.size()) {
|
||||
return;
|
||||
}
|
||||
this.lines.get(index).remove();
|
||||
this.lines.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLine(@Nullable Component line) {
|
||||
setLine(lines.size(), line);
|
||||
|
|
Loading…
Reference in a new issue