Fix REntity for 1.15.2-1.21.3

<1.15.2: Untested
This commit is contained in:
2024-12-01 11:39:23 +01:00
parent 41233b7710
commit 7927a195d6
15 changed files with 127 additions and 73 deletions
@@ -25,6 +25,7 @@ dependencies {
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
compileOnly(project(":SpigotCore:SpigotCore_18", "default"))
compileOnly(project(":SpigotCore:SpigotCore_14", "default"))
compileOnly(project(":SpigotCore:SpigotCore_9", "default"))
compileOnly(libs.fawe21)
@@ -0,0 +1,42 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.world.entity.PositionMoveRotation;
import net.minecraft.world.phys.Vec3D;
public class BountifulWrapper21 extends BountifulWrapper9 {
@Override
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset) {
try {
Reflection.FieldAccessor<PositionMoveRotation> field = Reflection.getField(packetClass, PositionMoveRotation.class, 0);
return (packet, x, y, z, pitch, yaw) -> {
PositionMoveRotation pos = field.get(packet);
field.set(packet, new PositionMoveRotation(new Vec3D(x, y, z), pos.b(), pitch, yaw));
};
} catch (IllegalArgumentException e) {
return super.getPositionSetter(packetClass, fieldOffset);
}
}
}
@@ -28,8 +28,12 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.enginehub.linbus.stream.LinBinaryIO;
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.tree.LinCompoundTag;
@@ -38,7 +42,7 @@ import org.enginehub.linbus.tree.LinTagType;
import java.io.*;
public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper {
public class WorldEditWrapper21 implements WorldEditWrapper {
@Override
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
@@ -94,4 +98,26 @@ public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper {
}
}
}
@Override
public org.bukkit.util.Vector getOrigin(Clipboard clipboard) {
return new org.bukkit.util.Vector(clipboard.getOrigin().x(), clipboard.getOrigin().y(), clipboard.getOrigin().z());
}
@Override
public Vector getMinimum(Region region) {
return new Vector(region.getMinimumPoint().x(), region.getMinimumPoint().y(), region.getMinimumPoint().z());
}
@Override
public Vector getMaximum(Region region) {
return new Vector(region.getMaximumPoint().x(), region.getMaximumPoint().y(), region.getMaximumPoint().z());
}
@Override
public Vector applyTransform(Vector vector, Transform transform) {
Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ());
v = transform.apply(v);
return new org.bukkit.util.Vector(v.x(), v.y(), v.z());
}
}