Compare commits
13
Commits
old/java17
..
2.4.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3185768a3 | ||
|
|
3318583475 | ||
|
|
1fb35efd76 | ||
|
|
e12d0a21ee | ||
|
|
3362b2a16f | ||
|
|
eeb7b8fe05 | ||
|
|
bce700c7e3 | ||
|
|
9506ed628b | ||
|
|
c07a411fe2 | ||
|
|
b8ea7f6ad7 | ||
|
|
83de88b171 | ||
|
|
6dffed2e8f | ||
|
|
6e7fbf240f |
No files matched your search
@@ -44,7 +44,7 @@ This method requires [NpcPlugin](https://www.spigotmc.org/resources/npc-plugin-1
|
||||
<dependency>
|
||||
<groupId>com.github.Eisi05</groupId>
|
||||
<artifactId>NpcApi</artifactId>
|
||||
<version>2.3.3</version>
|
||||
<version>2.4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
@@ -60,7 +60,7 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.github.Eisi05:NpcApi:2.3.3'
|
||||
compileOnly 'com.github.Eisi05:NpcApi:2.4.1'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -93,7 +93,7 @@ Add the repository and dependency to your `pom.xml`:
|
||||
<dependency>
|
||||
<groupId>com.github.Eisi05</groupId>
|
||||
<artifactId>NpcApi</artifactId>
|
||||
<version>2.3.3</version>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
@@ -110,7 +110,7 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.Eisi05:NpcApi:2.3.3'
|
||||
implementation 'com.github.Eisi05:NpcApi:2.4.1'
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
jdk:
|
||||
- openjdk17
|
||||
- openjdk21
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
|
||||
<groupId>de.eisi05</groupId>
|
||||
<artifactId>NpcApi</artifactId>
|
||||
<version>2.3.3</version>
|
||||
<version>2.4.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>NpcApi</name>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -64,7 +66,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -12,6 +12,7 @@ import de.eisi05.npc.api.utils.PacketReader;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedPlayerTeam;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -40,6 +41,8 @@ public final class NpcApi
|
||||
public static Plugin plugin;
|
||||
public static Function<Player, String> DISABLED_MESSAGE_PROVIDER = player -> ChatColor.RED + "DISABLED";
|
||||
|
||||
public static NamespacedKey displayKey;
|
||||
|
||||
/**
|
||||
* The configuration object for the NPC API, containing various settings like the look-at timer.
|
||||
*/
|
||||
@@ -58,6 +61,7 @@ public final class NpcApi
|
||||
{
|
||||
NpcApi.plugin = plugin;
|
||||
NpcApi.config = config;
|
||||
displayKey = new NamespacedKey(NpcApi.plugin, "display");
|
||||
|
||||
if(config.preciseSleepingHitbox())
|
||||
listeners.add(sleepListener = new NpcSleepListener());
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package de.eisi05.npc.api.ai;
|
||||
|
||||
import de.eisi05.npc.api.objects.NPC;
|
||||
import de.eisi05.npc.api.utils.SerializableBiPredicate;
|
||||
import de.eisi05.npc.api.utils.SerializablePredicate;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -17,8 +19,12 @@ public abstract class Goal implements Serializable
|
||||
@Serial
|
||||
private final static long serialVersionUID = 1L;
|
||||
private Priority priority;
|
||||
|
||||
@Deprecated(since = "2.4.1")
|
||||
private SerializablePredicate<NPC> condition;
|
||||
|
||||
private SerializableBiPredicate<Location, NPC> newCondition;
|
||||
|
||||
/**
|
||||
* Creates a new goal with the specified priority.
|
||||
*
|
||||
@@ -33,14 +39,35 @@ public abstract class Goal implements Serializable
|
||||
{
|
||||
}
|
||||
|
||||
@Serial
|
||||
private Object readResolve()
|
||||
{
|
||||
if(newCondition == null && condition != null)
|
||||
newCondition = new SerializableBiPredicate<>()
|
||||
{
|
||||
@Override
|
||||
public boolean test(Location location, NPC npc)
|
||||
{
|
||||
return condition.test(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return condition.toString();
|
||||
}
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the condition for this goal. The condition is checked before the goal is executed.
|
||||
*
|
||||
* @return The condition for this goal
|
||||
*/
|
||||
public @Nullable SerializablePredicate<NPC> getCondition()
|
||||
public final @Nullable SerializableBiPredicate<Location, NPC> getCondition()
|
||||
{
|
||||
return condition;
|
||||
return newCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,9 +75,9 @@ public abstract class Goal implements Serializable
|
||||
*
|
||||
* @param condition The condition to set
|
||||
*/
|
||||
public void setCondition(@Nullable SerializablePredicate<NPC> condition)
|
||||
public void setCondition(@Nullable SerializableBiPredicate<Location, NPC> condition)
|
||||
{
|
||||
this.condition = condition;
|
||||
this.newCondition = condition;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +108,7 @@ public abstract class Goal implements Serializable
|
||||
*/
|
||||
protected boolean canUse(@NotNull NPC npc)
|
||||
{
|
||||
return condition == null || condition.test(npc);
|
||||
return newCondition == null || newCondition.test(getLocation(), npc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,6 +132,16 @@ public abstract class Goal implements Serializable
|
||||
*/
|
||||
protected abstract void stop(@NotNull NPC npc);
|
||||
|
||||
/**
|
||||
* Gets the location associated with this goal.
|
||||
*
|
||||
* @return The location or null if not applicable
|
||||
*/
|
||||
protected @Nullable Location getLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this goal can continue executing. If this returns false, the goal will be stopped and a new goal will be selected.
|
||||
*
|
||||
@@ -113,7 +150,7 @@ public abstract class Goal implements Serializable
|
||||
*/
|
||||
protected boolean canContinue(@NotNull NPC npc)
|
||||
{
|
||||
return condition == null || condition.test(npc);
|
||||
return newCondition == null || newCondition.test(getLocation(), npc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -274,7 +274,7 @@ public class GoalSelector
|
||||
if(usableGoals.isEmpty())
|
||||
selectedGoal = null;
|
||||
else if(usableGoals.size() == 1)
|
||||
selectedGoal = usableGoals.get(0);
|
||||
selectedGoal = usableGoals.getFirst();
|
||||
else
|
||||
{
|
||||
int totalWeight = usableGoals.stream()
|
||||
@@ -300,7 +300,7 @@ public class GoalSelector
|
||||
}
|
||||
|
||||
if(selectedGoal == null)
|
||||
selectedGoal = usableGoals.get(usableGoals.size() - 1);
|
||||
selectedGoal = usableGoals.getLast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class AttackEntityGoal extends Goal
|
||||
super(Priority.ALWAYS);
|
||||
this.targetFilter = targetFilter;
|
||||
this.customAttackRange = customAttackRange;
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FollowEntityGoal extends Goal
|
||||
this.targetEntityId = targetEntityId;
|
||||
this.followDistance = Math.max(stopDistance + 0.5, followDistance);
|
||||
this.stopDistance = Math.max(0.5, stopDistance);
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,7 +175,7 @@ public class LookAroundGoal extends Goal
|
||||
newPitch = lerp(currentPitch, targetPitch, rotationSpeed);
|
||||
}
|
||||
|
||||
newPitch = Math.max(-PITCH_MIN_MAX, Math.min(PITCH_MIN_MAX, newPitch));
|
||||
newPitch = Math.clamp(newPitch, -PITCH_MIN_MAX, PITCH_MIN_MAX);
|
||||
|
||||
currentLoc.setYaw(newYaw);
|
||||
currentLoc.setPitch(newPitch);
|
||||
@@ -278,7 +278,7 @@ public class LookAroundGoal extends Goal
|
||||
targetYaw = (float) Math.toDegrees(Math.atan2(-dx, dz));
|
||||
targetPitch = (float) Math.toDegrees(-Math.atan2(dy, distanceXZ));
|
||||
|
||||
targetPitch = Math.max(-PITCH_MIN_MAX, Math.min(PITCH_MIN_MAX, targetPitch));
|
||||
targetPitch = Math.clamp(targetPitch, -PITCH_MIN_MAX, PITCH_MIN_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ public class WalkPathGoal extends Goal
|
||||
super(Priority.MEDIUM);
|
||||
this.path = builder.path;
|
||||
this.serializablePath = path != null ? path.toSerializablePath() : null;
|
||||
this.speed = Math.max(0.1, Math.min(1.0, builder.speed));
|
||||
this.speed = Math.clamp(builder.speed, 0.1, 1.0);
|
||||
this.completionCallback = builder.completionCallback;
|
||||
this.withRotation = builder.withRotation;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class WalkPathGoal extends Goal
|
||||
*/
|
||||
public void setSpeed(double speed)
|
||||
{
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,12 @@ public class WalkPathGoal extends Goal
|
||||
this.withRotation = withRotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Location getLocation()
|
||||
{
|
||||
return path != null ? path.asLocations().getLast() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this goal can be used by the NPC.
|
||||
*
|
||||
@@ -170,7 +176,7 @@ public class WalkPathGoal extends Goal
|
||||
if(waypoints == null || waypoints.isEmpty())
|
||||
return false;
|
||||
|
||||
Location startLocation = waypoints.get(0);
|
||||
Location startLocation = waypoints.getFirst();
|
||||
if(!startLocation.getWorld().equals(npc.getLocation().getWorld()))
|
||||
return false;
|
||||
|
||||
@@ -193,7 +199,7 @@ public class WalkPathGoal extends Goal
|
||||
if(waypoints == null || waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
Location startLocation = waypoints.get(0);
|
||||
Location startLocation = waypoints.getFirst();
|
||||
double distance = npc.getLocation().distance(startLocation);
|
||||
|
||||
isWalking = true;
|
||||
@@ -244,7 +250,7 @@ public class WalkPathGoal extends Goal
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
|
||||
Location finalLocation = waypoints.get(waypoints.size() - 1);
|
||||
Location finalLocation = waypoints.getLast();
|
||||
|
||||
npc.walkTo(path, speed, true, result ->
|
||||
{
|
||||
@@ -365,7 +371,7 @@ public class WalkPathGoal extends Goal
|
||||
*/
|
||||
public Builder speed(double speed)
|
||||
{
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import de.eisi05.npc.api.objects.NPC;
|
||||
import de.eisi05.npc.api.objects.NpcOption;
|
||||
import de.eisi05.npc.api.pathfinding.AStarPathfinder;
|
||||
import de.eisi05.npc.api.pathfinding.Path;
|
||||
import de.eisi05.npc.api.pathfinding.PathfindingUtils;
|
||||
import de.eisi05.npc.api.scheduler.Tasks;
|
||||
import de.eisi05.npc.api.utils.SerializableConsumer;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedEntity;
|
||||
@@ -63,7 +62,7 @@ public class WalkToLocationGoal extends Goal
|
||||
super(Priority.MEDIUM);
|
||||
this.targetLocation = builder.targetLocation.clone();
|
||||
this.serializableLocation = new Path.SerializablePath.SerializableLocation(targetLocation);
|
||||
this.speed = Math.max(0.1, Math.min(1.0, builder.speed));
|
||||
this.speed = Math.clamp(builder.speed, 0.1, 1.0);
|
||||
this.maxIterations = builder.maxIterations;
|
||||
this.allowDiagonal = builder.allowDiagonal;
|
||||
this.completionCallback = builder.completionCallback;
|
||||
@@ -103,7 +102,7 @@ public class WalkToLocationGoal extends Goal
|
||||
*/
|
||||
public void setSpeed(double speed)
|
||||
{
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,6 +215,12 @@ public class WalkToLocationGoal extends Goal
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Location getLocation()
|
||||
{
|
||||
return targetLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the walk to location goal, calculating the path.
|
||||
*
|
||||
@@ -540,7 +545,7 @@ public class WalkToLocationGoal extends Goal
|
||||
*/
|
||||
public Builder speed(double speed)
|
||||
{
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class WanderGoal extends Goal
|
||||
this.radius = radius;
|
||||
this.minDelay = minDelay;
|
||||
this.maxDelay = maxDelay;
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +158,7 @@ public class WanderGoal extends Goal
|
||||
*/
|
||||
public void setSpeed(double speed)
|
||||
{
|
||||
this.speed = Math.max(0.1, Math.min(1.0, speed));
|
||||
this.speed = Math.clamp(speed, 0.1, 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +286,8 @@ public class WanderGoal extends Goal
|
||||
|
||||
if(y.isPresent())
|
||||
{
|
||||
targetLocation = new Location(world, x, y.getAsInt(), z);
|
||||
targetLocation = new Location(world, x, y.getAsInt(), z, 0, 0);
|
||||
targetLocation.setYaw(calculateYaw(currentLoc, targetLocation));
|
||||
currentWalkGoal = new WalkToLocationGoal.Builder(targetLocation).speed(speed).build();
|
||||
currentWalkGoal.start(npc);
|
||||
return;
|
||||
@@ -297,4 +298,17 @@ public class WanderGoal extends Goal
|
||||
|
||||
delayTicks = maxDelay;
|
||||
}
|
||||
|
||||
public float calculateYaw(@NotNull Location current, @NotNull Location target)
|
||||
{
|
||||
double dx = target.getX() - current.getX();
|
||||
double dz = target.getZ() - current.getZ();
|
||||
|
||||
double yaw = Math.toDegrees(Math.atan2(-dx, dz));
|
||||
|
||||
if(yaw < 0)
|
||||
yaw += 360;
|
||||
|
||||
return (float) yaw;
|
||||
}
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class NpcManager
|
||||
*
|
||||
* @return the set of NPCs
|
||||
*/
|
||||
public static @NotNull Collection<NPC> getList()
|
||||
public static @NotNull Set<NPC> getList()
|
||||
{
|
||||
return npcById.values();
|
||||
return new HashSet<>(npcById.values());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ public record MovementRecording(@NotNull ArrayList<MovementData> movements, long
|
||||
*/
|
||||
public @Nullable MovementData getFirstMovement()
|
||||
{
|
||||
return movements.isEmpty() ? null : movements.get(0);
|
||||
return movements.isEmpty() ? null : movements.getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ public record MovementRecording(@NotNull ArrayList<MovementData> movements, long
|
||||
*/
|
||||
public @Nullable MovementData getLastMovement()
|
||||
{
|
||||
return movements.isEmpty() ? null : movements.get(movements.size() - 1);
|
||||
return movements.isEmpty() ? null : movements.getLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -476,10 +476,9 @@ public class NPC extends NpcHolder
|
||||
public void updateName(@NotNull Player player)
|
||||
{
|
||||
WrappedServerPlayer.fromPlayer(player)
|
||||
.sendPacket(SetEntityDataPacket.create(serverPlayer.getNameTag().getId(), serverPlayer.getNameTag().applyData(
|
||||
Versions.isCurrentVersionSmallerThan(Versions.V1_19_4) || isEnabled() ? name.getName(player) :
|
||||
WrappedComponent.parseFromLegacy(NpcApi.DISABLED_MESSAGE_PROVIDER.apply(player))
|
||||
.append(WrappedComponent.create("\n").append(name.getName(player))))));
|
||||
.sendPacket(SetEntityDataPacket.create(serverPlayer.getNameTag().getId(), serverPlayer.getNameTag()
|
||||
.applyData(isEnabled() ? name.getName(player) : WrappedComponent.parseFromLegacy(NpcApi.DISABLED_MESSAGE_PROVIDER.apply(player))
|
||||
.append(WrappedComponent.create("\n").append(name.getName(player))), name.getDisplayOptions())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,9 +601,7 @@ public class NPC extends NpcHolder
|
||||
|
||||
//packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.ADD_PLAYER, serverPlayer));
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, serverPlayer));
|
||||
|
||||
if(!Versions.isCurrentVersionSmallerThan(Versions.V1_19_3))
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LISTED, serverPlayer));
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LISTED, serverPlayer));
|
||||
|
||||
if(!Versions.isCurrentVersionSmallerThan(Versions.V1_21_2))
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LIST_ORDER, serverPlayer));
|
||||
@@ -615,9 +612,7 @@ public class NPC extends NpcHolder
|
||||
NpcOption.ENABLED.getPacket(isEnabled(), this, player).ifPresent(packets::add);
|
||||
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, wrappedServerPlayer));
|
||||
|
||||
if(!Versions.isCurrentVersionSmallerThan(Versions.V1_19_3))
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LISTED, wrappedServerPlayer));
|
||||
packets.add(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LISTED, wrappedServerPlayer));
|
||||
|
||||
packets.forEach(wrappedServerPlayer::sendPacket);
|
||||
|
||||
@@ -659,6 +654,7 @@ public class NPC extends NpcHolder
|
||||
|
||||
WrappedServerPlayer wrappedServerPlayer = WrappedServerPlayer.fromPlayer(player);
|
||||
wrappedServerPlayer.sendPacket(new RemoveEntityPacket(serverPlayer.getId()));
|
||||
wrappedServerPlayer.sendPacket(new RemoveEntityPacket(entity.getId()));
|
||||
wrappedServerPlayer.sendPacket(new RemoveEntityPacket(serverPlayer.getNameTag().getId()));
|
||||
|
||||
if(WrappedPlayerTeam.exists(player, getServerPlayer().getName()))
|
||||
@@ -669,11 +665,9 @@ public class NPC extends NpcHolder
|
||||
}
|
||||
|
||||
toDeleteEntities.values().forEach(integer -> wrappedServerPlayer.sendPacket(new RemoveEntityPacket(integer)));
|
||||
toDeleteEntities.clear();
|
||||
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_19_3))
|
||||
wrappedServerPlayer.sendPacket(new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.REMOVE_PLAYER, serverPlayer));
|
||||
else
|
||||
wrappedServerPlayer.sendPacket(new PlayerInfoRemovePacket(List.of(getUUID())));
|
||||
wrappedServerPlayer.sendPacket(new PlayerInfoRemovePacket(List.of(getUUID())));
|
||||
|
||||
viewers.remove(player.getUniqueId());
|
||||
|
||||
@@ -953,7 +947,7 @@ public class NPC extends NpcHolder
|
||||
if(isWalking(player))
|
||||
cancelWalking(player);
|
||||
}
|
||||
final double speed = Math.max(Math.min(walkSpeed, 1), 0.1);
|
||||
final double speed = Math.clamp(walkSpeed, 0.1, 1);
|
||||
NpcStartWalkingEvent event = new NpcStartWalkingEvent(this, path, speed, changeRealLocation);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled())
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
package de.eisi05.npc.api.objects;
|
||||
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Represents the layout and visual rendering options for an NPC's name display. Maps directly to Minecraft's Text Display entity metadata properties.
|
||||
*/
|
||||
public class NameDisplayOptions implements Serializable
|
||||
{
|
||||
public static final float[] DEFAULT_SCALE = new float[]{1.0f, 1.0f, 1.0f};
|
||||
public static final int DEFAULT_BRIGHTNESS = -1;
|
||||
public static final float DEFAULT_VIEW_RANGE = 1.0f;
|
||||
public static final int DEFAULT_LINE_WIDTH = 200;
|
||||
public static final int DEFAULT_BACKGROUND_COLOR = 0x40000000;
|
||||
public static final byte DEFAULT_TEXT_OPACITY = (byte) 127;
|
||||
public static final boolean DEFAULT_SEE_THROUGH = false;
|
||||
public static final int DEFAULT_ALIGNMENT = TextDisplay.TextAlignment.CENTER.ordinal();
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private float height = 0;
|
||||
private float[] scale = DEFAULT_SCALE.clone();
|
||||
private int brightness = DEFAULT_BRIGHTNESS;
|
||||
private float viewRange = DEFAULT_VIEW_RANGE;
|
||||
private int lineWidth = DEFAULT_LINE_WIDTH;
|
||||
private int backgroundColor = DEFAULT_BACKGROUND_COLOR;
|
||||
private byte textOpacity = DEFAULT_TEXT_OPACITY;
|
||||
private boolean isSeeThrough = DEFAULT_SEE_THROUGH;
|
||||
private int alignment = DEFAULT_ALIGNMENT;
|
||||
|
||||
/**
|
||||
* Creates a new configuration instance initialized with standard Minecraft text display default settings.
|
||||
*/
|
||||
public NameDisplayOptions()
|
||||
{
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Getters & Fluent Setters
|
||||
// ==========================================
|
||||
|
||||
/**
|
||||
* Gets the 3D scale vector of the name display text.
|
||||
*
|
||||
* @return a float array of size 3 representing [x, y, z] scale dimensions
|
||||
*/
|
||||
public float[] getScale()
|
||||
{
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the 3D scale dimensions of the name text using a pre-configured array. Passing {@code null} resets the scale to the default
|
||||
* {@code [1.0f, 1.0f, 1.0f]}.
|
||||
*
|
||||
* @param scale a float array representing [x, y, z], or null to reset
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setScale(float[] scale)
|
||||
{
|
||||
this.scale = scale != null ? scale.clone() : new float[]{1.0f, 1.0f, 1.0f};
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the 3D scale dimensions of the name text using individual coordinate factors.
|
||||
*
|
||||
* @param x the scale factor along the X-axis
|
||||
* @param y the scale factor along the Y-axis
|
||||
* @param z the scale factor along the Z-axis
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setScale(float x, float y, float z)
|
||||
{
|
||||
this.scale = new float[]{x, y, z};
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the packed block and skylight override value for the text display.
|
||||
*
|
||||
* @return the packed brightness value, or -1 if using the default environmental lighting
|
||||
*/
|
||||
public int getBrightness()
|
||||
{
|
||||
return this.brightness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the packed block and skylight override value for the text display. Setting this to -1 reverts the rendering back to natural entity lighting.
|
||||
*
|
||||
* @param brightness the packed brightness integer values
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setBrightness(int brightness)
|
||||
{
|
||||
this.brightness = brightness;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum block distance at which this name display is visible to players.
|
||||
*
|
||||
* @return the maximum rendering range in blocks
|
||||
*/
|
||||
public float getViewRange()
|
||||
{
|
||||
return this.viewRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum block distance at which this name display remains visible.
|
||||
*
|
||||
* @param viewRange the maximum rendering range in blocks
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setViewRange(float viewRange)
|
||||
{
|
||||
this.viewRange = viewRange;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the line split threshold length before the text automatically wraps to a new line.
|
||||
*
|
||||
* @return the line width threshold value
|
||||
*/
|
||||
public int getLineWidth()
|
||||
{
|
||||
return this.lineWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the line split threshold length before the text automatically wraps to a new line.
|
||||
*
|
||||
* @param lineWidth the line wrap boundary width (Minecraft default is typically 200)
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setLineWidth(int lineWidth)
|
||||
{
|
||||
this.lineWidth = lineWidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ARGB background color rendered directly behind the name text.
|
||||
*
|
||||
* @return the background color packed integer
|
||||
*/
|
||||
public int getBackgroundColor()
|
||||
{
|
||||
return this.backgroundColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ARGB background color rendered directly behind the name text. Use an alpha channel of {@code 0x00} to render an entirely transparent
|
||||
* background.
|
||||
*
|
||||
* @param backgroundColor the packed ARGB background integer code
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setBackgroundColor(int backgroundColor)
|
||||
{
|
||||
this.backgroundColor = backgroundColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specific opacity level applied to the rendered text characters.
|
||||
*
|
||||
* @return the opacity value index, where -1 signals default full alpha opacity
|
||||
*/
|
||||
public byte getTextOpacity()
|
||||
{
|
||||
return this.textOpacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the specific opacity level applied to the rendered text characters.
|
||||
*
|
||||
* @param textOpacity alpha channel depth values, or -1 for default full opacity
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setTextOpacity(byte textOpacity)
|
||||
{
|
||||
this.textOpacity = textOpacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the text characters remain visible through solid geometry blocks.
|
||||
*
|
||||
* @return true if the name text is see-through, false otherwise
|
||||
*/
|
||||
public boolean isSeeThrough()
|
||||
{
|
||||
return this.isSeeThrough;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether the text characters remain visible through solid geometry blocks. Enabling this acts like an X-ray effect for the text.
|
||||
*
|
||||
* @param seeThrough true to force see-through rendering, false for occluded behavior
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setSeeThrough(boolean seeThrough)
|
||||
{
|
||||
this.isSeeThrough = seeThrough;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public @NotNull TextDisplay.TextAlignment getAlignment()
|
||||
{
|
||||
return TextDisplay.TextAlignment.values()[this.alignment];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the horizontal alignment formatting applied to multi-line text strings.
|
||||
*
|
||||
* @param alignment alignment
|
||||
* @return this options instance for method chaining
|
||||
*/
|
||||
public @NotNull NameDisplayOptions setAlignment(@NotNull TextDisplay.TextAlignment alignment)
|
||||
{
|
||||
this.alignment = alignment.ordinal();
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getHeight()
|
||||
{
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@NotNull NameDisplayOptions setHeight(float height)
|
||||
{
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Utility Methods
|
||||
// ==========================================
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this NameDisplayOptions instance. Essential for cloning NPCs without transferring internal field references.
|
||||
*
|
||||
* @return a completely independent, deep-copied duplicate of this configuration
|
||||
*/
|
||||
public @NotNull NameDisplayOptions copy()
|
||||
{
|
||||
NameDisplayOptions cloned = new NameDisplayOptions();
|
||||
cloned.scale = this.scale.clone();
|
||||
cloned.brightness = this.brightness;
|
||||
cloned.viewRange = this.viewRange;
|
||||
cloned.lineWidth = this.lineWidth;
|
||||
cloned.backgroundColor = this.backgroundColor;
|
||||
cloned.textOpacity = this.textOpacity;
|
||||
cloned.isSeeThrough = this.isSeeThrough;
|
||||
cloned.alignment = this.alignment;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this configuration containing the values of all internal display metrics.
|
||||
*
|
||||
* @return a descriptive text block summary of this options instance
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "NameDisplayOptions{" +
|
||||
"scale=" + Arrays.toString(scale) +
|
||||
", brightness=" + brightness +
|
||||
", viewRange=" + viewRange +
|
||||
", lineWidth=" + lineWidth +
|
||||
", backgroundColor=" + backgroundColor +
|
||||
", textOpacity=" + textOpacity +
|
||||
", isSeeThrough=" + isSeeThrough +
|
||||
", alignment=" + alignment +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,7 @@ import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents the name of an NPC, which can be either a fixed {@link WrappedComponent}
|
||||
* or dynamically generated based on a {@link Player}.
|
||||
* Represents the name of an NPC, which can be either a fixed {@link WrappedComponent} or dynamically generated based on a {@link Player}.
|
||||
*/
|
||||
public class NpcName implements Serializable
|
||||
{
|
||||
@@ -21,9 +20,9 @@ public class NpcName implements Serializable
|
||||
|
||||
private final WrappedComponent.SerializedComponent nameComponentSerialized;
|
||||
private final SerializableFunction<Player, WrappedComponent.SerializedComponent> nameFunctionSerialized;
|
||||
|
||||
private transient final WrappedComponent nameComponent;
|
||||
private transient final SerializableFunction<Player, WrappedComponent> nameFunction;
|
||||
private NameDisplayOptions displayOptions = new NameDisplayOptions();
|
||||
|
||||
/**
|
||||
* Creates a static NPC name.
|
||||
@@ -42,8 +41,7 @@ public class NpcName implements Serializable
|
||||
/**
|
||||
* Creates a dynamic NPC name with a fallback static component.
|
||||
* <p>
|
||||
* The {@code nameFunction} generates the name for a player, but if needed,
|
||||
* {@code fallback} will be used as a default static name.
|
||||
* The {@code nameFunction} generates the name for a player, but if needed, {@code fallback} will be used as a default static name.
|
||||
*
|
||||
* @param nameFunction the function producing the name for a given player
|
||||
* @param fallback the static fallback name component
|
||||
@@ -71,8 +69,7 @@ public class NpcName implements Serializable
|
||||
/**
|
||||
* Creates a new {@link NpcName} from a legacy text string.
|
||||
* <p>
|
||||
* The string is parsed using {@link WrappedComponent#parseFromLegacy(String)}
|
||||
* to support Minecraft-style color codes and formatting.
|
||||
* The string is parsed using {@link WrappedComponent#parseFromLegacy(String)} to support Minecraft-style color codes and formatting.
|
||||
*
|
||||
* @param name the legacy text string to convert into an NPC name
|
||||
* @return a new {@link NpcName} representing the given legacy text
|
||||
@@ -109,10 +106,31 @@ public class NpcName implements Serializable
|
||||
@Serial
|
||||
private Object readResolve() throws ObjectStreamException
|
||||
{
|
||||
if(nameFunctionSerialized == null)
|
||||
return new NpcName(nameComponentSerialized.deserialize());
|
||||
NpcName deserialized = nameFunctionSerialized == null ? new NpcName(nameComponentSerialized.deserialize()) :
|
||||
new NpcName(player -> nameFunctionSerialized.apply(player).deserialize(), nameComponentSerialized.deserialize());
|
||||
if(this.displayOptions != null)
|
||||
deserialized.displayOptions = this.displayOptions;
|
||||
return deserialized;
|
||||
}
|
||||
|
||||
return new NpcName(player -> nameFunctionSerialized.apply(player).deserialize(), nameComponentSerialized.deserialize());
|
||||
/**
|
||||
* Gets the display options for this NPC name.
|
||||
*
|
||||
* @return the display options
|
||||
*/
|
||||
public @NotNull NameDisplayOptions getDisplayOptions()
|
||||
{
|
||||
return this.displayOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display options for this NPC name.
|
||||
*
|
||||
* @param displayOptions the display options to set
|
||||
*/
|
||||
public void setDisplayOptions(@NotNull NameDisplayOptions displayOptions)
|
||||
{
|
||||
this.displayOptions = displayOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +174,9 @@ public class NpcName implements Serializable
|
||||
*/
|
||||
public @NotNull NpcName copy()
|
||||
{
|
||||
return isStatic() ? new NpcName(nameComponent) : new NpcName(nameFunction, nameComponent);
|
||||
NpcName copied = isStatic() ? new NpcName(nameComponent) : new NpcName(nameFunction, nameComponent);
|
||||
copied.displayOptions = this.displayOptions.copy();
|
||||
return copied;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,14 +18,14 @@ import de.eisi05.npc.api.wrapper.objects.*;
|
||||
import de.eisi05.npc.api.wrapper.packets.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Pose;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -154,10 +154,7 @@ public class NpcOption<T, S extends Serializable>
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_19_3) && player != null)
|
||||
WrappedServerPlayer.fromPlayer(player).sendPacket(
|
||||
new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.REMOVE_PLAYER, npc.getServerPlayer()));
|
||||
else if(player != null && npc.getUUID() != null)
|
||||
if(player != null && npc.getUUID() != null)
|
||||
WrappedServerPlayer.fromPlayer(player).sendPacket(new PlayerInfoRemovePacket(List.of(npc.getUUID())));
|
||||
}
|
||||
}.runTaskLater(NpcApi.plugin, 50);
|
||||
@@ -171,10 +168,7 @@ public class NpcOption<T, S extends Serializable>
|
||||
public static final NpcOption<Integer, Integer> LATENCY = new NpcOption<>("latency", () -> 0,
|
||||
aInteger -> aInteger, aInteger -> aInteger, aInteger -> aInteger,
|
||||
(latency, npc, player) ->
|
||||
{
|
||||
npc.getServerPlayer().setLatency(latency);
|
||||
return new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LATENCY, npc.getServerPlayer());
|
||||
});
|
||||
new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.UPDATE_LATENCY, npc.getServerPlayer()));
|
||||
|
||||
/**
|
||||
* NPC option to control the visibility of the NPC's nametag.
|
||||
@@ -184,19 +178,10 @@ public class NpcOption<T, S extends Serializable>
|
||||
(hide, npc, player) ->
|
||||
{
|
||||
WrappedEntity<?> nameTag = npc.getServerPlayer().getNameTag();
|
||||
|
||||
WrappedEntityData data = npc.getServerPlayer().getNameTag().getEntityData();
|
||||
if(nameTag instanceof WrappedArmorStand)
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BOOLEAN.create(3), !hide);
|
||||
else if(nameTag instanceof WrappedTextDisplay)
|
||||
{
|
||||
if(!hide)
|
||||
return null;
|
||||
|
||||
if(nameTag instanceof WrappedTextDisplay && hide)
|
||||
return new RemoveEntityPacket(npc.getServerPlayer().getNameTag().getId());
|
||||
}
|
||||
|
||||
return SetEntityDataPacket.create(npc.getServerPlayer().getNameTag().getId(), data);
|
||||
return null;
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -570,11 +555,15 @@ public class NpcOption<T, S extends Serializable>
|
||||
entity = npc.entity;
|
||||
|
||||
npc.entity = entity;
|
||||
if(entity instanceof WrappedEnderDragon dragon)
|
||||
dragon.getSubIds().forEach(id -> NpcManager.addID(id, npc));
|
||||
|
||||
NpcManager.addID(npc.entity.getId(), npc);
|
||||
|
||||
List<PacketWrapper> packets = new ArrayList<>();
|
||||
|
||||
packets.add(new RemoveEntityPacket(npc.getServerPlayer().getId()));
|
||||
packets.add(new RemoveEntityPacket(npc.entity.getId()));
|
||||
packets.add(entity.getAddEntityPacket());
|
||||
|
||||
var teamPair = getTeam(player, npc);
|
||||
@@ -598,9 +587,53 @@ public class NpcOption<T, S extends Serializable>
|
||||
(byte) (Var.nbtToEntityFlags(wrappedEntitySnapshot.getData()) | Var.extractFlagsFromBukkit(entity.getBukkitPlayer())));
|
||||
data.set(WrappedEntityData.EntityDataSerializers.OPTIONAL_CHAT_COMPONENT.create(2), Optional.of(WrappedComponent.create("NPC").getHandle()));
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BOOLEAN.create(3), false);
|
||||
packets.add(SetEntityDataPacket.create(entity.getId(), data));
|
||||
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_19_4) || !npc.getOption(NpcOption.HIDE_NAMETAG, player))
|
||||
if(entity.getBukkitPlayer() instanceof BlockDisplay display)
|
||||
{
|
||||
Vector3f translation = display.getTransformation().getTranslation();
|
||||
if(!display.getPersistentDataContainer().has(NpcApi.displayKey, PersistentDataType.BOOLEAN))
|
||||
{
|
||||
display.getPersistentDataContainer().set(NpcApi.displayKey, PersistentDataType.BOOLEAN, true);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.VECTOR3.create(11),
|
||||
new Vector3f(translation.x - 0.5f, translation.y, translation.z - 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.getBukkitPlayer() instanceof ItemDisplay display)
|
||||
{
|
||||
Vector3f translation = display.getTransformation().getTranslation();
|
||||
if(!display.getPersistentDataContainer().has(NpcApi.displayKey, PersistentDataType.BOOLEAN))
|
||||
{
|
||||
display.getPersistentDataContainer().set(NpcApi.displayKey, PersistentDataType.BOOLEAN, true);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.VECTOR3.create(11), new Vector3f(translation.x, translation.y + 0.5f, translation.z));
|
||||
}
|
||||
}
|
||||
|
||||
packets.add(SetEntityDataPacket.createNoneDefaults(entity.getId(), data));
|
||||
|
||||
List<WrappedEntity<?>> passengers = new ArrayList<>();
|
||||
if(entity.getBukkitPlayer() instanceof Display display)
|
||||
{
|
||||
Vector3f scale = display.getTransformation().getScale();
|
||||
|
||||
WrappedInteraction interaction = WrappedInteraction.create(npc.getLocation().getWorld());
|
||||
interaction.moveTo(npc.getLocation());
|
||||
float width = Math.max(scale.x, scale.z);
|
||||
float height = scale.y;
|
||||
|
||||
NpcManager.addID(interaction.getId(), npc);
|
||||
npc.toDeleteEntities.put("interaction", interaction.getId());
|
||||
passengers.add(interaction);
|
||||
|
||||
npc.name.getDisplayOptions().setHeight(height);
|
||||
WrappedEntityData displayData = interaction.getData(width, height);
|
||||
packets.add(interaction.getAddEntityPacket());
|
||||
packets.add(SetEntityDataPacket.create(interaction.getId(), displayData));
|
||||
}
|
||||
else
|
||||
npc.name.getDisplayOptions().setHeight(0);
|
||||
|
||||
if(!npc.getOption(NpcOption.HIDE_NAMETAG, player))
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_21))
|
||||
npc.serverPlayer.getNameTag()
|
||||
@@ -610,15 +643,17 @@ public class NpcOption<T, S extends Serializable>
|
||||
packets.add(npc.serverPlayer.getNameTag().getAddEntityPacket());
|
||||
|
||||
packets.add(SetEntityDataPacket.create(npc.serverPlayer.getNameTag().getId(), npc.serverPlayer.getNameTag().applyData(
|
||||
Versions.isCurrentVersionSmallerThan(Versions.V1_19_4) || npc.isEnabled() ? npc.name.getName(player) :
|
||||
npc.isEnabled() ? npc.name.getName(player) :
|
||||
WrappedComponent.parseFromLegacy(NpcApi.DISABLED_MESSAGE_PROVIDER.apply(player))
|
||||
.append(WrappedComponent.create("\n").append(npc.name.getName(player))))));
|
||||
.append(WrappedComponent.create("\n").append(npc.name.getName(player))), npc.name.getDisplayOptions())));
|
||||
|
||||
if(!Versions.isCurrentVersionSmallerThan(Versions.V1_19_4))
|
||||
{
|
||||
entity.setPassengers(npc.serverPlayer.getNameTag());
|
||||
packets.add(new SetPassengerPacket(entity));
|
||||
}
|
||||
passengers.add(npc.serverPlayer.getNameTag());
|
||||
}
|
||||
|
||||
if(!passengers.isEmpty())
|
||||
{
|
||||
entity.setPassengers(passengers.toArray(new WrappedEntity<?>[0]));
|
||||
packets.add(new SetPassengerPacket(entity));
|
||||
}
|
||||
|
||||
return new BundlePacket(packets.toArray(new PacketWrapper[0]));
|
||||
@@ -630,33 +665,7 @@ public class NpcOption<T, S extends Serializable>
|
||||
*/
|
||||
static final NpcOption<Boolean, Boolean> ENABLED = new NpcOption<>("enabled", () -> false,
|
||||
aBoolean -> aBoolean, aBoolean -> aBoolean, aBoolean -> aBoolean,
|
||||
(enabled, npc, player) ->
|
||||
{
|
||||
if(!Versions.isCurrentVersionSmallerThan(Versions.V1_19_4))
|
||||
return null;
|
||||
|
||||
if(enabled)
|
||||
return null;
|
||||
|
||||
WrappedArmorStand armorStand = WrappedArmorStand.create(npc.getLocation().getWorld());
|
||||
armorStand.moveTo(npc.getLocation().clone()
|
||||
.add(0, (npc.entity.getBoundingBox().getYSize() * npc.getOption(SCALE, player)), 0));
|
||||
|
||||
PacketWrapper addPacket = armorStand.getAddEntityPacket();
|
||||
|
||||
WrappedEntityData data = armorStand.getEntityData();
|
||||
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BYTE.create(0), (byte) 0x20);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.OPTIONAL_CHAT_COMPONENT.create(2),
|
||||
Optional.of(WrappedComponent.parseFromLegacy(NpcApi.DISABLED_MESSAGE_PROVIDER.apply(player)).getHandle()));
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BOOLEAN.create(3), true);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BOOLEAN.create(4), true);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BYTE.create(15), (byte) 0x10);
|
||||
|
||||
npc.toDeleteEntities.put("name", armorStand.getId());
|
||||
|
||||
return new BundlePacket(addPacket, SetEntityDataPacket.create(armorStand.getId(), data));
|
||||
});
|
||||
(enabled, npc, player) -> null);
|
||||
|
||||
/**
|
||||
* NPC option to control if the NPC is enabled (visible and interactable). If false, a "DISABLED" marker may be shown. This is an internal option, typically
|
||||
@@ -710,7 +719,7 @@ public class NpcOption<T, S extends Serializable>
|
||||
private final Function<S, T> deserializer;
|
||||
private final Function<T, T> copyFunction;
|
||||
private final TriFunction<T, NPC, Player, PacketWrapper> packet;
|
||||
private Versions since = Versions.V1_17;
|
||||
private Versions since = Versions.V1_20_6;
|
||||
private boolean loadBefore = false;
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,10 +70,7 @@ public record Skin(@Nullable String name, @Nullable String value, @Nullable Stri
|
||||
if(Versions.getVersion() == Versions.NONE)
|
||||
throw new VersionNotFound();
|
||||
|
||||
return Versions.isCurrentVersionSmallerThan(Versions.V1_20_2) ?
|
||||
new Skin(player.getName(), Reflections.<String>invokeMethod(property, "getValue").get(),
|
||||
Reflections.<String>invokeMethod(property, "getSignature").get()) :
|
||||
new Skin(player.getName(), Reflections.<String>invokeMethod(property, "value").get(),
|
||||
return new Skin(player.getName(), Reflections.<String>invokeMethod(property, "value").get(),
|
||||
Reflections.<String>invokeMethod(property, "signature").get());
|
||||
}
|
||||
|
||||
@@ -98,7 +95,7 @@ public record Skin(@Nullable String name, @Nullable String value, @Nullable Stri
|
||||
{
|
||||
String response = scanner.useDelimiter("\\A").next();
|
||||
|
||||
JsonObject json = new JsonParser().parse(response).getAsJsonObject();
|
||||
JsonObject json = JsonParser.parseString(response).getAsJsonObject();
|
||||
String name = json.get("name").getAsString();
|
||||
|
||||
JsonArray properties = json.getAsJsonArray("properties");
|
||||
@@ -139,14 +136,14 @@ public record Skin(@Nullable String name, @Nullable String value, @Nullable Stri
|
||||
|
||||
try
|
||||
{
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
||||
URL url = URI.create("https://api.mojang.com/users/profiles/minecraft/" + name).toURL();
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setReadTimeout(10000);
|
||||
|
||||
try(InputStream is = conn.getInputStream(); Scanner scanner = new Scanner(is))
|
||||
{
|
||||
String response = scanner.useDelimiter("\\A").next();
|
||||
JsonObject json = new JsonParser().parse(response).getAsJsonObject();
|
||||
JsonObject json = JsonParser.parseString(response).getAsJsonObject();
|
||||
String id = json.get("id").getAsString();
|
||||
return fetchSkin(UUID.fromString(id.replaceFirst(
|
||||
"(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})",
|
||||
@@ -175,9 +172,8 @@ public record Skin(@Nullable String name, @Nullable String value, @Nullable Stri
|
||||
if(skinCacheFile.containsKey(skinFile))
|
||||
return Optional.ofNullable(skinCacheFile.get(skinFile));
|
||||
|
||||
try
|
||||
try(HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build())
|
||||
{
|
||||
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
|
||||
String boundary = "----MineSkinBoundary" + System.currentTimeMillis();
|
||||
String CRLF = "\r\n";
|
||||
|
||||
@@ -199,7 +195,7 @@ public record Skin(@Nullable String name, @Nullable String value, @Nullable Stri
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
JsonObject obj = new JsonParser().parse(response.body()).getAsJsonObject();
|
||||
JsonObject obj = JsonParser.parseString(response.body()).getAsJsonObject();
|
||||
JsonObject texture = obj.getAsJsonObject("data").getAsJsonObject("texture");
|
||||
|
||||
String value = texture.get("value").getAsString();
|
||||
|
||||
@@ -79,6 +79,16 @@ public class Path implements ConfigurationSerializable
|
||||
return locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new path that is the reverse of this path.
|
||||
*
|
||||
* @return a new path that is the reverse of this path
|
||||
*/
|
||||
public @NotNull Path reverse()
|
||||
{
|
||||
return new Path(new ArrayList<>(locations).reversed(), new ArrayList<>(waypoints).reversed());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path as an unmodifiable list of {@link Vector} objects.
|
||||
*
|
||||
@@ -95,8 +105,8 @@ public class Path implements ConfigurationSerializable
|
||||
if(locations.isEmpty())
|
||||
return "Empty path";
|
||||
|
||||
Vector start = vectors.get(0);
|
||||
Vector end = vectors.get(vectors.size() - 1);
|
||||
Vector start = vectors.getFirst();
|
||||
Vector end = vectors.getLast();
|
||||
|
||||
return String.format("Start: [%.2f, %.2f, %.2f] -> End: [%.2f, %.2f, %.2f]",
|
||||
start.getX(), start.getY(), start.getZ(),
|
||||
|
||||
@@ -130,7 +130,7 @@ public class PathfindingUtils
|
||||
throw new PathfindingException("Could not find path between waypoint " + i + " and " + (i + 1));
|
||||
|
||||
if(!fullPathPoints.isEmpty() && !segment.isEmpty())
|
||||
segment.remove(0);
|
||||
segment.removeFirst();
|
||||
|
||||
fullPathPoints.addAll(segment.stream().map(Location::clone).toList());
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ public class PathTask extends BukkitRunnable
|
||||
*/
|
||||
private boolean finishPath()
|
||||
{
|
||||
Location last = path.getWaypoints().isEmpty() ? null : path.getWaypoints().get(path.getWaypoints().size() - 1);
|
||||
Location last = path.getWaypoints().isEmpty() ? null : path.getWaypoints().getLast();
|
||||
|
||||
if(last != null)
|
||||
{
|
||||
@@ -358,7 +358,7 @@ public class PathTask extends BukkitRunnable
|
||||
|
||||
if(event.changeRealLocation())
|
||||
{
|
||||
Location loc = path.getWaypoints().isEmpty() ? pathPoints.get(pathPoints.size() - 1) : path.getWaypoints().get(path.getWaypoints().size() - 1);
|
||||
Location loc = path.getWaypoints().isEmpty() ? pathPoints.getLast() : path.getWaypoints().getLast();
|
||||
npc.changeRealLocation(loc, getViewers());
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ public class PathTask extends BukkitRunnable
|
||||
targetYaw = normalizeAngle(targetYaw);
|
||||
|
||||
float diff = normalizeAngle(targetYaw - previousYaw);
|
||||
diff = Math.max(-15f, Math.min(15f, diff));
|
||||
diff = Math.clamp(diff, -15f, 15f);
|
||||
|
||||
float yaw = previousYaw + diff;
|
||||
previousYaw = yaw;
|
||||
@@ -780,8 +780,8 @@ public class PathTask extends BukkitRunnable
|
||||
|
||||
if(event.changeRealLocation())
|
||||
{
|
||||
World world = path.getWaypoints().isEmpty() ? pathPoints.get(pathPoints.size() - 1).getWorld() :
|
||||
path.getWaypoints().get(path.getWaypoints().size() - 1).getWorld();
|
||||
World world = path.getWaypoints().isEmpty() ? pathPoints.getLast().getWorld() :
|
||||
path.getWaypoints().getLast().getWorld();
|
||||
Location loc = new Location(world, currentPos.getX(), currentPos.getY(), currentPos.getZ());
|
||||
npc.changeRealLocation(loc, getViewers());
|
||||
}
|
||||
|
||||
@@ -397,9 +397,9 @@ public class Reflections
|
||||
{
|
||||
if(this == o)
|
||||
return true;
|
||||
if(!(o instanceof MethodKey methodKey))
|
||||
if(!(o instanceof MethodKey(Class<?> clazz1, String name, Class<?>[] types)))
|
||||
return false;
|
||||
return clazz.equals(methodKey.clazz) && methodName.equals(methodKey.methodName) && Arrays.equals(paramTypes, methodKey.paramTypes);
|
||||
return clazz.equals(clazz1) && methodName.equals(name) && Arrays.equals(paramTypes, types);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -419,9 +419,9 @@ public class Reflections
|
||||
{
|
||||
if(this == o)
|
||||
return true;
|
||||
if(!(o instanceof FieldKey fieldKey))
|
||||
if(!(o instanceof FieldKey(Class<?> clazz1, String name)))
|
||||
return false;
|
||||
return clazz.equals(fieldKey.clazz) && fieldName.equals(fieldKey.fieldName);
|
||||
return clazz.equals(clazz1) && fieldName.equals(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -440,9 +440,9 @@ public class Reflections
|
||||
{
|
||||
if(this == o)
|
||||
return true;
|
||||
if(!(o instanceof ConstructorKey constructorKey))
|
||||
if(!(o instanceof ConstructorKey(Class<?> clazz1, Class<?>[] types)))
|
||||
return false;
|
||||
return clazz.equals(constructorKey.clazz) && Arrays.equals(paramTypes, constructorKey.paramTypes);
|
||||
return clazz.equals(clazz1) && Arrays.equals(paramTypes, types);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,6 +100,42 @@ public class Var
|
||||
"fromComponent", component.getHandle()).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a json text into a {@link WrappedComponent} (NMS chat component equivalent). This method uses reflection to call the appropriate
|
||||
* {@code fromStringOrNull} method from CraftBukkit's CraftChatMessage utility, which handles parsing text into components.
|
||||
*
|
||||
* @param json The json text to convert. Must not be {@code null}.
|
||||
* @return A {@link WrappedComponent} representing the given text.
|
||||
* @throws java.util.NoSuchElementException If the reflection method is not found or cannot be invoked.
|
||||
*/
|
||||
public static @NotNull WrappedComponent fromJson(@NotNull String json)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V26_1))
|
||||
return WrappedComponent.fromHandle(
|
||||
Reflections.invokeStaticMethod("org.bukkit.craftbukkit." + Versions.getVersion().getPath() + ".util.CraftChatMessage",
|
||||
"fromJSONOrNull", json).get());
|
||||
return WrappedComponent.fromHandle(
|
||||
Reflections.invokeStaticMethod("org.bukkit.craftbukkit.util.CraftChatMessage",
|
||||
"fromJSONOrNull", json).get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link WrappedComponent} (NMS chat component equivalent) back into json format. This method uses reflection to call the appropriate
|
||||
* {@code fromComponent} method from CraftBukkit's CraftChatMessage utility.
|
||||
*
|
||||
* @param component The {@link WrappedComponent} to convert to json. Must not be {@code null}.
|
||||
* @return A json representation of the component.
|
||||
* @throws java.util.NoSuchElementException If the reflection method is not found or cannot be invoked.
|
||||
*/
|
||||
public static @NotNull String toJson(@NotNull WrappedComponent component)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V26_1))
|
||||
return (String) Reflections.invokeStaticMethod("org.bukkit.craftbukkit." + Versions.getVersion().getPath() + ".util.CraftChatMessage",
|
||||
"toJSON", component.getHandle()).get();
|
||||
return (String) Reflections.invokeStaticMethod("org.bukkit.craftbukkit.util.CraftChatMessage",
|
||||
"toJSON", component.getHandle()).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an unchecked cast of an object to a specified type. This method can be used to bypass Java's type checking at compile time, but it comes with
|
||||
* the risk of {@link ClassCastException} at runtime if the object is not an instance of the target type.
|
||||
|
||||
@@ -9,9 +9,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* The {@link Versions} enum represents the supported Minecraft server versions
|
||||
* and provides utility methods for working with version-specific paths and comparisons.
|
||||
* It helps in adapting the plugin's functionality to different server environments.
|
||||
* The {@link Versions} enum represents the supported Minecraft server versions and provides utility methods for working with version-specific paths and
|
||||
* comparisons. It helps in adapting the plugin's functionality to different server environments.
|
||||
*/
|
||||
public enum Versions
|
||||
{
|
||||
@@ -22,42 +21,52 @@ public enum Versions
|
||||
/**
|
||||
* Minecraft 1.17 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_17("v1_17_R1"),
|
||||
/**
|
||||
* Minecraft 1.18 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_18("v1_18_R1"),
|
||||
/**
|
||||
* Minecraft 1.18.2 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_18_2("v1_18_R2"),
|
||||
/**
|
||||
* Minecraft 1.19 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_19("v1_19_R1"),
|
||||
/**
|
||||
* Minecraft 1.19.1 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_19_1("v1_19_R1"),
|
||||
/**
|
||||
* Minecraft 1.19.3 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_19_3("v1_19_R2"),
|
||||
/**
|
||||
* Minecraft 1.19.4 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_19_4("v1_19_R3"),
|
||||
/**
|
||||
* Minecraft 1.20 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_20("v1_20_R1"),
|
||||
/**
|
||||
* Minecraft 1.20.2 version.
|
||||
*/
|
||||
@Deprecated(since = "2.4.0")
|
||||
V1_20_2("v1_20_R2"),
|
||||
/**
|
||||
* Minecraft 1.20.4 version.
|
||||
*/
|
||||
@Deprecated
|
||||
V1_20_4("v1_20_R3"),
|
||||
/**
|
||||
* Minecraft 1.20.6 version.
|
||||
@@ -94,7 +103,11 @@ public enum Versions
|
||||
/**
|
||||
* Minecraft 26.1 version.
|
||||
*/
|
||||
V26_1("v26_1");
|
||||
V26_1("v26_1"),
|
||||
/**
|
||||
* Minecraft 26.1 version.
|
||||
*/
|
||||
V26_2("v26_2");
|
||||
|
||||
/**
|
||||
* Caches the determined current server version to avoid repeated lookups.
|
||||
@@ -102,8 +115,7 @@ public enum Versions
|
||||
private static Versions VERSION;
|
||||
|
||||
/**
|
||||
* The NMS (Net Minecraft Server) path component corresponding to this version.
|
||||
* For example, "v1_17_R1" for Minecraft 1.17.
|
||||
* The NMS (Net Minecraft Server) path component corresponding to this version. For example, "v1_17_R1" for Minecraft 1.17.
|
||||
*/
|
||||
private final String path;
|
||||
|
||||
@@ -118,9 +130,8 @@ public enum Versions
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines and returns the current Minecraft server version based on the Bukkit server's package name.
|
||||
* The determined version is cached for later calls. If the version is not recognized,
|
||||
* the plugin will be disabled and a {@link VersionNotFound} exception will be thrown.
|
||||
* Determines and returns the current Minecraft server version based on the Bukkit server's package name. The determined version is cached for later calls.
|
||||
* If the version is not recognized, the plugin will be disabled and a {@link VersionNotFound} exception will be thrown.
|
||||
*
|
||||
* @return The {@link Versions} enum entry corresponding to the current server version. Must not be {@code null}.
|
||||
* @throws VersionNotFound If the current server version cannot be determined or is not supported.
|
||||
@@ -130,13 +141,31 @@ public enum Versions
|
||||
if(VERSION != null)
|
||||
return VERSION;
|
||||
|
||||
if(Bukkit.getServer().getBukkitVersion().startsWith("26.1"))
|
||||
return V26_1;
|
||||
VERSION = switch(Bukkit.getServer().getBukkitVersion())
|
||||
{
|
||||
case String v when v.startsWith("26.1") -> V26_1;
|
||||
case String v when v.startsWith("26.2") -> V26_2;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if(VERSION != null)
|
||||
return VERSION;
|
||||
|
||||
String nmsVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
||||
return VERSION = Arrays.stream(Versions.values())
|
||||
.filter(v -> v.path.equalsIgnoreCase(nmsVersion))
|
||||
.filter(versions ->
|
||||
{
|
||||
try
|
||||
{
|
||||
return !Versions.class.getDeclaredField(versions.name()).isAnnotationPresent(Deprecated.class);
|
||||
}
|
||||
catch(NoSuchFieldException e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.reduce((a, b) -> Bukkit.getBukkitVersion().startsWith("1.19.1") ? Versions.V1_19_1 : Versions.V1_19)
|
||||
.orElseThrow(() ->
|
||||
{
|
||||
@@ -146,9 +175,8 @@ public enum Versions
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of {@link Versions} enum entries that fall inclusively between
|
||||
* two specified versions (based on their ordinal values).
|
||||
* The {@code NONE} version is excluded from the result.
|
||||
* Returns an array of {@link Versions} enum entries that fall inclusively between two specified versions (based on their ordinal values). The {@code NONE}
|
||||
* version is excluded from the result.
|
||||
*
|
||||
* @param versions1 The starting version (inclusive). Must not be {@code null}.
|
||||
* @param versions2 The ending version (inclusive). Must not be {@code null}.
|
||||
@@ -163,8 +191,7 @@ public enum Versions
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current server version is numerically smaller than a specified version.
|
||||
* This comparison is based on the ordinal value of the enum entries.
|
||||
* Checks if the current server version is numerically smaller than a specified version. This comparison is based on the ordinal value of the enum entries.
|
||||
*
|
||||
* @param versions The version to compare against. Must not be {@code null}.
|
||||
* @return {@code true} if the current version is smaller, {@code false} otherwise.
|
||||
@@ -175,8 +202,7 @@ public enum Versions
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current server version is contained within a given {@link Mapping}.
|
||||
* A mapping can specify either a fixed version or a range of versions.
|
||||
* Checks if the current server version is contained within a given {@link Mapping}. A mapping can specify either a fixed version or a range of versions.
|
||||
*
|
||||
* @param mapping The {@link Mapping} to check against. Must not be {@code null}.
|
||||
* @return {@code true} if the current version matches the mapping, {@code false} otherwise.
|
||||
@@ -200,8 +226,7 @@ public enum Versions
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the version, with underscores replaced by dots for better readability.
|
||||
* For example, {@code V1_17} becomes "V1.17".
|
||||
* Returns the name of the version, with underscores replaced by dots for better readability. For example, {@code V1_17} becomes "V1.17".
|
||||
*
|
||||
* @return The formatted name of the version as a {@link String}. Must not be {@code null}.
|
||||
*/
|
||||
|
||||
@@ -9,96 +9,96 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.ChatFormatting")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.EnumChatFormat")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.ChatFormatting")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.EnumChatFormat")
|
||||
public enum ChatFormat implements Wrapper.EnumWrapper, Serializable
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BLACK")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BLACK")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
BLACK(ChatColor.BLACK),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DARK_BLUE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DARK_BLUE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
DARK_BLUE(ChatColor.DARK_BLUE),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DARK_GREEN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DARK_GREEN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
DARK_GREEN(ChatColor.DARK_GREEN),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DARK_AQUA")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DARK_AQUA")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
DARK_AQUA(ChatColor.DARK_AQUA),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DARK_RED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DARK_RED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
DARK_RED(ChatColor.DARK_RED),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DARK_PURPLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DARK_PURPLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "f")
|
||||
DARK_PURPLE(ChatColor.DARK_PURPLE),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "GOLD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "GOLD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "g")
|
||||
GOLD(ChatColor.GOLD),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "GRAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "GRAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "h")
|
||||
GRAY(ChatColor.GRAY),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DARK_GRAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DARK_GRAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "i")
|
||||
DARK_GRAY(ChatColor.DARK_GRAY),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BLUE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BLUE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "j")
|
||||
BLUE(ChatColor.BLUE),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "GREEN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "GREEN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "k")
|
||||
GREEN(ChatColor.GREEN),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "AQUA")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "l")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "AQUA")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "l")
|
||||
AQUA(ChatColor.AQUA),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "RED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "m")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "RED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "m")
|
||||
RED(ChatColor.RED),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "LIGHT_PURPLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "LIGHT_PURPLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "n")
|
||||
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "YELLOW")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "o")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "YELLOW")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "o")
|
||||
YELLOW(ChatColor.YELLOW),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "WHITE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "p")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "WHITE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "p")
|
||||
WHITE(ChatColor.WHITE),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OBFUSCATED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "q")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OBFUSCATED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "q")
|
||||
OBFUSCATED(ChatColor.MAGIC),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BOLD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "r")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BOLD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "r")
|
||||
BOLD(ChatColor.BOLD),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "STRIKETHROUGH")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "s")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "STRIKETHROUGH")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "s")
|
||||
STRIKETHROUGH(ChatColor.STRIKETHROUGH),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UNDERLINE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "t")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UNDERLINE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "t")
|
||||
UNDERLINE(ChatColor.UNDERLINE),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ITALIC")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "u")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ITALIC")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "u")
|
||||
ITALIC(ChatColor.ITALIC),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "RESET")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "v")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "RESET")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "v")
|
||||
RESET(ChatColor.RESET);
|
||||
|
||||
private final ChatColor color;
|
||||
|
||||
@@ -7,31 +7,31 @@ import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.ConnectionProtocol")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.EnumProtocol")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.ConnectionProtocol")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.EnumProtocol")
|
||||
public enum ConnectionProtocol implements Wrapper.EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "HANDSHAKE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "HANDSHAKE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
HANDSHAKE,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "PLAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "PLAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
PLAY,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "STATUS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "STATUS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
STATUS,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "LOGIN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "LOGIN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
LOGIN,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CONFIGURATION")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CONFIGURATION")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
CONFIGURATION;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public @NotNull Object codecData(@NotNull WrappedConnection.WrappedNetworkManager.PacketFlow packetFlow)
|
||||
{
|
||||
return Reflections.invokeMethod(getHandle(), getPath(), packetFlow.getHandle()).get();
|
||||
|
||||
@@ -5,39 +5,39 @@ import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.entity.EquipmentSlot")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.entity.EnumItemSlot")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.entity.EquipmentSlot")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.entity.EnumItemSlot")
|
||||
public enum EquipmentSlot implements Wrapper.EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "MAINHAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "MAINHAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
MAINHAND,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OFFHAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OFFHAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
OFFHAND,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "FEET")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "FEET")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
FEET,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "LEGS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "LEGS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
LEGS,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CHEST")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CHEST")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
CHEST,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "HEAD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "HEAD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "f")
|
||||
HEAD,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BODY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BODY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "g")
|
||||
BODY,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SADDLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SADDLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "h")
|
||||
SADDLE;
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.InteractionHand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.EnumHand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.InteractionHand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.EnumHand")
|
||||
public enum InteractionHand implements Wrapper.EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "MAIN_HAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "MAIN_HAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
MAIN_HAND,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OFF_HAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OFF_HAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
OFF_HAND;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,84 +9,80 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.entity.Pose")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.entity.EntityPose")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.entity.Pose")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.entity.EntityPose")
|
||||
public enum Pose implements Wrapper.EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "STANDING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "STANDING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
STANDING(getBukkit("STANDING"), Material.ARMOR_STAND),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "FALL_FLYING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "FALL_FLYING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
FALL_FLYING(getBukkit("FALL_FLYING"), Material.FEATHER),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SLEEPING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SLEEPING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
SLEEPING(getBukkit("SLEEPING"), Material.RED_BED),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SWIMMING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SWIMMING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
SWIMMING(getBukkit("SWIMMING"), Material.WATER_BUCKET),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SPIN_ATTACK")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SPIN_ATTACK")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
SPIN_ATTACK(getBukkit("SPIN_ATTACK"), Material.TRIDENT),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CROUCHING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CROUCHING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "f")
|
||||
CROUCHING(getBukkit("SNEAKING"), Material.LEATHER_BOOTS),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "LONG_JUMPING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "LONG_JUMPING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "g")
|
||||
LONG_JUMPING(getBukkit("LONG_JUMPING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DYING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "h")
|
||||
DYING(getBukkit("DYING"), Versions.isCurrentVersionSmallerThan(Versions.V1_19_4) ? Material.ROTTEN_FLESH : null),
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DYING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "h")
|
||||
DYING(getBukkit("DYING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CROAKING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21_11), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CROAKING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "i")
|
||||
CROAKING(getBukkit("CROAKING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "USING_TONGUE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21_11), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "USING_TONGUE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "j")
|
||||
USING_TONGUE(getBukkit("USING_TONGUE"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SITTING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "k")
|
||||
SITTING(getBukkit("SITTING"), Versions.isCurrentVersionSmallerThan(Versions.V1_19_4) ? null : Material.OAK_STAIRS),
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SITTING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "k")
|
||||
SITTING(getBukkit("SITTING"), Material.OAK_STAIRS),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ROARING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "l")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ROARING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "l")
|
||||
ROARING(getBukkit("ROARING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SNIFFING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "m")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "l")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SNIFFING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "m")
|
||||
SNIFFING(getBukkit("SNIFFING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "EMERGING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "m")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "EMERGING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "n")
|
||||
EMERGING(getBukkit("EMERGING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DIGGING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "o")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DIGGING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "o")
|
||||
DIGGING(getBukkit("DIGGING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SLIDING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_4, to = Versions.V1_21_11), path = "p")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SLIDING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "p")
|
||||
SLIDING(getBukkit("SLIDING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SHOOTING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_4, to = Versions.V1_21_11), path = "q")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SHOOTING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "q")
|
||||
SHOOTING(getBukkit("SHOOTING"), null),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "INHALING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_4, to = Versions.V1_21_11), path = "r")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "INHALING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "r")
|
||||
INHALING(getBukkit("INHALING"), null);
|
||||
|
||||
private final org.bukkit.entity.Pose bukkitPose;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package de.eisi05.npc.api.wrapper.objects;
|
||||
|
||||
import de.eisi05.npc.api.utils.Reflections;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.entity.decoration.ArmorStand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.entity.decoration.EntityArmorStand")
|
||||
public class WrappedArmorStand extends WrappedEntity.WrappedNameTag<ArmorStand>
|
||||
{
|
||||
private WrappedArmorStand(Object handle)
|
||||
{
|
||||
super(handle);
|
||||
}
|
||||
|
||||
public static WrappedArmorStand create(World world)
|
||||
{
|
||||
return new WrappedArmorStand(
|
||||
createInstance(WrappedArmorStand.class, EntityTypes.ARMOR_STAND, Reflections.invokeMethod(world, "getHandle").get()));
|
||||
}
|
||||
|
||||
public WrappedEntityData applyData(WrappedComponent component)
|
||||
{
|
||||
WrappedEntityData data = getEntityData();
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BYTE.create(0), (byte) 0x20);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.OPTIONAL_CHAT_COMPONENT.create(2), Optional.of(component.getHandle()));
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BOOLEAN.create(4), true);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BYTE.create(15), (byte) 0x10);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.entity.ai.attributes.AttributeInstance")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.entity.ai.attributes.AttributeInstance")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.entity.ai.attributes.AttributeModifiable")
|
||||
public class WrappedAttributeInstance extends Wrapper
|
||||
{
|
||||
@@ -20,18 +20,18 @@ public class WrappedAttributeInstance extends Wrapper
|
||||
super(createInstance(WrappedAttributeInstance.class, holder, consumer));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setBaseValue")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setBaseValue")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void setBaseValue(double value)
|
||||
{
|
||||
invokeWrappedMethod(value);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.entity.ai.attributes.Attributes")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.entity.ai.attributes.Attributes")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.entity.ai.attributes.GenericAttributes")
|
||||
public static class Attributes extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SCALE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SCALE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V1_21_11), path = "A")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_9), path = "z")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21, to = Versions.V1_21_5), path = "y")
|
||||
|
||||
@@ -5,7 +5,7 @@ import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V26_1), path = "net.minecraft.server.level.ClientInformation")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.server.level.ClientInformation")
|
||||
public class WrappedClientInformation extends Wrapper
|
||||
{
|
||||
private WrappedClientInformation(Object handle)
|
||||
@@ -13,8 +13,8 @@ public class WrappedClientInformation extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "createDefault")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "createDefault")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public static @NotNull WrappedClientInformation createDefault()
|
||||
{
|
||||
return new WrappedClientInformation(invokeStaticWrappedMethod());
|
||||
|
||||
@@ -6,8 +6,8 @@ import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.commands.CommandSourceStack")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.commands.CommandListenerWrapper")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.commands.CommandSourceStack")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.commands.CommandListenerWrapper")
|
||||
public class WrappedCommandSourceStack extends Wrapper
|
||||
{
|
||||
public WrappedCommandSourceStack(Object handle)
|
||||
@@ -15,15 +15,15 @@ public class WrappedCommandSourceStack extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "getBukkitSender")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "getBukkitSender")
|
||||
public CommandSender getBukkitSender()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withMaximumPermission")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withMaximumPermission")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_9), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_9), path = "a")
|
||||
public @NotNull WrappedCommandSourceStack withMaximumPermission()
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_21_11))
|
||||
@@ -31,21 +31,21 @@ public class WrappedCommandSourceStack extends Wrapper
|
||||
return new WrappedCommandSourceStack(invokeWrappedMethod(WrappedPermissionSet.ALL.getHandle()));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withSuppressedOutput")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withSuppressedOutput")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @NotNull WrappedCommandSourceStack withSuppressedOutput()
|
||||
{
|
||||
return new WrappedCommandSourceStack(invokeWrappedMethod());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V26_1), path = "net.minecraft.server.permissions.PermissionSet")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V26_2), path = "net.minecraft.server.permissions.PermissionSet")
|
||||
private static class WrappedPermissionSet extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "NO_PERMISSIONS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "NO_PERMISSIONS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V1_21_11), path = "g")
|
||||
public static final WrappedPermissionSet NO = new WrappedPermissionSet(getStaticWrappedFieldValue("NO").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ALL_PERMISSIONS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ALL_PERMISSIONS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V1_21_11), path = "h")
|
||||
public static final WrappedPermissionSet ALL = new WrappedPermissionSet(getStaticWrappedFieldValue("ALL").orElse(null));
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.function.UnaryOperator;
|
||||
* A wrapper class for Minecraft's chat component system, providing a type-safe way to create and manipulate
|
||||
* chat messages with formatting, click events, hover events, and other rich text features.
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.Component")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.chat.IChatBaseComponent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.Component")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.IChatBaseComponent")
|
||||
public class WrappedComponent extends Wrapper
|
||||
{
|
||||
/**
|
||||
@@ -56,8 +56,8 @@ public class WrappedComponent extends Wrapper
|
||||
* @param text The text to display (can be null for empty component)
|
||||
* @return A new WrappedComponent containing the specified text
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "literal")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "literal")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public static @NotNull WrappedComponent create(@Nullable String text)
|
||||
{
|
||||
return new WrappedComponent(text == null ? CommonComponents.EMPTY : invokeStaticWrappedMethod(text));
|
||||
@@ -83,8 +83,8 @@ public class WrappedComponent extends Wrapper
|
||||
* @param format One or more ChatFormat values to apply (e.g., BOLD, ITALIC, UNDERLINE)
|
||||
* @return This component for method chaining
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withStyle")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withStyle")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @NotNull WrappedComponent setFormats(@NotNull ChatFormat... format)
|
||||
{
|
||||
if(format.length == 0)
|
||||
@@ -119,9 +119,8 @@ public class WrappedComponent extends Wrapper
|
||||
* @param clickEvent The click event to add
|
||||
* @return This component for method chaining
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withStyle")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "format")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withStyle")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @NotNull WrappedComponent withClickEvent(@NotNull ClickEvent clickEvent)
|
||||
{
|
||||
invokeWrappedMethod((UnaryOperator<Object>) o -> new Style(o).withClickEvent(clickEvent).getHandle());
|
||||
@@ -134,9 +133,8 @@ public class WrappedComponent extends Wrapper
|
||||
* @param hoverEvent The hover event to add
|
||||
* @return This component for method chaining
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withStyle")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "format")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withStyle")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @NotNull WrappedComponent withHoverEvent(@NotNull HoverEvent hoverEvent)
|
||||
{
|
||||
invokeWrappedMethod((UnaryOperator<Object>) o -> new Style(o).withHoverEvent(hoverEvent).getHandle());
|
||||
@@ -149,10 +147,8 @@ public class WrappedComponent extends Wrapper
|
||||
* @param wrappedComponent The component to append
|
||||
* @return This component for method chaining
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "append")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_1, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_19), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "addSibling")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "append")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public @NotNull WrappedComponent append(WrappedComponent wrappedComponent)
|
||||
{
|
||||
invokeWrappedMethod(wrappedComponent);
|
||||
@@ -164,10 +160,8 @@ public class WrappedComponent extends Wrapper
|
||||
*
|
||||
* @return A new WrappedComponent that is a copy of this one
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "copy")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_4, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_20_2), path = "e")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "mutableCopy")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "copy")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "f")
|
||||
public @NotNull WrappedComponent copy()
|
||||
{
|
||||
return new WrappedComponent(invokeWrappedMethod());
|
||||
@@ -205,13 +199,11 @@ public class WrappedComponent extends Wrapper
|
||||
return new SerializedComponent(toLegacy(true));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V26_1), path = "net.minecraft.network.chat.CommonComponents")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "net.minecraft.network.chat.ChatComponentText")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.network.chat.CommonComponents")
|
||||
private static class CommonComponents extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "EMPTY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "EMPTY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
private static final Object EMPTY = getStaticWrappedFieldValue("EMPTY").orElse(null);
|
||||
|
||||
private CommonComponents()
|
||||
@@ -220,8 +212,8 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable")
|
||||
public static class ClickEvent extends Wrapper
|
||||
{
|
||||
private ClickEvent(Object handle)
|
||||
@@ -236,41 +228,41 @@ public class WrappedComponent extends Wrapper
|
||||
return action.function.apply(value);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$Action")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$EnumClickAction")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$Action")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$EnumClickAction")
|
||||
public enum ClickAction implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPEN_URL")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPEN_URL")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
OPEN_URL(o -> new OpenUrl((URI) o)),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPEN_FILE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPEN_FILE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
OPEN_FILE(o -> new OpenFile((String) o)),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "RUN_COMMAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "RUN_COMMAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
RUN_COMMAND(o -> new RunCommand((String) o)),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SUGGEST_COMMAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SUGGEST_COMMAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
SUGGEST_COMMAND(o -> new SuggestCommand((String) o)),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SHOW_DIALOG")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SHOW_DIALOG")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "e")
|
||||
SHOW_DIALOG(ShowDialog::new),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CHANGE_PAGE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CHANGE_PAGE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_5), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_5), path = "e")
|
||||
CHANGE_PAGE(o -> new ChangePage((int) o)),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "COPY_TO_CLIPBOARD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "COPY_TO_CLIPBOARD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_5), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_5), path = "f")
|
||||
COPY_TO_CLIPBOARD(o -> new CopyToClipboard((String) o)),
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CUSTOM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CUSTOM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "h")
|
||||
CUSTOM(o -> new Custom(((Object[]) o)[0], (Optional<?>) ((Object[]) o)[1]));
|
||||
|
||||
@@ -288,7 +280,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$OpenUrl")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$OpenUrl")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$OpenUrl")
|
||||
private static class OpenUrl extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -298,7 +290,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$OpenFile")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$OpenFile")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$OpenFile")
|
||||
private static class OpenFile extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -308,7 +300,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$RunCommand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$RunCommand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$RunCommand")
|
||||
private static class RunCommand extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -318,7 +310,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$SuggestCommand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$SuggestCommand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$SuggestCommand")
|
||||
private static class SuggestCommand extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -328,7 +320,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$ChangePage")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$ChangePage")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$ChangePage")
|
||||
private static class ChangePage extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -338,7 +330,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$CopyToClipboard")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$CopyToClipboard")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$CopyToClipboard")
|
||||
private static class CopyToClipboard extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -348,7 +340,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$ShowDialog")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$ShowDialog")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$h")
|
||||
private static class ShowDialog extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -358,7 +350,7 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.ClickEvent$Custom")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.ClickEvent$Custom")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatClickable$d")
|
||||
private static class Custom extends WrappedComponent.ClickEvent
|
||||
{
|
||||
@@ -369,8 +361,8 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.HoverEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatHoverable")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.HoverEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatHoverable")
|
||||
public static class HoverEvent extends Wrapper
|
||||
{
|
||||
private HoverEvent(Object handle)
|
||||
@@ -385,7 +377,7 @@ public class WrappedComponent extends Wrapper
|
||||
return new ShowText(component);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.HoverEvent$ShowText")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.HoverEvent$ShowText")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatHoverable$e")
|
||||
private static class ShowText extends HoverEvent
|
||||
{
|
||||
@@ -395,12 +387,12 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.HoverEvent$Action")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatHoverable$EnumHoverAction")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.HoverEvent$Action")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatHoverable$EnumHoverAction")
|
||||
private static class HoverAction extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SHOW_TEXT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SHOW_TEXT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
private static final Object SHOW_TEXT = getStaticWrappedFieldValue("SHOW_TEXT").orElse(null);
|
||||
|
||||
private HoverAction()
|
||||
@@ -428,8 +420,8 @@ public class WrappedComponent extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.chat.Style")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatModifier")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.chat.Style")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.chat.ChatModifier")
|
||||
public static class Style extends Wrapper
|
||||
{
|
||||
private Style(Object handle)
|
||||
@@ -437,17 +429,15 @@ public class WrappedComponent extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withClickEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setChatClickable")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withClickEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @NotNull Style withClickEvent(@NotNull ClickEvent clickEvent)
|
||||
{
|
||||
return new Style(invokeWrappedMethod(clickEvent));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "withHoverEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setChatHoverable")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "withHoverEvent")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @NotNull Style withHoverEvent(@NotNull HoverEvent hoverEvent)
|
||||
{
|
||||
return new Style(invokeWrappedMethod(hoverEvent));
|
||||
|
||||
@@ -4,17 +4,13 @@ import com.mojang.authlib.GameProfile;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import de.eisi05.npc.api.wrapper.enums.ConnectionProtocol;
|
||||
import de.eisi05.npc.api.wrapper.packets.PacketWrapper;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.server.network.ServerGamePacketListenerImpl")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "net.minecraft.server.network.PlayerConnection")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "net.minecraft.network.PlayerConnection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.server.network.ServerGamePacketListenerImpl")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.server.network.PlayerConnection")
|
||||
public class WrappedConnection extends Wrapper
|
||||
{
|
||||
WrappedConnection(Object handle)
|
||||
@@ -28,28 +24,23 @@ public class WrappedConnection extends Wrapper
|
||||
super(createInstance(WrappedConnection.class, server, networkManager, player, commonListenerCookie));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "sendPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_20), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "sendPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "sendPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public void sendPacket(@NotNull PacketWrapper packet)
|
||||
{
|
||||
invokeWrappedMethod(packet);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_20_4), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_3), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "c")
|
||||
public @NotNull WrappedNetworkManager networkManager()
|
||||
{
|
||||
return new WrappedNetworkManager(getWrappedFieldValue());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.Connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.NetworkManager")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.Connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.NetworkManager")
|
||||
public static class WrappedNetworkManager extends Wrapper
|
||||
{
|
||||
private WrappedNetworkManager(Object handle)
|
||||
@@ -59,50 +50,35 @@ public class WrappedConnection extends Wrapper
|
||||
|
||||
public static @NotNull WrappedNetworkManager create(@NotNull PacketFlow packetFlow)
|
||||
{
|
||||
WrappedNetworkManager networkManager = new WrappedNetworkManager(createInstance(WrappedNetworkManager.class, packetFlow));
|
||||
|
||||
if(Versions.getVersion() != Versions.V1_20_2 && Versions.getVersion() != Versions.V1_20_4)
|
||||
return networkManager;
|
||||
|
||||
NioSocketChannel socketChannel = new NioSocketChannel();
|
||||
socketChannel.attr(AttributeKey.valueOf("serverbound_protocol")).set(ConnectionProtocol.PLAY.codecData(PacketFlow.SERVERBOUND));
|
||||
socketChannel.attr(AttributeKey.valueOf("clientbound_protocol")).set(ConnectionProtocol.PLAY.codecData(PacketFlow.SERVERBOUND));
|
||||
|
||||
networkManager.setChannel(socketChannel);
|
||||
|
||||
return networkManager;
|
||||
return new WrappedNetworkManager(createInstance(WrappedNetworkManager.class, packetFlow));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "channel")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "channel")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V1_21_11), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_9), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18_2, to = Versions.V1_20), path = "m")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_9), path = "n")
|
||||
public @NotNull Channel channel()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "channel")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "channel")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V1_21_11), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_9), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18_2, to = Versions.V1_20), path = "m")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_9), path = "n")
|
||||
public void setChannel(@Nullable Channel channel)
|
||||
{
|
||||
setWrappedFieldValue(channel);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.PacketFlow")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.EnumProtocolDirection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.PacketFlow")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.EnumProtocolDirection")
|
||||
public enum PacketFlow implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "SERVERBOUND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "SERVERBOUND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
SERVERBOUND,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "CLIENTBOUND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "CLIENTBOUND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
CLIENTBOUND;
|
||||
|
||||
@Override
|
||||
@@ -113,7 +89,7 @@ public class WrappedConnection extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V26_1), path = "net.minecraft.server.network.CommonListenerCookie")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.server.network.CommonListenerCookie")
|
||||
public static class CommonListenerCookie extends Wrapper
|
||||
{
|
||||
public CommonListenerCookie(@NotNull GameProfile profile, int latency, boolean transferred)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package de.eisi05.npc.api.wrapper.objects;
|
||||
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.entity.boss.enderdragon.EnderDragon")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.entity.boss.EntityEnderDragon")
|
||||
public class WrappedEnderDragon extends WrappedEntity<EnderDragon>
|
||||
{
|
||||
WrappedEnderDragon(Object handle)
|
||||
{
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "subEntities")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "cF")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "cD")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "cu")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_5), path = "bS")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_4), path = "cj")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_2), path = "ck")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21), path = "co")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "ck")
|
||||
public List<Integer> getSubIds()
|
||||
{
|
||||
Object[] subParts = getWrappedFieldValue();
|
||||
return Arrays.stream(subParts).map(object -> new WrappedEntity<>(object).getId()).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.eisi05.npc.api.wrapper.objects;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import de.eisi05.npc.api.objects.NameDisplayOptions;
|
||||
import de.eisi05.npc.api.utils.Reflections;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
@@ -16,7 +17,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.entity.Entity")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.world.entity.Entity")
|
||||
public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
{
|
||||
public String data = "{}";
|
||||
@@ -57,21 +58,20 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
return false;
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "getBukkitEntity")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "getBukkitEntity")
|
||||
public @NotNull T getBukkitPlayer()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "absSnapTo")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setLocation")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "absSnapTo")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void moveTo(@NotNull Location location)
|
||||
{
|
||||
invokeWrappedMethod(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getEntityData")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getEntityData")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "aD")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "aC")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "au")
|
||||
@@ -79,60 +79,36 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_4), path = "au")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21), path = "ar")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "ap")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "an")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "al")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20), path = "aj")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "al")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_19_1), path = "ai")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getDataWatcher")
|
||||
public @NotNull WrappedEntityData getEntityData()
|
||||
{
|
||||
return new WrappedEntityData(invokeWrappedMethod());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "passengers")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "passengers")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "aS")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "aR")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_5), path = "u")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_4), path = "q")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "p")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "r")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_19_3), path = "au")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "at")
|
||||
public void setPassengers(WrappedEntity<?>... entities)
|
||||
{
|
||||
setWrappedFieldValue(ImmutableList.copyOf(Arrays.stream(entities).map(wrappedEntity -> wrappedEntity.handle).toList()));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "level")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "level")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "ao")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "an")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "ai")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_5), path = "cU")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "cN")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "cK")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "cJ")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "cH")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_4), path = "cG")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "cH")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_1), path = "cC")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19), path = "cD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_18_2), path = "cA")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getWorld")
|
||||
public @NotNull Object getServer()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getAddEntityPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getAddEntityPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "dl")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "dj")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "di")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20), path = "S")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "T")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_19_1), path = "S")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getPacket")
|
||||
public @NotNull PacketWrapper getAddEntityPacket()
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_21))
|
||||
@@ -140,19 +116,12 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
return new CustomPacket(invokeWrappedMethod(new WrappedEntityTrackerEntry(this)));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getBoundingBox")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getBoundingBox")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "dj")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "de")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "cV")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_5), path = "cR")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "cK")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "cH")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "cG")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "cE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_19_4), path = "cD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "cz")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_18_2), path = "cw")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getBoundingBox")
|
||||
public BoundingBox getBoundingBox()
|
||||
{
|
||||
return new BoundingBox(invokeWrappedMethod());
|
||||
@@ -163,7 +132,7 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
return defaultBoundingBox;
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setId")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setId")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "e")
|
||||
public void setId(int id)
|
||||
{
|
||||
@@ -180,11 +149,11 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
return getBukkitPlayer().getWorld();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V26_1), path = "net.minecraft.world.entity.Entity$RemovalReason")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.world.entity.Entity$RemovalReason")
|
||||
enum RemovalReason implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DISCARDED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DISCARDED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
DISCARDED;
|
||||
|
||||
@Override
|
||||
@@ -194,10 +163,10 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V26_1), path = "net.minecraft.world.entity.EntitySpawnReason")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V26_2), path = "net.minecraft.world.entity.EntitySpawnReason")
|
||||
enum SpawnReason implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "LOAD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "LOAD")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_11), path = "r")
|
||||
LOAD;
|
||||
|
||||
@@ -208,10 +177,10 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V26_1), path = "net.minecraft.world.entity.EntityProcessor")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_11, to = Versions.V26_2), path = "net.minecraft.world.entity.EntityProcessor")
|
||||
static class EntityProcessor extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "NOP")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "NOP")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "a")
|
||||
public static final Object NOP = getStaticWrappedFieldValue("NOP").orElse(null);
|
||||
|
||||
@@ -221,19 +190,19 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.entity.EntityType")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.entity.EntityTypes")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_2, to = Versions.V26_2), path = "net.minecraft.world.entity.EntityTypes")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V26_1), path = "net.minecraft.world.entity.EntityType")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.entity.EntityTypes")
|
||||
public static class EntityTypes extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ARMOR_STAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ARMOR_STAND")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_6), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_4), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "d")
|
||||
public static final Object ARMOR_STAND = getStaticWrappedFieldValue("ARMOR_STAND").orElse(null);
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "TEXT_DISPLAY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "TEXT_DISPLAY")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "bD")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "bA")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "bx")
|
||||
@@ -241,18 +210,26 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_4), path = "bu")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_2), path = "bv")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "bb")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "aY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_2), path = "aX")
|
||||
public static final Object TEXT_DISPLAY = getStaticWrappedFieldValue("TEXT_DISPLAY").orElse(null);
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "INTERACTION")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "at")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "as")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "aq")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_5), path = "ap")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_4), path = "ao")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_2), path = "ap")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "ae")
|
||||
public static final Object INTERACTION = getStaticWrappedFieldValue("INTERACTION").orElse(null);
|
||||
|
||||
private EntityTypes()
|
||||
{
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.phys.AABB")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.phys.AxisAlignedBB")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.phys.AABB")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.phys.AxisAlignedBB")
|
||||
public static class BoundingBox extends Wrapper
|
||||
{
|
||||
private BoundingBox(Object handle)
|
||||
@@ -260,22 +237,22 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getXsize")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getXsize")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public double getXSize()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getYsize")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getYsize")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
public double getYSize()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getZsize")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getZsize")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
public double getZSize()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
@@ -289,6 +266,6 @@ public class WrappedEntity<T extends Entity> extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
public abstract WrappedEntityData applyData(WrappedComponent component);
|
||||
public abstract WrappedEntityData applyData(WrappedComponent component, @NotNull NameDisplayOptions displayOptions);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.syncher.SynchedEntityData")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcher")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.syncher.SynchedEntityData")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcher")
|
||||
public class WrappedEntityData extends Wrapper
|
||||
{
|
||||
WrappedEntityData(Object handle)
|
||||
@@ -22,47 +22,43 @@ public class WrappedEntityData extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "set")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "set")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_20_4), path = "b")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "set")
|
||||
public <T> void set(@NotNull EntityDataAccessor<T> accessor, @Nullable T value)
|
||||
{
|
||||
invokeWrappedMethod(accessor, value);
|
||||
markDirty(accessor);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "get")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "get")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "get")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public <T> @Nullable T get(@NotNull EntityDataAccessor<T> accessor)
|
||||
{
|
||||
return invokeWrappedMethod(accessor);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "packDirty")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "packDirty")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public @NotNull List<?> packDirty()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "markDirty")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "markDirty")
|
||||
public <T> void markDirty(@NotNull EntityDataAccessor<T> accessor)
|
||||
{
|
||||
invokeWrappedMethod(accessor);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getNonDefaultValues")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getAll")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getNonDefaultValues")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
public List<?> getAll()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.syncher.EntityDataAccessor")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcherObject")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.syncher.EntityDataAccessor")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcherObject")
|
||||
public static class EntityDataAccessor<T> extends Wrapper
|
||||
{
|
||||
private EntityDataAccessor(Object handle)
|
||||
@@ -76,8 +72,8 @@ public class WrappedEntityData extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.syncher.EntityDataSerializer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcherSerializer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.syncher.EntityDataSerializer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcherSerializer")
|
||||
public static class EntityDataSerializer<T> extends Wrapper
|
||||
{
|
||||
private EntityDataSerializer(Object handle)
|
||||
@@ -91,192 +87,145 @@ public class WrappedEntityData extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.syncher.EntityDataSerializers")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcherRegistry")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.syncher.EntityDataSerializers")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.syncher.DataWatcherRegistry")
|
||||
public static class EntityDataSerializers extends Wrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BYTE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BYTE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public static final EntityDataSerializer<Byte> BYTE = new EntityDataSerializer<>(getStaticWrappedFieldValue("BYTE").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "INT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "INT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_4, to = Versions.V1_21_11), path = "b")
|
||||
public static final EntityDataSerializer<Integer> INT = new EntityDataSerializer<>(getStaticWrappedFieldValue("INT").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "LONG")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "LONG")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
public static final EntityDataSerializer<Long> LONG = new EntityDataSerializer<>(getStaticWrappedFieldValue("LONG").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "FLOAT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "FLOAT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
public static final EntityDataSerializer<Float> FLOAT = new EntityDataSerializer<>(getStaticWrappedFieldValue("FLOAT").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "STRING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "STRING")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
public static final EntityDataSerializer<String> STRING = new EntityDataSerializer<>(getStaticWrappedFieldValue("STRING").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "COMPONENT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "COMPONENT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "f")
|
||||
public static final EntityDataSerializer<?> CHAT_COMPONENT = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("CHAT_COMPONENT").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPTIONAL_COMPONENT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPTIONAL_COMPONENT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "g")
|
||||
public static final EntityDataSerializer<Optional<?>> OPTIONAL_CHAT_COMPONENT = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_CHAT_COMPONENT").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ITEM_STACK")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ITEM_STACK")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "h")
|
||||
public static final EntityDataSerializer<?> ITEM_STACK = new EntityDataSerializer<>(getStaticWrappedFieldValue("ITEM_STACK").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BLOCK_STATE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_21_11), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BLOCK_STATE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "i")
|
||||
public static final EntityDataSerializer<?> BLOCK_DATA = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("BLOCK_DATA").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPTIONAL_BLOCK_STATE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_21_11), path = "j")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPTIONAL_BLOCK_STATE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "j")
|
||||
public static final EntityDataSerializer<Optional<?>> OPTIONAL_BLOCK_DATA = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_BLOCK_DATA").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BOOLEAN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_21_11), path = "k")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BOOLEAN")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "k")
|
||||
public static final EntityDataSerializer<Boolean> BOOLEAN = new EntityDataSerializer<>(getStaticWrappedFieldValue("BOOLEAN").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "PARTICLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_21_11), path = "l")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "PARTICLE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "l")
|
||||
public static final EntityDataSerializer<?> PARTICLE_PARAM = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("PARTICLE_PARAM").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "PARTICLES")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "PARTICLES")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "m")
|
||||
public static final EntityDataSerializer<List<?>> PARTICLE_PARAM_LIST = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("PARTICLE_PARAM_LIST").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ROTATIONS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ROTATIONS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "m")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "l")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "k")
|
||||
public static final EntityDataSerializer<?> VECTOR = new EntityDataSerializer<>(getStaticWrappedFieldValue("VECTOR").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "BLOCK_POS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "BLOCK_POS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "o")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "n")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "m")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "l")
|
||||
public static final EntityDataSerializer<?> BLOCK_POSITION = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("BLOCK_POSITION").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPTIONAL_BLOCK_POS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPTIONAL_BLOCK_POS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "p")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "o")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "n")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "m")
|
||||
public static final EntityDataSerializer<?> OPTIONAL_BLOCK_POSITION = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_BLOCK_POSITION").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "DIRECTION")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "DIRECTION")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "q")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "p")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "o")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "n")
|
||||
public static final EntityDataSerializer<?> ENUM_DIRECTION = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("ENUM_DIRECTION").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "r")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "q")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "p")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "o")
|
||||
public static final EntityDataSerializer<Optional<UUID>> OPTIONAL_UUID = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_UUID").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPTIONAL_LIVING_ENTITY_REFERENCE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPTIONAL_LIVING_ENTITY_REFERENCE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "r")
|
||||
public static final EntityDataSerializer<Optional<?>> OPTIONAL_ENTITY_REFERENCE = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_ENTITY_REFERENCE").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPTIONAL_GLOBAL_POS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPTIONAL_GLOBAL_POS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "s")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "r")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "q")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "p")
|
||||
public static final EntityDataSerializer<Optional<?>> OPTIONAL_GLOBAL_POS = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_GLOBAL_POS").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_6), path = "t")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "s")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "r")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "q")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "p")
|
||||
public static final EntityDataSerializer<?> NBT_TAG = new EntityDataSerializer<>(getStaticWrappedFieldValue("NBT_TAG").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "VILLAGER_DATA")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "VILLAGER_DATA")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "t")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_6), path = "u")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "t")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "s")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "r")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "q")
|
||||
public static final EntityDataSerializer<?> VILLAGER_DATA = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("VILLAGER_DATA").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "OPTIONAL_UNSIGNED_INT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "OPTIONAL_UNSIGNED_INT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "u")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_6), path = "v")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "u")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "t")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "s")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "r")
|
||||
public static final EntityDataSerializer<OptionalInt> OPTIONAL_INT = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("OPTIONAL_INT").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "POSE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "POSE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "v")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_6), path = "w")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "v")
|
||||
@Mapping(fixed = @Mapping.Fixed(value = Versions.V1_19_3), path = "u")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_19_1), path = "t")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "s")
|
||||
public static final EntityDataSerializer<Pose> ENTITY_POSE = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("ENTITY_POSE").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "VECTOR3")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "VECTOR3")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "J")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "I")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_6), path = "H")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "D")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "A")
|
||||
public static final EntityDataSerializer<Vector3f> VECTOR3 = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("VECTOR3").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "QUARTERNION")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "QUARTERNION")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "K")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "J")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_6), path = "I")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "E")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20_4), path = "B")
|
||||
public static final EntityDataSerializer<?> QUARTERNION = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("QUARTERNION").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "RESOLVABLE_PROFILE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "RESOLVABLE_PROFILE")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "L")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "K")
|
||||
public static final EntityDataSerializer<?> RESOLVABLE_PROFILE = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("RESOLVABLE_PROFILE").orElse(null));
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "HUMANOID_ARM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "HUMANOID_ARM")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "M")
|
||||
public static final EntityDataSerializer<?> HAND = new EntityDataSerializer<>(
|
||||
getStaticWrappedFieldValue("HAND").orElse(null));
|
||||
|
||||
@@ -100,39 +100,35 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
@SuppressWarnings("unchecked")
|
||||
public @NotNull WrappedEntity<?> create(@NotNull World world)
|
||||
{
|
||||
WrappedEntity<?> entity;
|
||||
Object handle;
|
||||
WrappedCompoundTag data = getData();
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_21_2))
|
||||
{
|
||||
data.putString("id", type.toLowerCase());
|
||||
|
||||
entity = new WrappedEntity<>(Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a",
|
||||
data.getHandle(), Var.getNmsLevel(world), Function.identity()).get());
|
||||
handle = Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a",
|
||||
data.getHandle(), Var.getNmsLevel(world), Function.identity()).get();
|
||||
}
|
||||
else if(Versions.isCurrentVersionSmallerThan(Versions.V1_21_9))
|
||||
{
|
||||
data.putString("id", type.toLowerCase());
|
||||
entity = new WrappedEntity<>(
|
||||
Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a",
|
||||
data.getHandle(), Var.getNmsLevel(world), WrappedEntity.SpawnReason.LOAD.getHandle(), Function.identity()).get());
|
||||
handle = Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a",
|
||||
data.getHandle(), Var.getNmsLevel(world), WrappedEntity.SpawnReason.LOAD.getHandle(), Function.identity()).get();
|
||||
}
|
||||
else if(Versions.isCurrentVersionSmallerThan(Versions.V1_21_11))
|
||||
entity = new WrappedEntity<>(
|
||||
Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a", Var.toNmsEntityType(getType()), data.getHandle(),
|
||||
Var.getNmsLevel(world), WrappedEntity.SpawnReason.LOAD.getHandle(), Function.identity()).get());
|
||||
handle = Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a", Var.toNmsEntityType(getType()), data.getHandle(),
|
||||
Var.getNmsLevel(world), WrappedEntity.SpawnReason.LOAD.getHandle(), Function.identity()).get();
|
||||
else if(Versions.isCurrentVersionSmallerThan(Versions.V26_1))
|
||||
entity = new WrappedEntity<>(
|
||||
Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a", Var.toNmsEntityType(getType()),
|
||||
handle = Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityTypes", "a", Var.toNmsEntityType(getType()),
|
||||
data.getHandle(), Var.getNmsLevel(world), WrappedEntity.SpawnReason.LOAD.getHandle(),
|
||||
WrappedEntity.EntityProcessor.NOP).get());
|
||||
WrappedEntity.EntityProcessor.NOP).get();
|
||||
else
|
||||
entity = new WrappedEntity<>(
|
||||
Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityType", "loadEntityRecursive",
|
||||
handle = Reflections.invokeStaticMethod("net.minecraft.world.entity.EntityType", "loadEntityRecursive",
|
||||
Var.toNmsEntityType(getType()), data.getHandle(), Var.getNmsLevel(world), WrappedEntity.SpawnReason.LOAD.getHandle(),
|
||||
WrappedEntity.EntityProcessor.NOP).get());
|
||||
WrappedEntity.EntityProcessor.NOP).get();
|
||||
|
||||
WrappedEntity<?> entity = getType() == EntityType.ENDER_DRAGON ? new WrappedEnderDragon(handle) : new WrappedEntity<>(handle);
|
||||
WrappedEntity<?> finalEntity = entityFunction == null ? entity :
|
||||
WrappedEntity.fromEntity(entityFunction.apply(Var.unsafeCast(entity.getBukkitPlayer())), WrappedEntity.class);
|
||||
WrappedEntity.fromEntity(entityFunction.apply(Var.unsafeCast(entity.getBukkitPlayer())), entity.getClass());
|
||||
finalEntity.data = data.toString();
|
||||
return finalEntity;
|
||||
}
|
||||
@@ -141,8 +137,8 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
/**
|
||||
* A wrapper for Minecraft's NBT (Named Binary Tag) compound tag system, providing a type-safe way to read and write NBT data.
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.nbt.CompoundTag")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.nbt.NBTTagCompound")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.nbt.CompoundTag")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.nbt.NBTTagCompound")
|
||||
public static class WrappedCompoundTag extends Wrapper
|
||||
{
|
||||
/**
|
||||
@@ -177,8 +173,7 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
if(!Versions.isCurrentVersionSmallerThan(Versions.V26_1))
|
||||
return new WrappedCompoundTag(Reflections.invokeStaticMethod("net.minecraft.nbt.TagParser", "parseCompoundFully", s).get());
|
||||
|
||||
String methodName = Versions.isCurrentVersionSmallerThan(Versions.V1_18) ? "parse" : "a";
|
||||
return new WrappedCompoundTag(Reflections.invokeStaticMethod("net.minecraft.nbt.MojangsonParser", methodName, s).get());
|
||||
return new WrappedCompoundTag(Reflections.invokeStaticMethod("net.minecraft.nbt.MojangsonParser", "a", s).get());
|
||||
}
|
||||
catch(RuntimeException e1)
|
||||
{
|
||||
@@ -196,10 +191,6 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
*/
|
||||
public static WrappedCompoundTag parse(byte[] bytes)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_20_4))
|
||||
return new WrappedCompoundTag(
|
||||
Reflections.invokeStaticMethod("net.minecraft.nbt.NBTCompressedStreamTools", "a", new ByteArrayInputStream(bytes)).get());
|
||||
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V26_1))
|
||||
return new WrappedCompoundTag(
|
||||
Reflections.invokeStaticMethod("net.minecraft.nbt.NBTCompressedStreamTools", "a", new ByteArrayInputStream(bytes),
|
||||
@@ -216,9 +207,8 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
* @param key The key to store the value under
|
||||
* @param value The string value to store
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "putString")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setString")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "putString")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void putString(@NotNull String key, @NotNull String value)
|
||||
{
|
||||
invokeWrappedMethod(key, value);
|
||||
@@ -230,10 +220,9 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
* @param key The key of the boolean value
|
||||
* @return The boolean value, or false if the key doesn't exist
|
||||
*/
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getBooleanOr")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getBooleanOr")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_4), path = "q")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getBoolean")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "q")
|
||||
public boolean getBoolean(@NotNull String key)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_21_5))
|
||||
@@ -258,8 +247,8 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.nbt.NbtAccounter")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.nbt.NBTReadLimiter")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.nbt.NbtAccounter")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.nbt.NBTReadLimiter")
|
||||
public static class NbtAccounter extends Wrapper
|
||||
{
|
||||
private NbtAccounter(Object handle)
|
||||
@@ -267,9 +256,9 @@ public class WrappedEntitySnapshot implements Serializable
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "unlimitedHeap")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "unlimitedHeap")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_2, to = Versions.V1_21_9), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_9), path = "a")
|
||||
public static NbtAccounter unlimitedHeap()
|
||||
{
|
||||
return new NbtAccounter(invokeStaticWrappedMethod());
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.server.level.ServerEntity")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.server.level.ServerEntity")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21, to = Versions.V1_21_11), path = "net.minecraft.server.level.EntityTrackerEntry")
|
||||
public class WrappedEntityTrackerEntry extends Wrapper
|
||||
{
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.eisi05.npc.api.wrapper.objects;
|
||||
|
||||
import de.eisi05.npc.api.utils.Reflections;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Interaction;
|
||||
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.world.entity.Interaction")
|
||||
public class WrappedInteraction extends WrappedEntity<Interaction>
|
||||
{
|
||||
WrappedInteraction(Object handle)
|
||||
{
|
||||
super(handle);
|
||||
}
|
||||
|
||||
public static WrappedInteraction create(World world)
|
||||
{
|
||||
return new WrappedInteraction(
|
||||
createInstance(WrappedInteraction.class, EntityTypes.INTERACTION, Reflections.invokeMethod(world, "getHandle").get()));
|
||||
}
|
||||
|
||||
public WrappedEntityData getData(float width, float height)
|
||||
{
|
||||
WrappedEntityData data = getEntityData();
|
||||
data.set(WrappedEntityData.EntityDataSerializers.FLOAT.create(8), width);
|
||||
data.set(WrappedEntityData.EntityDataSerializers.FLOAT.create(9), height);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "net.minecraft.server.MinecraftServer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.server.MinecraftServer")
|
||||
public class WrappedMinecraftServer extends Wrapper
|
||||
{
|
||||
public static final WrappedMinecraftServer INSTANCE = new WrappedMinecraftServer(Reflections.invokeMethod(Bukkit.getServer(), "getServer").get());
|
||||
@@ -23,32 +23,32 @@ public class WrappedMinecraftServer extends Wrapper
|
||||
return Reflections.getStaticField(INSTANCE.handle.getClass(), "currentTick");
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "vanillaCommandDispatcher")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "vanillaCommandDispatcher")
|
||||
public @NotNull WrappedMinecraftServer commands()
|
||||
{
|
||||
return new WrappedMinecraftServer(getWrappedFieldValue());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "registryAccess")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "registryAccess")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "bc")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "bg")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_6), path = "ba")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "bc")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "aZ")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "aU")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "aV")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_4), path = "aX")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "aW")
|
||||
public Object registryAccess()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getDispatcher")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getDispatcher")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
@SuppressWarnings("unchecked")
|
||||
public @NotNull CommandDispatcher<Object> getCommandDispatcher()
|
||||
{
|
||||
return (CommandDispatcher<Object>) Reflections.invokeMethod(commands().getHandle(), getPath()).get();
|
||||
}
|
||||
|
||||
public static Object vanillaRegistry() {
|
||||
return Reflections.invokeStaticMethod("net.minecraft.data.registries.VanillaRegistries",
|
||||
Versions.isCurrentVersionSmallerThan(Versions.V26_1) ? "a" : "createLookup").get();
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.scores.PlayerTeam")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.scores.ScoreboardTeam")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.scores.PlayerTeam")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.scores.ScoreboardTeam")
|
||||
public class WrappedPlayerTeam extends Wrapper
|
||||
{
|
||||
private static final Map<UUID, Map<String, WrappedPlayerTeam>> teams = new HashMap<>();
|
||||
@@ -30,12 +27,9 @@ public class WrappedPlayerTeam extends Wrapper
|
||||
return new WrappedPlayerTeam(Reflections.invokeMethod(player.getScoreboard(), "getHandle")
|
||||
.thanInvoke(switch(Versions.getVersion())
|
||||
{
|
||||
case NONE -> null;
|
||||
case V1_17 -> "getPlayerTeam";
|
||||
case V1_18, V1_18_2, V1_19, V1_19_1, V1_19_3, V1_19_4, V1_20 -> "i";
|
||||
case V1_20_2 -> "g";
|
||||
case V1_20_4, V1_20_6, V1_21, V1_21_2, V1_21_4, V1_21_5, V1_21_6, V1_21_9, V1_21_11 -> "e";
|
||||
case V26_1 -> "getPlayersTeam";
|
||||
case V1_20_6, V1_21, V1_21_2, V1_21_4, V1_21_5, V1_21_6, V1_21_9, V1_21_11 -> "e";
|
||||
case V26_1, V26_2 -> "getPlayersTeam";
|
||||
default -> null;
|
||||
}, WrappedServerPlayer.fromPlayer(player).getName()).get());
|
||||
}
|
||||
|
||||
@@ -81,10 +75,9 @@ public class WrappedPlayerTeam extends Wrapper
|
||||
return teams.getOrDefault(player.getUniqueId(), new HashMap<>()).containsKey(name);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getNameTagVisibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "nameTagVisibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_4), path = "j")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getNameTagVisibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "j")
|
||||
public @Nullable Visibility getNameTagVisibility()
|
||||
{
|
||||
Object enumHandle = getWrappedFieldValue();
|
||||
@@ -96,92 +89,90 @@ public class WrappedPlayerTeam extends Wrapper
|
||||
return null;
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setNameTagVisibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setNameTagVisibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setNameTagVisibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void setNameTagVisibility(@NotNull Visibility visibility)
|
||||
{
|
||||
invokeWrappedMethod(visibility.getHandle());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setCollisionRule")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setCollisionRule")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setCollisionRule")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void setCollisionRule(@NotNull CollisionRule collisionRule)
|
||||
{
|
||||
invokeWrappedMethod(collisionRule.getHandle());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setSeeFriendlyInvisibles")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setCanSeeFriendlyInvisibles")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setSeeFriendlyInvisibles")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public void setCanSeeFriendlyInvisible(boolean canSeeFriendlyInvisible)
|
||||
{
|
||||
invokeWrappedMethod(canSeeFriendlyInvisible);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "canSeeFriendlyInvisibles")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "canSeeFriendlyInvisibles")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_4), path = "i")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "canSeeFriendlyInvisibles")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "i")
|
||||
public boolean canSeeFriendlyInvisible()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getPlayers")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getPlayers")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_4), path = "g")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getPlayerNameSet")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "g")
|
||||
public @NotNull Collection<String> getPlayers()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getName")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getName")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_5, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_4), path = "b")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getName")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_4), path = "b")
|
||||
public @NotNull String getName()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setColor")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setColor")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setColor")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void setColor(@NotNull ChatFormat color)
|
||||
{
|
||||
invokeWrappedMethod(color);
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V26_2))
|
||||
invokeWrappedMethod(color);
|
||||
else
|
||||
{
|
||||
Object teamColor = Reflections.getStaticField(getWrappedClass(TeamColor.class), color.name());
|
||||
invokeWrappedMethod(Optional.of(teamColor));
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setPlayerPrefix")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setPrefix")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setPlayerPrefix")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void setPrefix(@NotNull WrappedComponent prefix)
|
||||
{
|
||||
invokeWrappedMethod(prefix);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.scores.Team$Visibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.scores" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.scores.Team$Visibility")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.scores" +
|
||||
".ScoreboardTeamBase$EnumNameTagVisibility")
|
||||
public enum Visibility implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ALWAYS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ALWAYS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
ALWAYS,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "NEVER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "NEVER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
NEVER,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "HIDE_FOR_OTHER_TEAMS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "HIDE_FOR_OTHER_TEAMS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
HIDE_FOR_OTHER_TEAMS,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "HIDE_FOR_OWN_TEAM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "HIDE_FOR_OWN_TEAM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
HIDE_FOR_OWN_TEAM;
|
||||
|
||||
@Override
|
||||
@@ -191,24 +182,24 @@ public class WrappedPlayerTeam extends Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.scores.Team$CollisionRule")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.scores.ScoreboardTeamBase$EnumTeamPush")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.scores.Team$CollisionRule")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.scores.ScoreboardTeamBase$EnumTeamPush")
|
||||
public enum CollisionRule implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ALWAYS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ALWAYS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
ALWAYS,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "NEVER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "NEVER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
NEVER,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "PUSH_OTHER_TEAMS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "PUSH_OTHER_TEAMS")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
PUSH_OTHER_TEAMS,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "PUSH_OWN_TEAM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "PUSH_OWN_TEAM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
PUSH_OWN_TEAM;
|
||||
|
||||
@Override
|
||||
@@ -217,4 +208,9 @@ public class WrappedPlayerTeam extends Wrapper
|
||||
return cast(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_2, to = Versions.V26_2), path = "net.minecraft.world.scores.TeamColor")
|
||||
public static class TeamColor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import de.eisi05.npc.api.utils.exceptions.VersionNotFound;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.enums.Pose;
|
||||
import de.eisi05.npc.api.wrapper.packets.BundlePacket;
|
||||
import de.eisi05.npc.api.wrapper.packets.ChatPacket;
|
||||
import de.eisi05.npc.api.wrapper.packets.PacketWrapper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -21,8 +20,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.server.level.ServerPlayer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.server.level.EntityPlayer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.server.level.ServerPlayer")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.server.level.EntityPlayer")
|
||||
public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
{
|
||||
private static final Map<UUID, WrappedServerPlayer> map = new HashMap<>();
|
||||
@@ -54,9 +53,7 @@ public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
|
||||
WrappedServerPlayer wrappedServerPlayer = switch(Versions.getVersion())
|
||||
{
|
||||
case V1_17, V1_18, V1_18_2, V1_19_3, V1_19_4, V1_20 -> createWrappedInstance(WrappedServerPlayer.class, mcServer, serverLevel, gameProfile);
|
||||
case V1_19, V1_19_1 -> createWrappedInstance(WrappedServerPlayer.class, mcServer, serverLevel, gameProfile, null);
|
||||
case V1_20_2, V1_20_4, V1_20_6, V1_21, V1_21_2, V1_21_4, V1_21_5, V1_21_6, V1_21_9, V1_21_11, V26_1 ->
|
||||
case V1_20_6, V1_21, V1_21_2, V1_21_4, V1_21_5, V1_21_6, V1_21_9, V1_21_11, V26_1, V26_2 ->
|
||||
{
|
||||
WrappedServerPlayer serverPlayer = createWrappedInstance(WrappedServerPlayer.class, mcServer, serverLevel, gameProfile,
|
||||
WrappedClientInformation.createDefault().getHandle());
|
||||
@@ -67,23 +64,15 @@ public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
|
||||
yield serverPlayer;
|
||||
}
|
||||
case NONE -> throw new VersionNotFound();
|
||||
default -> throw new VersionNotFound();
|
||||
};
|
||||
|
||||
if(nameDisplay != null)
|
||||
wrappedServerPlayer.setNameTag(nameDisplay);
|
||||
else if(Versions.isCurrentVersionSmallerThan(Versions.V1_19_4))
|
||||
{
|
||||
WrappedArmorStand armorStand = WrappedArmorStand.create(location.getWorld());
|
||||
armorStand.moveTo(location.clone().add(0, 0.2, 0));
|
||||
wrappedServerPlayer.setNameTag(armorStand);
|
||||
}
|
||||
else
|
||||
{
|
||||
WrappedTextDisplay textDisplay = WrappedTextDisplay.create(location.getWorld());
|
||||
textDisplay.moveTo(location.clone().add(0, 0.2, 0));
|
||||
wrappedServerPlayer.setNameTag(textDisplay);
|
||||
}
|
||||
|
||||
WrappedTextDisplay textDisplay = WrappedTextDisplay.create(location.getWorld());
|
||||
textDisplay.moveTo(location.clone().add(0, 0.2, 0));
|
||||
wrappedServerPlayer.setNameTag(textDisplay);
|
||||
|
||||
wrappedServerPlayer.moveTo(location);
|
||||
wrappedServerPlayer.setListName(name);
|
||||
@@ -97,7 +86,7 @@ public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
return create(location, uuid, new GameProfile(uuid, "NPC" + uuid.toString().substring(0, 13)), name, nameDisplay);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getAttribute")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getAttribute")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_5), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "f")
|
||||
@@ -106,7 +95,7 @@ public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
return new WrappedAttributeInstance(invokeWrappedMethod(attribute));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getGameProfile")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "getGameProfile")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "gI")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "gz")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "gr")
|
||||
@@ -114,132 +103,86 @@ public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_4), path = "gh")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21), path = "fX")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "gb")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "fR")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "fQ")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "fM")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_4), path = "fI")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "fD")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_1), path = "fy")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19), path = "fz")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_18_2), path = "fq")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_18), path = "fp")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getProfile")
|
||||
public @NotNull GameProfile getGameProfile()
|
||||
{
|
||||
return invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_5), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20, to = Versions.V1_21), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_4), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "c")
|
||||
public @NotNull WrappedConnection playerConnection()
|
||||
{
|
||||
return new WrappedConnection(getWrappedFieldValue());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "connection")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_6, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_5), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20, to = Versions.V1_21), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_4), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "c")
|
||||
public void setConnection(@NotNull WrappedConnection newConnection)
|
||||
{
|
||||
setWrappedFieldValue(newConnection.getHandle());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "listName")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "listName")
|
||||
public void setListName(@Nullable WrappedComponent component)
|
||||
{
|
||||
setWrappedFieldValue(component.getHandle());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "listName")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "listName")
|
||||
public void setListName(@Nullable String name)
|
||||
{
|
||||
setListName(WrappedComponent.create(name));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V26_1), path = "listOrder")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "listOrder")
|
||||
public void setListOrder(int order)
|
||||
{
|
||||
setWrappedFieldValue(order);
|
||||
}
|
||||
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_4), path = "e")
|
||||
public void setLatency(int i)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_20_2))
|
||||
setWrappedFieldValue(i);
|
||||
else
|
||||
setConnection(new WrappedConnection(WrappedMinecraftServer.INSTANCE, playerConnection().networkManager(), this,
|
||||
new WrappedConnection.CommonListenerCookie(getGameProfile(), i, true)));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "setPose")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "setPose")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "setPose")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
public void setPose(@NotNull Pose pose)
|
||||
{
|
||||
invokeWrappedMethod(pose);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "createCommandSourceStack")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "createCommandSourceStack")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "C")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "A")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_5), path = "z")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_4), path = "A")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "dg")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "dd")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "dc")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "da")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_4), path = "cZ")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "cY")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_1), path = "cT")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19), path = "cU")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_18_2), path = "cQ")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getCommandListener")
|
||||
public WrappedCommandSourceStack createCommandStack()
|
||||
{
|
||||
return new WrappedCommandSourceStack(invokeWrappedMethod());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "stopUsingItem")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "stopUsingItem")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "gf")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_9), path = "fU")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "fM")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_5), path = "fF")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21), path = "fx")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "fB")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_4), path = "ft")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "fs")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20), path = "fo")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_4), path = "fk")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "ff")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_1), path = "eZ")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19), path = "fa")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_18_2), path = "eS")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_18), path = "eR")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "clearActiveItem")
|
||||
public void stopUsingItem()
|
||||
{
|
||||
invokeWrappedMethod();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "sendSystemMessage")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "sendSystemMessage")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void sendRawMessage(@NotNull WrappedComponent component)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_19))
|
||||
sendPacket(new ChatPacket(component, ChatPacket.ChatType.CHAT));
|
||||
else
|
||||
invokeWrappedMethod(component);
|
||||
invokeWrappedMethod(component);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "remove")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "removePlayerImmediately")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public void remove()
|
||||
{
|
||||
map.remove(getUUID());
|
||||
@@ -248,18 +191,14 @@ public class WrappedServerPlayer extends WrappedEntity<Player>
|
||||
Reflections.invokeMethod(nmsLevel, getPath(), getHandle(), RemovalReason.DISCARDED.getHandle());
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "getAdvancements-stopListening")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_2, to = Versions.V26_2), path = "getAdvancements-clearTriggers")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V26_1), path = "getAdvancements-stopListening")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "U-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_6), path = "S-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_5), path = "R-a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_4), path = "S-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21), path = "R-a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_4, to = Versions.V1_20_6), path = "Q-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_2), path = "O-a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V1_20), path = "M-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_19_3), path = "N-a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_18, to = Versions.V1_19_1), path = "M-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_17), path = "getAdvancementData-a")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_20_6), path = "Q-a")
|
||||
public void stopAdvancementListening()
|
||||
{
|
||||
String path = getPath();
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package de.eisi05.npc.api.wrapper.objects;
|
||||
|
||||
import de.eisi05.npc.api.objects.NameDisplayOptions;
|
||||
import de.eisi05.npc.api.utils.Reflections;
|
||||
import de.eisi05.npc.api.utils.Var;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V26_1), path = "net.minecraft.world.entity.Display$TextDisplay")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.world.entity.Display$TextDisplay")
|
||||
public class WrappedTextDisplay extends WrappedEntity.WrappedNameTag<Entity>
|
||||
{
|
||||
private static final boolean flag = Versions.isCurrentVersionSmallerThan(Versions.V1_20_2);
|
||||
private final Map<WrappedEntityData.EntityDataAccessor<?>, Object> dataMap = new LinkedHashMap<>();
|
||||
|
||||
protected WrappedTextDisplay(Object handle)
|
||||
@@ -47,7 +49,7 @@ public class WrappedTextDisplay extends WrappedEntity.WrappedNameTag<Entity>
|
||||
*/
|
||||
public WrappedTextDisplay translation(float x, float y, float z)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.VECTOR3.create(flag ? 10 : 11), new Vector3f(x, y, z));
|
||||
return set(WrappedEntityData.EntityDataSerializers.VECTOR3.create(11), new Vector3f(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,169 +64,158 @@ public class WrappedTextDisplay extends WrappedEntity.WrappedNameTag<Entity>
|
||||
*/
|
||||
public WrappedTextDisplay scale(float x, float y, float z)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.VECTOR3.create(flag ? 11 : 12), new Vector3f(x, y, z));
|
||||
return set(WrappedEntityData.EntityDataSerializers.VECTOR3.create(12), new Vector3f(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the billboard alignment constraints.
|
||||
* Default: CENTER
|
||||
* Sets the billboard alignment constraints. Default: CENTER
|
||||
*
|
||||
* @param constraints BillboardConstraints enum.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay billboardConstraints(BillboardConstraints constraints)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.BYTE.create(flag ? 14 : 15), (byte) constraints.ordinal());
|
||||
return set(WrappedEntityData.EntityDataSerializers.BYTE.create(15), (byte) constraints.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets brightness override.
|
||||
* Default: -1
|
||||
* Sets brightness override. Default: -1
|
||||
*
|
||||
* @param brightness Brightness value.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay brightnessOverride(int brightness)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(flag ? 15 : 16), brightness);
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(16), brightness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the viewing range of the nametag.
|
||||
* Default: 1.0
|
||||
* Sets the viewing range of the nametag. Default: 1.0
|
||||
*
|
||||
* @param range View range.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay viewRange(float range)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(flag ? 16 : 17), range);
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(17), range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shadow radius.
|
||||
* Default: 0.0
|
||||
* Sets the shadow radius. Default: 0.0
|
||||
*
|
||||
* @param radius Shadow radius.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay shadowRadius(float radius)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(flag ? 17 : 18), radius);
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(18), radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shadow strength.
|
||||
* Default: 1.0
|
||||
* Sets the shadow strength. Default: 1.0
|
||||
*
|
||||
* @param strength Shadow strength.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay shadowStrength(float strength)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(flag ? 18 : 19), strength);
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(19), strength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the nametag.
|
||||
* Default: 0.0
|
||||
*
|
||||
* @param width Width value.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay width(float width)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(flag ? 19 : 20), width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the height of the nametag.
|
||||
* Default: 1.0
|
||||
*
|
||||
* @param height Height value.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay height(float height)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.FLOAT.create(flag ? 20 : 21), height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a glow color override.
|
||||
* Default: -1
|
||||
*
|
||||
* @param color Glow color as integer.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay glowColorOverride(int color)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(flag ? 21 : 22), color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the line width of the text.
|
||||
* Default: 200
|
||||
* Sets the line width of the text. Default: 200
|
||||
*
|
||||
* @param width Line width.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay lineWidth(int width)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(flag ? 23 : 24), width);
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(24), width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color.
|
||||
* Default: 1073741824 (0x40000000)
|
||||
* Sets the background color. Default: 1073741824 (0x40000000)
|
||||
*
|
||||
* @param color Background color as integer.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay backgroundColor(int color)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(flag ? 24 : 25), color);
|
||||
return set(WrappedEntityData.EntityDataSerializers.INT.create(25), color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text opacity.
|
||||
* Default: -1 (fully opaque)
|
||||
* Sets the text opacity. Default: -1 (fully opaque)
|
||||
*
|
||||
* @param opacity Text opacity.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay textOpacity(byte opacity)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.BYTE.create(flag ? 25 : 26), opacity);
|
||||
return set(WrappedEntityData.EntityDataSerializers.BYTE.create(26), opacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags including shadow, see-through, background color, and alignment.
|
||||
* Default: NONE
|
||||
* Sets flags including shadow, see-through, background color, and alignment. Default: NONE
|
||||
*
|
||||
* @param flags Varargs of TextDisplayFlags.
|
||||
* @return This instance for chaining.
|
||||
*/
|
||||
public WrappedTextDisplay flags(TextDisplayFlags... flags)
|
||||
{
|
||||
return set(WrappedEntityData.EntityDataSerializers.BYTE.create(flag ? 26 : 27), TextDisplayFlags.combineFlags(flags));
|
||||
return set(WrappedEntityData.EntityDataSerializers.BYTE.create(27), TextDisplayFlags.combineFlags(flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all configured data to the given TextDisplay and component.
|
||||
*
|
||||
* @param component The text component to display.
|
||||
* @param displayOptions The display options to apply.
|
||||
* @return The WrappedEntityData after applying values.
|
||||
*/
|
||||
public WrappedEntityData applyData(WrappedComponent component)
|
||||
public WrappedEntityData applyData(WrappedComponent component, @NotNull NameDisplayOptions displayOptions)
|
||||
{
|
||||
WrappedEntityData data = getEntityData();
|
||||
data.set(WrappedEntityData.EntityDataSerializers.OPTIONAL_CHAT_COMPONENT.create(2), Optional.of(component.getHandle()));
|
||||
data.set(WrappedEntityData.EntityDataSerializers.BOOLEAN.create(4), true);
|
||||
|
||||
translation(0, 0.25f, 0);
|
||||
translation(0, 0.25f + displayOptions.getHeight(), 0);
|
||||
billboardConstraints(BillboardConstraints.CENTER);
|
||||
|
||||
data.set(WrappedEntityData.EntityDataSerializers.CHAT_COMPONENT.create(flag ? 22 : 23), Var.unsafeCast(component.getHandle()));
|
||||
float[] scale = displayOptions.getScale();
|
||||
scale(scale[0], scale[1], scale[2]);
|
||||
|
||||
int brightness = displayOptions.getBrightness();
|
||||
brightnessOverride(brightness);
|
||||
|
||||
float viewRange = displayOptions.getViewRange();
|
||||
viewRange(viewRange);
|
||||
|
||||
int lineWidth = displayOptions.getLineWidth();
|
||||
lineWidth(lineWidth);
|
||||
|
||||
int backgroundColor = displayOptions.getBackgroundColor();
|
||||
backgroundColor(backgroundColor);
|
||||
|
||||
byte textOpacity = displayOptions.getTextOpacity();
|
||||
textOpacity(textOpacity);
|
||||
|
||||
|
||||
boolean isSeeThrough = displayOptions.isSeeThrough();
|
||||
TextDisplay.TextAlignment alignment = displayOptions.getAlignment();
|
||||
TextDisplayFlags alignmentFlag = switch(alignment)
|
||||
{
|
||||
case LEFT -> TextDisplayFlags.LEFT_ALIGNMENT;
|
||||
case CENTER -> TextDisplayFlags.CENTER_ALIGNMENT;
|
||||
case RIGHT -> TextDisplayFlags.RIGHT_ALIGNMENT;
|
||||
};
|
||||
|
||||
if(isSeeThrough)
|
||||
flags(alignmentFlag, TextDisplayFlags.IS_SEE_THROUGH);
|
||||
else
|
||||
flags(alignmentFlag);
|
||||
|
||||
data.set(WrappedEntityData.EntityDataSerializers.CHAT_COMPONENT.create(23), Var.unsafeCast(component.getHandle()));
|
||||
|
||||
dataMap.forEach((accessor, value) -> data.set(accessor, Var.unsafeCast(value)));
|
||||
|
||||
@@ -252,9 +243,10 @@ public class WrappedTextDisplay extends WrappedEntity.WrappedNameTag<Entity>
|
||||
IS_SEE_THROUGH((byte) 0x02),
|
||||
USE_DEFAULT_BACKGROUND_COLOR((byte) 0x04),
|
||||
CENTER_ALIGNMENT((byte) 0x00),
|
||||
LEFT_ALIGNMENT((byte) 0x01),
|
||||
RIGHT_ALIGNMENT((byte) 0x02);
|
||||
LEFT_ALIGNMENT((byte) 0x08),
|
||||
RIGHT_ALIGNMENT((byte) 0x10);
|
||||
|
||||
private static final byte ALIGNMENT_MASK = (byte) 0x18;
|
||||
private final byte flag;
|
||||
|
||||
TextDisplayFlags(byte flag) {this.flag = flag;}
|
||||
@@ -262,8 +254,22 @@ public class WrappedTextDisplay extends WrappedEntity.WrappedNameTag<Entity>
|
||||
public static byte combineFlags(TextDisplayFlags... flags)
|
||||
{
|
||||
byte result = 0;
|
||||
boolean alignmentSet = false;
|
||||
|
||||
for(TextDisplayFlags flag : flags)
|
||||
result |= flag.flag;
|
||||
{
|
||||
boolean isAlignment = (flag == CENTER_ALIGNMENT || flag == LEFT_ALIGNMENT || flag == RIGHT_ALIGNMENT);
|
||||
|
||||
if(isAlignment)
|
||||
{
|
||||
if(alignmentSet)
|
||||
throw new IllegalArgumentException("You cannot clear or set multiple alignments at once!");
|
||||
result = (byte) ((result & ~ALIGNMENT_MASK) | flag.flag);
|
||||
alignmentSet = true;
|
||||
}
|
||||
else
|
||||
result |= flag.flag;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.phys.Vec2")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.phys.Vec2F")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.phys.Vec2")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.phys.Vec2F")
|
||||
|
||||
public class WrappedVec2F extends Wrapper
|
||||
{
|
||||
@@ -14,17 +14,17 @@ public class WrappedVec2F extends Wrapper
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "x")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "x")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_9), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_9), path = "i")
|
||||
public float getPitch()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "y")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "y")
|
||||
@Mapping(fixed = @Mapping.Fixed(Versions.V1_21_11), path = "k")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_9), path = "j")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_9), path = "j")
|
||||
public float getYaw()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
|
||||
@@ -6,8 +6,8 @@ import de.eisi05.npc.api.wrapper.Wrapper;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.world.phys.Vec3")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.world.phys.Vec3D")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.world.phys.Vec3")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.world.phys.Vec3D")
|
||||
public class WrappedVec3D extends Wrapper
|
||||
{
|
||||
private WrappedVec3D(Object handle)
|
||||
@@ -30,28 +30,28 @@ public class WrappedVec3D extends Wrapper
|
||||
return new WrappedVec3D(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "x")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "x")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "g")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_6), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "c")
|
||||
public double getX()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "y")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "y")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "h")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_6), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "d")
|
||||
public double getY()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "z")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "z")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_9, to = Versions.V1_21_11), path = "i")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_6), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21), path = "e")
|
||||
public double getZ()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
|
||||
@@ -3,15 +3,14 @@ package de.eisi05.npc.api.wrapper.packets;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedEntity;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedServerPlayer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundAnimatePacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutAnimation")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundAnimatePacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutAnimation")
|
||||
public class AnimatePacket extends PacketWrapper
|
||||
{
|
||||
protected AnimatePacket(@NotNull WrappedEntity<?> entity, int animationId)
|
||||
@@ -21,7 +20,7 @@ public class AnimatePacket extends PacketWrapper
|
||||
|
||||
public static @Nullable PacketWrapper create(@NotNull WrappedEntity<?> entity, @NotNull Animation animation)
|
||||
{
|
||||
if(animation != Animation.HURT || Versions.isCurrentVersionSmallerThan(Versions.V1_19_4))
|
||||
if(animation != Animation.HURT)
|
||||
return new AnimatePacket(entity, animation.ordinal());
|
||||
|
||||
if(!(entity.getBukkitPlayer() instanceof LivingEntity))
|
||||
@@ -40,7 +39,7 @@ public class AnimatePacket extends PacketWrapper
|
||||
MAGIC_CRITICAL_HIT
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_4, to = Versions.V26_1),
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2),
|
||||
path = "net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket")
|
||||
public static class HurtAnimationPacket extends PacketWrapper
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ package de.eisi05.npc.api.wrapper.packets;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ServerboundAttackPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ServerboundAttackPacket")
|
||||
public class AttackPacket extends PacketWrapper.PacketHolder
|
||||
{
|
||||
protected AttackPacket(Object handle)
|
||||
@@ -11,7 +11,7 @@ public class AttackPacket extends PacketWrapper.PacketHolder
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "entityId")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "entityId")
|
||||
public int getId()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package de.eisi05.npc.api.wrapper.packets;
|
||||
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "net.minecraft.network.protocol.game.PacketPlayOutChat")
|
||||
public class ChatPacket extends PacketWrapper
|
||||
{
|
||||
private static final UUID NULL_UUID = new UUID(0, 0);
|
||||
|
||||
public ChatPacket(@NotNull WrappedComponent component, @NotNull ChatType type)
|
||||
{
|
||||
super(ChatPacket.class, component, type, NULL_UUID);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "net.minecraft.network.chat.ChatMessageType")
|
||||
public enum ChatType implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "a")
|
||||
CHAT,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "b")
|
||||
SYSTEM,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_18_2), path = "c")
|
||||
GAME_INFO;
|
||||
|
||||
@Override
|
||||
public @NotNull Object getHandle()
|
||||
{
|
||||
return cast(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package de.eisi05.npc.api.wrapper.packets;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntity")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntity")
|
||||
public class MoveEntityPacket
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
".PacketPlayOutEntity$PacketPlayOutEntityLook")
|
||||
public static class Rot extends PacketWrapper
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class PacketWrapper extends Wrapper
|
||||
super(createInstance(clazz, args));
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V26_1), path = "net.minecraft.network.protocol.Packet")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.network.protocol.Packet")
|
||||
public static abstract class PacketHolder extends PacketWrapper
|
||||
{
|
||||
public PacketHolder(Object handle)
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V26_1), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.network.protocol.game" +
|
||||
".ClientboundPlayerInfoRemovePacket")
|
||||
public class PlayerInfoRemovePacket extends PacketWrapper
|
||||
{
|
||||
|
||||
@@ -5,9 +5,8 @@ import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V26_1), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "net.minecraft.network.protocol.game" +
|
||||
".ClientboundPlayerInfoUpdatePacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo")
|
||||
public class PlayerInfoUpdatePacket extends PacketWrapper
|
||||
{
|
||||
public PlayerInfoUpdatePacket(@NotNull Action action, @NotNull WrappedServerPlayer serverPlayer)
|
||||
@@ -15,50 +14,41 @@ public class PlayerInfoUpdatePacket extends PacketWrapper
|
||||
super(PlayerInfoUpdatePacket.class, action, serverPlayer);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game" +
|
||||
".ClientboundPlayerInfoUpdatePacket$Action")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
".ClientboundPlayerInfoUpdatePacket$a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "net.minecraft.network.protocol.game" +
|
||||
".PacketPlayOutPlayerInfo$EnumPlayerInfoAction")
|
||||
public enum Action implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "ADD_PLAYER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "ADD_PLAYER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
ADD_PLAYER,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "INITIALIZE_CHAT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "INITIALIZE_CHAT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
INITIALIZE_CHAT,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UPDATE_GAME_MODE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UPDATE_GAME_MODE")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
UPDATE_GAME_MODE,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UPDATE_LISTED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UPDATE_LISTED")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "d")
|
||||
UPDATE_LISTED,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UPDATE_LATENCY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UPDATE_LATENCY")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
UPDATE_LATENCY,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UPDATE_DISPLAY_NAME")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V1_21_11), path = "f")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "d")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UPDATE_DISPLAY_NAME")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "f")
|
||||
UPDATE_DISPLAY_NAME,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "REMOVE_PLAYER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "e")
|
||||
REMOVE_PLAYER,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UPDATE_LIST_ORDER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UPDATE_LIST_ORDER")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V1_21_11), path = "g")
|
||||
UPDATE_LIST_ORDER,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "UPDATE_HAT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "UPDATE_HAT")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_4, to = Versions.V1_21_11), path = "h")
|
||||
UPDATE_HAT;
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package de.eisi05.npc.api.wrapper.packets;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy")
|
||||
public class RemoveEntityPacket extends PacketWrapper
|
||||
{
|
||||
public RemoveEntityPacket(int entityId)
|
||||
|
||||
@@ -5,8 +5,8 @@ import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundRotateHeadPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundRotateHeadPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation")
|
||||
public class RotateHeadPacket extends PacketWrapper
|
||||
{
|
||||
public RotateHeadPacket(@NotNull WrappedEntity entity, byte yHeadRot)
|
||||
|
||||
@@ -8,19 +8,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata")
|
||||
public class SetEntityDataPacket extends PacketWrapper
|
||||
{
|
||||
public List<?> data;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_19_1), path = "")
|
||||
private SetEntityDataPacket(int id, @NotNull WrappedEntityData data, boolean nonDefaults)
|
||||
{
|
||||
super(SetEntityDataPacket.class, id, data, nonDefaults);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_19_3, to = Versions.V26_1), path = "")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V26_2), path = "")
|
||||
private SetEntityDataPacket(int id, @NotNull List<?> data)
|
||||
{
|
||||
super(SetEntityDataPacket.class, id, data);
|
||||
@@ -29,12 +23,13 @@ public class SetEntityDataPacket extends PacketWrapper
|
||||
|
||||
public static SetEntityDataPacket create(int id, @NotNull WrappedEntityData data)
|
||||
{
|
||||
if(Versions.isCurrentVersionSmallerThan(Versions.V1_19_3))
|
||||
return new SetEntityDataPacket(id, data, true);
|
||||
else
|
||||
{
|
||||
List<?> dataList = data.packDirty();
|
||||
return new SetEntityDataPacket(id, dataList == null ? new ArrayList<>() : dataList);
|
||||
}
|
||||
List<?> dataList = data.packDirty();
|
||||
return new SetEntityDataPacket(id, dataList == null ? new ArrayList<>() : dataList);
|
||||
}
|
||||
|
||||
public static SetEntityDataPacket createNoneDefaults(int id, @NotNull WrappedEntityData data)
|
||||
{
|
||||
List<?> dataList = data.getAll();
|
||||
return new SetEntityDataPacket(id, dataList == null ? new ArrayList<>() : dataList);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment")
|
||||
public class SetEquipmentPacket extends PacketWrapper
|
||||
{
|
||||
public SetEquipmentPacket(int entity, @NotNull List<Pair<?, ?>> list)
|
||||
|
||||
@@ -4,8 +4,8 @@ import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
import de.eisi05.npc.api.wrapper.objects.WrappedEntity;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundSetPassengersPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutMount")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundSetPassengersPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutMount")
|
||||
public class SetPassengerPacket extends PacketWrapper
|
||||
{
|
||||
public SetPassengerPacket(WrappedEntity<?> entity)
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam")
|
||||
public class SetPlayerTeamPacket extends PacketWrapper
|
||||
{
|
||||
private SetPlayerTeamPacket(@NotNull String teamName, int method, @NotNull Optional<Object> parameter, @NotNull Collection<String> players)
|
||||
@@ -41,9 +41,9 @@ public class SetPlayerTeamPacket extends PacketWrapper
|
||||
REMOVE
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game" +
|
||||
".ClientboundSetPlayerTeamPacket$Parameters")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam$b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam$b")
|
||||
public static class Parameters extends Wrapper
|
||||
{
|
||||
public Parameters(@NotNull WrappedPlayerTeam team)
|
||||
|
||||
@@ -11,8 +11,8 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport")
|
||||
public class TeleportEntityPacket extends PacketWrapper
|
||||
{
|
||||
public TeleportEntityPacket(WrappedEntity<?> entity, PositionMoveRotation positionMoveRotation, Set<?> relatives, boolean onGround)
|
||||
@@ -35,7 +35,7 @@ public class TeleportEntityPacket extends PacketWrapper
|
||||
return createInstance(TeleportEntityPacket.class, entity.getId(), positionMoveRotation.getHandle(), relatives, onGround);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V26_1), path = "net.minecraft.world.entity.PositionMoveRotation")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21_2, to = Versions.V26_2), path = "net.minecraft.world.entity.PositionMoveRotation")
|
||||
public static class PositionMoveRotation extends Wrapper
|
||||
{
|
||||
private final Vector position;
|
||||
|
||||
@@ -6,7 +6,7 @@ import de.eisi05.npc.api.wrapper.objects.WrappedAttributeInstance;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayOutUpdateAttributes")
|
||||
public class UpdateAttributesPacket extends PacketWrapper
|
||||
{
|
||||
|
||||
@@ -7,12 +7,11 @@ import de.eisi05.npc.api.wrapper.enums.InteractionHand;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ServerboundInteractPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayInUseEntity")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ServerboundInteractPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayInUseEntity")
|
||||
public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "e")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_20_4), path = "d")
|
||||
public final static Action ATTACK_ACTION = new Action(getStaticWrappedFieldValue("ATTACK_ACTION").orElse(null));
|
||||
|
||||
protected UseEntityPacketWrapper(Object handle)
|
||||
@@ -20,15 +19,14 @@ public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "entityId")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "entityId")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_20_4), path = "a")
|
||||
public int getId()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "hand")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "hand")
|
||||
public @Nullable InteractionHand getHand()
|
||||
{
|
||||
Object enumHandle = getWrappedFieldValue();
|
||||
@@ -40,14 +38,13 @@ public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
return null;
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "usingSecondaryAction")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "usingSecondaryAction")
|
||||
public boolean usingSecondaryAction()
|
||||
{
|
||||
return getWrappedFieldValue();
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_21, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_20_6), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
public @NotNull Action getAction()
|
||||
{
|
||||
Object value = getWrappedFieldValue();
|
||||
@@ -58,17 +55,17 @@ public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
return new Action(value);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
".PacketPlayInUseEntity$b")
|
||||
public enum ActionType implements EnumWrapper
|
||||
{
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
INTERACT,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "b")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "b")
|
||||
ATTACK,
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "c")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "c")
|
||||
INTERACT_AT;
|
||||
|
||||
@Override
|
||||
@@ -78,7 +75,7 @@ public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
}
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game" +
|
||||
".PacketPlayInUseEntity$EnumEntityUseAction")
|
||||
public static class Action extends Wrapper
|
||||
{
|
||||
@@ -87,7 +84,7 @@ public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @Nullable ActionType getActionType()
|
||||
{
|
||||
Object enumHandle = invokeWrappedMethod();
|
||||
@@ -99,7 +96,7 @@ public class UseEntityPacketWrapper extends PacketWrapper.PacketHolder
|
||||
return null;
|
||||
}
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "a")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "a")
|
||||
public @Nullable InteractionHand getHand()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -3,8 +3,8 @@ package de.eisi05.npc.api.wrapper.packets;
|
||||
import de.eisi05.npc.api.utils.Versions;
|
||||
import de.eisi05.npc.api.wrapper.Mapping;
|
||||
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_1), path = "net.minecraft.network.protocol.game.ServerboundUseItemPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_17, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayInUseItem")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V26_1, to = Versions.V26_2), path = "net.minecraft.network.protocol.game.ServerboundUseItemPacket")
|
||||
@Mapping(range = @Mapping.Range(from = Versions.V1_20_6, to = Versions.V1_21_11), path = "net.minecraft.network.protocol.game.PacketPlayInUseItem")
|
||||
public class UseItemPacketWrapper extends PacketWrapper.PacketHolder
|
||||
{
|
||||
protected UseItemPacketWrapper(Object handle)
|
||||
|
||||
Reference in new issue
Block a user