Fix 1.19.4 NMS

This commit is contained in:
NotAlexNoyle committed 2026-04-01 15:22:03 -04:00
1 parent 0f29f9a6e5
commit fa7ee8130b
4 files changed
+40 -52

No files matched your search

+3 -2
View File
@@ -13,7 +13,7 @@ plugins {
}
group = "de.sprax2013"
version = "1.14-OG"
version = "1.18.0"
val pluginName = "BetterChairs"
val selfMavenLocalRepo = System.getProperty("SELF_MAVEN_LOCAL_REPO")?.let(::file)?.takeIf { it.isDirectory }
@@ -197,6 +197,7 @@ project(":modules:betterchairs-plugin") {
}
archiveClassifier.set("")
archiveBaseName.set("BetterChairs")
archiveVersion.set(rootProject.version.toString())
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
relocate("betterchairs.nms", "de.sprax2013.betterchairs.nms")
relocate("de.sprax2013.lime", "de.sprax2013.betterchairs.third_party.de.sprax2013.lime")
@@ -264,7 +265,7 @@ subprojects
"compileOnly"(project(":modules:betterchairs-api"))
val ver = nmsVersions.getValue(nms.name)
"compileOnly"("org.spigotmc:spigot-api:$ver")
val mojangMapped = ver.startsWith("1.19")
val mojangMapped = ver.startsWith("1.19") && nms.name != "betterchairs-v1_19_R3"
if (mojangMapped) {
"compileOnly"("org.spigotmc:spigot:$ver:remapped-mojang")
} else {
@@ -3,14 +3,14 @@ package betterchairs.nms.v1_19_R3;
import de.sprax2013.betterchairs.ChairManager;
import de.sprax2013.betterchairs.ChairUtils;
import de.sprax2013.betterchairs.CustomChairEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.decoration.EntityArmorStand;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.level.World;
import org.bukkit.Bukkit;
import org.bukkit.Location;
class CustomArmorStand extends ArmorStand implements CustomChairEntity {
class CustomArmorStand extends EntityArmorStand implements CustomChairEntity {
private boolean remove = false;
private final int regenerationAmplifier;
@@ -19,7 +19,7 @@ class CustomArmorStand extends ArmorStand implements CustomChairEntity {
/**
* @param regenerationAmplifier provide a negative value to disable regeneration
*/
public CustomArmorStand(ServerLevel world, double d0, double d1, double d2, int regenerationAmplifier) {
public CustomArmorStand(World world, double d0, double d1, double d2, int regenerationAmplifier) {
super(world, d0, d1, d2);
this.regenerationAmplifier = regenerationAmplifier;
@@ -32,47 +32,40 @@ class CustomArmorStand extends ArmorStand implements CustomChairEntity {
}
@Override
public void tick() {
public void l() { // tick
if (this.remove) return; // If the ArmorStand is being removed, no need to bother
if (this.tickCount % 10 == 0) return; // Only run every 10 ticks
if (this.ag % 10 == 0) return; // Only run every 10 ticks
Entity passenger = getFirstPassenger();
Entity passenger = this.cN();
if (!(passenger instanceof Player)) {
if (!(passenger instanceof EntityHuman)) {
this.remove = true;
getBukkitEntity().remove();
this.getBukkitEntity().remove();
return;
}
// Rotate the ArmorStand together with its passenger
// Not happy about using Bukkit API here (+ scheduling) but I don't see a good alternative with all the
// obfuscation
Bukkit.getScheduler()
.runTask(ChairManager.getPlugin(), () -> getBukkitEntity().setRotation(passenger.getBukkitYaw(), 0));
Bukkit.getScheduler().runTask(ChairManager.getPlugin(), () -> this.getBukkitEntity()
.setRotation(passenger.getBukkitYaw(), 0));
if (ChairUtils.didChairEntityMove(this.expectedLocation, getX(), getY(), getZ())) {
this.expectedLocation.setY(Math.min(getY(), this.expectedLocation.getY()));
if (ChairUtils.didChairEntityMove(this.expectedLocation, this.dl(), this.dn(), this.dr())) {
this.expectedLocation.setY(Math.min(this.dn(), this.expectedLocation.getY()));
teleportToWithTicket(
this.expectedLocation.getX(), this.expectedLocation.getY(), this.expectedLocation.getZ());
this.n(this.expectedLocation.getX(), this.expectedLocation.getY(), this.expectedLocation.getZ());
}
ChairUtils.applyRegeneration(((Player) passenger).getBukkitEntity(), this.regenerationAmplifier);
ChairUtils.applyRegeneration(((EntityHuman) passenger).getBukkitEntity(), this.regenerationAmplifier);
}
@Override
public void kill() {
public void a(Entity.RemovalReason removalReason) {
// Prevents the ArmorStand from getting killed unexpectedly
if (shouldDie()) super.kill();
}
@Override
public void remove(Entity.RemovalReason removalReason) {
// Prevents the ArmorStand from getting killed unexpectedly
if (shouldDie()) super.remove(removalReason);
if (shouldDie()) super.a(removalReason);
}
private boolean shouldDie() {
return this.remove || getPassengers().isEmpty() || !(getFirstPassenger() instanceof Player);
return this.remove || this.cM().isEmpty() || !(this.cN() instanceof EntityHuman);
}
}
@@ -3,20 +3,20 @@ package betterchairs.nms.v1_19_R3;
import de.sprax2013.betterchairs.ChairManager;
import de.sprax2013.betterchairs.ChairUtils;
import de.sprax2013.betterchairs.CustomChairEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Arrow;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.entity.projectile.EntityTippedArrow;
import net.minecraft.world.level.World;
import org.bukkit.Bukkit;
class CustomArrow extends Arrow implements CustomChairEntity {
class CustomArrow extends EntityTippedArrow implements CustomChairEntity {
private boolean remove = false;
private final int regenerationAmplifier;
/**
* @param regenerationAmplifier provide a negative value to disable regeneration
*/
public CustomArrow(ServerLevel world, double d0, double d1, double d2, int regenerationAmplifier) {
public CustomArrow(World world, double d0, double d1, double d2, int regenerationAmplifier) {
super(world, d0, d1, d2);
this.regenerationAmplifier = regenerationAmplifier;
@@ -28,40 +28,34 @@ class CustomArrow extends Arrow implements CustomChairEntity {
}
@Override
public void tick() {
public void l() { // tick
if (this.remove) return; // If the entity is being removed, no need to bother
if (this.tickCount % 10 == 0) return; // Only run every 10 ticks
if (this.ag % 10 == 0) return; // Only run every 10 ticks
Entity passenger = getFirstPassenger();
Entity passenger = this.cN();
if (!(passenger instanceof Player)) {
if (!(passenger instanceof EntityHuman)) {
this.remove = true;
getBukkitEntity().remove();
this.getBukkitEntity().remove();
return;
}
// Rotate the entity together with its passenger
// Not happy about using Bukkit API here (+ scheduling) but I don't see a good alternative with all the
// obfuscation
Bukkit.getScheduler()
.runTask(ChairManager.getPlugin(), () -> getBukkitEntity().setRotation(passenger.getBukkitYaw(), 0));
Bukkit.getScheduler().runTask(ChairManager.getPlugin(), () -> this.getBukkitEntity()
.setRotation(passenger.getBukkitYaw(), 0));
ChairUtils.applyRegeneration(((Player) passenger).getBukkitEntity(), this.regenerationAmplifier);
ChairUtils.applyRegeneration(((EntityHuman) passenger).getBukkitEntity(), this.regenerationAmplifier);
}
@Override
public void kill() {
public void a(Entity.RemovalReason removalReason) {
// Prevents the ArmorStand from getting killed unexpectedly
if (shouldDie()) super.kill();
}
@Override
public void remove(Entity.RemovalReason removalReason) {
// Prevents the ArmorStand from getting killed unexpectedly
if (shouldDie()) super.remove(removalReason);
if (shouldDie()) super.a(removalReason);
}
private boolean shouldDie() {
return this.remove || getPassengers().isEmpty() || !(getFirstPassenger() instanceof Player);
return this.remove || this.cM().isEmpty() || !(this.cN() instanceof EntityHuman);
}
}
@@ -6,7 +6,7 @@ import de.sprax2013.betterchairs.ChairUtils;
import de.sprax2013.betterchairs.CustomChairEntity;
import de.sprax2013.betterchairs.Messages;
import java.util.Objects;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.Entity;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -27,7 +27,7 @@ public class v1_19_R3 extends ChairNMS {
@Override
public @NotNull org.bukkit.entity.Entity spawnChairEntity(
@NotNull Location loc, int regenerationAmplifier, boolean useArmorStand) {
ServerLevel nmsWorld = ((CraftWorld) Objects.requireNonNull(loc.getWorld())).getHandle();
WorldServer nmsWorld = ((CraftWorld) Objects.requireNonNull(loc.getWorld())).getHandle();
Entity nmsEntity;