mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 03:57:35 +01:00
Merge pull request #516 from JCThePants/skins2-4
fix NPC skin layers sometimes don't show (Issue #505)
This commit is contained in:
commit
446e4d2ef0
@ -235,6 +235,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
controllerMove = new PlayerControllerMove(this);
|
||||
navigation = new PlayerNavigation(this, world);
|
||||
NMS.setStepHeight(this, 1); // the default (0) breaks step climbing
|
||||
|
||||
setSkinFlags((byte)0xFF);
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
@ -278,6 +280,18 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
controllerJump.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinFlags(byte flags) {
|
||||
// set skin flag byte (DataWatcher API is lacking so
|
||||
// catch the NPE as a sign that this is a MC 1.7 server without the
|
||||
// skin flag)
|
||||
try {
|
||||
getDataWatcher().watch(10, flags);
|
||||
} catch (NullPointerException e) {
|
||||
getDataWatcher().a(10, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinName(String name) {
|
||||
Preconditions.checkNotNull(name);
|
||||
@ -333,15 +347,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
private void updatePackets(boolean navigating) {
|
||||
|
||||
if (world.getWorld().getFullTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) {
|
||||
// set skin flag byte to all visible (DataWatcher API is lacking so
|
||||
// catch the NPE as a sign that this is a MC 1.7 server without the
|
||||
// skin flag)
|
||||
try {
|
||||
datawatcher.watch(10, Byte.valueOf((byte) 127));
|
||||
} catch (NullPointerException e) {
|
||||
datawatcher.a(10, Byte.valueOf((byte) 127));
|
||||
}
|
||||
|
||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||
Packet<?>[] packets = new Packet[navigating ? 5 : 6];
|
||||
if (!navigating) {
|
||||
@ -422,6 +427,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinFlags(byte flags) {
|
||||
((SkinnableEntity) this.entity).setSkinFlags(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinName(String name) {
|
||||
((SkinnableEntity) this.entity).setSkinName(name);
|
||||
|
@ -9,11 +9,6 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public interface SkinnableEntity extends NPCHolder {
|
||||
|
||||
/**
|
||||
* Get the entities skin packet tracker.
|
||||
*/
|
||||
SkinPacketTracker getSkinTracker();
|
||||
|
||||
/**
|
||||
* Get the bukkit entity.
|
||||
*/
|
||||
@ -29,12 +24,33 @@ public interface SkinnableEntity extends NPCHolder {
|
||||
*/
|
||||
String getSkinName();
|
||||
|
||||
/**
|
||||
* Get the entities skin packet tracker.
|
||||
*/
|
||||
SkinPacketTracker getSkinTracker();
|
||||
|
||||
/**
|
||||
* Set the bit flags that represent the skin layer parts visibility.
|
||||
*
|
||||
* <p>
|
||||
* Setting the skin flags automatically updates the NPC skin.
|
||||
* </p>
|
||||
*
|
||||
* @param flags
|
||||
* The bit flags.
|
||||
*/
|
||||
void setSkinFlags(byte flags);
|
||||
|
||||
/**
|
||||
* Set the name of the player whose skin the NPC
|
||||
* uses.
|
||||
*
|
||||
* <p>Setting the skin name automatically updates and
|
||||
* respawn the NPC.</p>
|
||||
* <p>
|
||||
* Setting the skin name automatically updates and respawn the NPC.
|
||||
* </p>
|
||||
*
|
||||
* @param name
|
||||
* The skin name.
|
||||
*/
|
||||
void setSkinName(String name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user