Skip to content

Commit

Permalink
Fix portal removal timing
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 29, 2020
1 parent a269bf1 commit bbf3f28
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions main/src/main/java/net/citizensnpcs/trait/SkinTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public void setSkinName(String name, boolean forceUpdate) {
* Sets the skin data directly, respawning the NPC if spawned
*
* @param skinName
* Skin name, for caching purposes
* @param signature
* {@link #getSignature()}
* @param data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
Expand Down Expand Up @@ -45,6 +46,7 @@
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.ChatComponentText;
import net.minecraft.server.v1_15_R1.DamageSource;
import net.minecraft.server.v1_15_R1.DimensionManager;
import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.EntityHuman;
import net.minecraft.server.v1_15_R1.EntityPlayer;
Expand Down Expand Up @@ -77,8 +79,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
private final CitizensNPC npc;
private final Location packetLocationCache = new Location(null, 0, 0, 0);
private final SkinPacketTracker skinTracker;

private int updateCounter = 0;
private int yawUpdateRequiredTicks;

public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,
PlayerInteractManager playerInteractManager, NPC npc) {
Expand Down Expand Up @@ -316,7 +318,22 @@ public boolean isNavigating() {
}

public void livingEntityBaseTick() {
// doPortalTick code
boolean old = this.af;
if (af && ag + 1 > ab()) {
af = false;
Bukkit.getServer().getScheduler().runTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
portalCooldown = ba();
a(world.worldProvider.getDimensionManager().getType() == DimensionManager.NETHER
? DimensionManager.OVERWORLD
: DimensionManager.NETHER, TeleportCause.NETHER_PORTAL);
}
});
}
entityBaseTick();
af = old;
this.az = this.aA;
if (this.hurtTicks > 0) {
this.hurtTicks -= 1;
Expand Down Expand Up @@ -381,7 +398,7 @@ public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
}

public void setTargetLook(Location target) {
controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40);
controllerLook.a(target.getX(), target.getY(), target.getZ());
}

public void setTracked() {
Expand Down Expand Up @@ -423,6 +440,16 @@ public void tick() {
}

npc.update();
/*
double diff = this.yaw - this.aK;
if (diff != 40 && diff != -40) {
++this.yawUpdateRequiredTicks;
}
if (this.yawUpdateRequiredTicks > 5) {
this.yaw = (diff > -40 && diff < 0) || (diff > 0 && diff > 40) ? this.aK - 40 : this.aK + 40;
this.yawUpdateRequiredTicks = 0;
}
*/
}

public void updateAI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void a() {
// this.a.yaw = MathHelper.b(this.a.yaw, this.a.aK, 40F);
// this.a.aK = this.a(this.a.aK, this.a.aI, 10.0F);
}

if (!this.a.getNavigation().m()) {
this.a.aK = MathHelper.b(this.a.aK, this.a.aI, 75);
}
Expand Down

0 comments on commit bbf3f28

Please sign in to comment.