Fix packets

This commit is contained in:
2024-12-28 16:08:50 +01:00
parent 3c1d46398d
commit 33f41869b6
4 changed files with 25 additions and 42 deletions
@@ -9,9 +9,9 @@ import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;
@Getter
public class RBlockDisplay extends RDisplay {
@Getter
private BlockData block = Material.AIR.createBlockData();
public RBlockDisplay(REntityServer server, Location location) {
@@ -20,7 +20,7 @@ public class RBlockDisplay extends RDisplay {
private static final Class<?> iBlockDataClass = Reflection.getClass("{nms.world}.level.block.state.IBlockData");
private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", iBlockDataClass);
private static final Object blockWatcher = BountifulWrapper.impl.getDataWatcherObject(23, iBlockDataClass);
private static final Object blockWatcher = BountifulWrapper.impl.getDataWatcherObject(22, iBlockDataClass);
public void setBlock(BlockData block) {
this.block = block;
if (Core.getVersion() >= 20) {
@@ -12,39 +12,29 @@ import org.bukkit.util.Transformation;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class RDisplay extends REntity {
@Getter
public abstract class RDisplay extends REntity {
@Getter
private Transformation transform = new Transformation(new Vector3f(), new Quaternionf(0, 0, 0, 1), new Vector3f(1, 1, 1), new Quaternionf(0, 0, 0, 1));
@Getter
private int interpolationDuration = 0;
@Getter
private float viewRange = 1.0F;
@Getter
private float shadowRadius = 0.0F;
@Getter
private float shadowStrength = 1.0F;
@Getter
private float displayWidth = 0.0F;
@Getter
private float displayHeight = 0.0F;
@Getter
private int interpolationDelay = 0;
@Getter
private Display.Billboard billboard = Display.Billboard.FIXED;
@Getter
private Color glowColorOverride = null;
@Getter
private Display.Brightness brightness = null;
protected RDisplay(REntityServer server, EntityType entityType, Location location) {
@@ -65,8 +55,8 @@ public class RDisplay extends REntity {
}
}
private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(9, Integer.class);
private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(10, Integer.class);
private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(8, Integer.class);
private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(9, Integer.class);
public void setInterpolationDuration(int interpolationDuration) {
this.interpolationDuration = interpolationDuration;
if (Core.getVersion() >= 20) {
@@ -75,7 +65,7 @@ public class RDisplay extends REntity {
}
}
private static final Object viewRangeWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Float.class);
private static final Object viewRangeWatcher = BountifulWrapper.impl.getDataWatcherObject(16, Float.class);
public void setViewRange(float viewRange) {
this.viewRange = viewRange;
if (Core.getVersion() >= 20) {
@@ -83,7 +73,7 @@ public class RDisplay extends REntity {
}
}
private static final Object shadowRadiusWatcher = BountifulWrapper.impl.getDataWatcherObject(18, Float.class);
private static final Object shadowRadiusWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Float.class);
public void setShadowRadius(float shadowRadius) {
this.shadowRadius = shadowRadius;
if (Core.getVersion() >= 20) {
@@ -91,7 +81,7 @@ public class RDisplay extends REntity {
}
}
private static final Object shadowStrengthWatcher = BountifulWrapper.impl.getDataWatcherObject(19, Float.class);
private static final Object shadowStrengthWatcher = BountifulWrapper.impl.getDataWatcherObject(18, Float.class);
public void setShadowStrength(float shadowStrength) {
this.shadowStrength = shadowStrength;
if (Core.getVersion() >= 20) {
@@ -99,7 +89,7 @@ public class RDisplay extends REntity {
}
}
private static final Object displayWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(20, Float.class);
private static final Object displayWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(19, Float.class);
public void setDisplayWidth(float displayWidth) {
this.displayWidth = displayWidth;
if (Core.getVersion() >= 20) {
@@ -107,7 +97,7 @@ public class RDisplay extends REntity {
}
}
private static final Object displayHeightWatcher = BountifulWrapper.impl.getDataWatcherObject(21, Float.class);
private static final Object displayHeightWatcher = BountifulWrapper.impl.getDataWatcherObject(20, Float.class);
public void setDisplayHeight(float displayHeight) {
this.displayHeight = displayHeight;
if (Core.getVersion() >= 20) {
@@ -115,7 +105,7 @@ public class RDisplay extends REntity {
}
}
private static final Object interpolationDelayWatcher = BountifulWrapper.impl.getDataWatcherObject(22, Integer.class);
private static final Object interpolationDelayWatcher = BountifulWrapper.impl.getDataWatcherObject(7, Integer.class);
public void setInterpolationDelay(int interpolationDelay) {
this.interpolationDelay = interpolationDelay;
if (Core.getVersion() >= 20) {
@@ -123,7 +113,7 @@ public class RDisplay extends REntity {
}
}
private static final Object billboardWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Byte.class);
private static final Object billboardWatcher = BountifulWrapper.impl.getDataWatcherObject(14, Byte.class);
public void setBillboard(Display.Billboard billboard) {
this.billboard = billboard;
if (Core.getVersion() >= 20) {
@@ -131,7 +121,7 @@ public class RDisplay extends REntity {
}
}
private static final Object glowColorOverrideWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Integer.class);
private static final Object glowColorOverrideWatcher = BountifulWrapper.impl.getDataWatcherObject(21, Integer.class);
public void setGlowColorOverride(Color glowColorOverride) {
this.glowColorOverride = glowColorOverride;
if (Core.getVersion() >= 20) {
@@ -139,7 +129,7 @@ public class RDisplay extends REntity {
}
}
private static final Object brightnessWatcher = BountifulWrapper.impl.getDataWatcherObject(16, Integer.class);
private static final Object brightnessWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Integer.class);
public void setBrightness(Display.Brightness brightness) {
this.brightness = brightness;
if (Core.getVersion() >= 20) {
@@ -9,12 +9,11 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemDisplay;
import org.bukkit.inventory.ItemStack;
@Getter
public class RItemDisplay extends RDisplay {
@Getter
private ItemStack itemStack;
@Getter
private ItemDisplay.ItemDisplayTransform itemDisplayTransform;
public RItemDisplay(REntityServer server, Location location) {
@@ -22,16 +21,16 @@ public class RItemDisplay extends RDisplay {
}
private static final Class<?> itemStackClass = Reflection.getClass("{nms.world}.item.ItemStack");
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("{obc}.inventory.CraftItemStack"), "asNMSCopy", itemStackClass);
private static final Object itemStackWatcher = BountifulWrapper.impl.getDataWatcherObject(23, itemStackClass);
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("{obc}.inventory.CraftItemStack"), "asNMSCopy", itemStackClass, ItemStack.class);
private static final Object itemStackWatcher = BountifulWrapper.impl.getDataWatcherObject(22, itemStackClass);
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
if (Core.getVersion() >= 20) {
server.updateEntity(this, getDataWatcherPacket(itemStackWatcher, asNMSCopy.invoke(itemStack)));
server.updateEntity(this, getDataWatcherPacket(itemStackWatcher, asNMSCopy.invoke(null, itemStack)));
}
}
private static final Object itemDisplayTransformWatcher = BountifulWrapper.impl.getDataWatcherObject(24, Byte.class);
private static final Object itemDisplayTransformWatcher = BountifulWrapper.impl.getDataWatcherObject(23, Byte.class);
public void setItemDisplayTransform(ItemDisplay.ItemDisplayTransform itemDisplayTransform) {
this.itemDisplayTransform = itemDisplayTransform;
if (Core.getVersion() >= 20) {
@@ -9,27 +9,21 @@ import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.TextDisplay;
@Getter
public class RTextDisplay extends RDisplay {
@Getter
private String text = "";
@Getter
private int lineWidth = 200;
@Getter
private byte textOpacity = (byte) -1;
@Getter
private boolean shadowed = false;
@Getter
private boolean seeThrough = false;
@Getter
private boolean defaultBackground = false;
@Getter
private TextDisplay.TextAlignment alignment = TextDisplay.TextAlignment.CENTER;
public RTextDisplay(REntityServer server, Location location) {
@@ -37,7 +31,7 @@ public class RTextDisplay extends RDisplay {
}
private static final Class<?> iChatBaseComponent = Reflection.getClass("{nms.network.chat}.IChatBaseComponent");
private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(23, iChatBaseComponent);
private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(22, iChatBaseComponent);
public void setText(String text) {
this.text = text;
if (Core.getVersion() >= 20) {
@@ -45,7 +39,7 @@ public class RTextDisplay extends RDisplay {
}
}
private static final Object lineWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(24, Integer.class);
private static final Object lineWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(23, Integer.class);
public void setLineWidth(int lineWidth) {
this.lineWidth = lineWidth;
if (Core.getVersion() >= 20) {
@@ -53,7 +47,7 @@ public class RTextDisplay extends RDisplay {
}
}
private static final Object textOpacityWatcher = BountifulWrapper.impl.getDataWatcherObject(26, Byte.class);
private static final Object textOpacityWatcher = BountifulWrapper.impl.getDataWatcherObject(25, Byte.class);
public void setTextOpacity(byte textOpacity) {
this.textOpacity = textOpacity;
if (Core.getVersion() >= 20) {
@@ -61,7 +55,7 @@ public class RTextDisplay extends RDisplay {
}
}
private static final Object textStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(27, Byte.class);
private static final Object textStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(26, Byte.class);
public void setShadowed(boolean shadowed) {
this.shadowed = shadowed;