Skip to content

Commit

Permalink
update to pe 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofaa2 committed Dec 14, 2023
1 parent 5539f5c commit 6648f2d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ allprojects {


dependencies {
compileOnlyApi("com.github.retrooper.packetevents:spigot:2.1.0")
compileOnlyApi("com.github.retrooper.packetevents:spigot:2.2.0")
}

1 change: 0 additions & 1 deletion src/main/java/me/tofaa/entitylib/EntityLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
import me.tofaa.entitylib.entity.EntityInteractionProcessor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.tofaa.entitylib;

import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
import com.sun.org.apache.bcel.internal.generic.PUTFIELD;
import me.tofaa.entitylib.meta.EntityMeta;
import me.tofaa.entitylib.meta.Metadata;
import me.tofaa.entitylib.meta.mobs.*;
Expand Down Expand Up @@ -39,6 +38,7 @@

import static com.github.retrooper.packetevents.protocol.entity.type.EntityTypes.*;

@SuppressWarnings("unchecked")
final class MetaConverterRegistry {

private final Map<EntityType, BiFunction<Integer, Metadata, EntityMeta>> converters = new HashMap<>();
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void rotateHead(Location location) {
rotateHead(location.getYaw(), location.getPitch());
}


public void remove() {
if (!spawned) return;
spawned = false;
Expand All @@ -85,9 +84,7 @@ public void teleport(Location location) {
}

public void sendPacketToViewers(PacketWrapper<?> packet) {
viewers.forEach(uuid -> {
EntityLib.sendPacket(uuid, packet);
});
viewers.forEach(uuid -> EntityLib.sendPacket(uuid, packet));
}

public boolean addViewer(UUID uuid) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/tofaa/entitylib/extras/Rotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public enum Rotation {
*/
CLOCKWISE_135,
/**
* Flipped upside-down, a 180 degree rotation
* Flipped upside-down, a 180-degree rotation
*/
FLIPPED,
/**
* Flipped upside-down + 45 degree rotation
* Flipped upside-down + 45-degree rotation
*/
FLIPPED_45,
/**
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.entity.data.EntityMetadataProvider;
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.exception.InvalidVersionException;
Expand Down Expand Up @@ -200,11 +201,16 @@ protected void setMaskBit(int index, byte bit, boolean value) {
if (value) {
mask |= bit;
} else {
mask &= ~bit;
mask &= (byte) ~bit;
}
setMask((byte)index, mask);
}

@Override
public List<EntityData> entityData(ClientVersion clientVersion) {
return metadata.getEntries(); // TODO: Atm this is useless cause of the way the api works. Might change in the future
}

@Override
public List<EntityData> entityData() {
return metadata.getEntries();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return false;
}
entity.addViewer(player.getUniqueId());
entity.spawn(fromBukkit(player.getLocation()));
entity.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
}
ItemStack held = player.getInventory().getItemInMainHand();
if (held != null && held.getType() != Material.AIR) {
if (held != null && !held.getType().isAir()) {
entity.getEquipment().setBoots(SpigotConversionUtil.fromBukkitItemStack(held));
}
EntityMeta meta = entity.getMeta();
Expand All @@ -49,8 +49,4 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return false;
}

public static Location fromBukkit(org.bukkit.Location location) {
return new Location(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
}

}

0 comments on commit 6648f2d

Please sign in to comment.