Skip to content

Commit

Permalink
Test fix for phantoms
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jun 12, 2021
1 parent f2d4c38 commit 8d17d85
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.server.v1_16_R3.ControllerLook;
import net.minecraft.server.v1_16_R3.ControllerMove;
import net.minecraft.server.v1_16_R3.DamageSource;
import net.minecraft.server.v1_16_R3.DataWatcherObject;
import net.minecraft.server.v1_16_R3.Entity;
import net.minecraft.server.v1_16_R3.EntityBoat;
import net.minecraft.server.v1_16_R3.EntityMinecartAbstract;
Expand All @@ -43,6 +44,7 @@ public Phantom getBukkitEntity() {
}

public static class EntityPhantomNPC extends EntityPhantom implements NPCHolder {
boolean calledNMSHeight = false;
private final CitizensNPC npc;
private ControllerLook oldLookController;
private ControllerMove oldMoveController;
Expand All @@ -65,6 +67,17 @@ public EntityPhantomNPC(EntityTypes<? extends EntityPhantom> types, World world,
}
}

@Override
public void a(DataWatcherObject<?> datawatcherobject) {
if (npc != null && !calledNMSHeight) {
calledNMSHeight = true;
NMSImpl.checkAndUpdateHeight(this, datawatcherobject);
calledNMSHeight = false;
}

super.a(datawatcherobject);
}

@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
Expand Down
Expand Up @@ -16,6 +16,7 @@
import net.citizensnpcs.util.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.Difficulty;
import net.minecraft.world.damagesource.DamageSource;
Expand All @@ -42,6 +43,7 @@ public org.bukkit.entity.Phantom getBukkitEntity() {
}

public static class EntityPhantomNPC extends Phantom implements NPCHolder {
boolean calledNMSHeight = false;
private final CitizensNPC npc;
private LookControl oldLookController;
private MoveControl oldMoveController;
Expand Down Expand Up @@ -186,6 +188,17 @@ public boolean onClimbable() {
}
}

@Override
public void onSyncedDataUpdated(EntityDataAccessor<?> datawatcherobject) {
if (npc != null && !calledNMSHeight) {
calledNMSHeight = true;
NMSImpl.checkAndUpdateHeight(this, datawatcherobject);
calledNMSHeight = false;
}

super.onSyncedDataUpdated(datawatcherobject);
}

@Override
public void push(double x, double y, double z) {
Vector vector = Util.callPushEvent(npc, x, y, z);
Expand Down
Expand Up @@ -1465,7 +1465,6 @@ public static void checkAndUpdateHeight(LivingEntity living, EntityDataAccessor<
size = (EntityDimensions) SIZE_FIELD_GETTER.invoke(living);
} catch (Throwable e) {
e.printStackTrace();
living.onSyncedDataUpdated(datawatcherobject);
return;
}
float oldw = size.width;
Expand Down

0 comments on commit 8d17d85

Please sign in to comment.