Implement a rudimentary setSkinPersistent API

This commit is contained in:
fullwall 2017-10-19 00:27:27 +08:00
parent 636cd7eff7
commit ffbedcd841
5 changed files with 75 additions and 15 deletions

View File

@ -56,4 +56,6 @@ public interface SkinnableEntity extends NPCHolder {
void setSkinName(String name);
void setSkinName(String skinName, boolean forceUpdate);
void setSkinPersistent(String skinName, String signature, String data);
}

View File

@ -380,6 +380,20 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
skinTracker.notifySkinChange(forceUpdate);
}
@Override
public void setSkinPersistent(String skinName, String signature, String data) {
Preconditions.checkNotNull(skinName);
Preconditions.checkNotNull(signature);
Preconditions.checkNotNull(data);
npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, skinName.toLowerCase());
npc.data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA, signature);
npc.data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA, data);
npc.data().setPersistent(NPC.PLAYER_SKIN_USE_LATEST, false);
npc.data().setPersistent("cached-skin-uuid-name", skinName.toLowerCase());
skinTracker.notifySkinChange(false);
}
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
controllerLook.a(target, yawOffset, renderOffset);
}
@ -485,8 +499,14 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public void setSkinName(String skinName, boolean forceUpdate) {
((SkinnableEntity) this.entity).setSkinName(skinName, forceUpdate);
}
@Override
public void setSkinPersistent(String skinName, String signature, String data) {
((SkinnableEntity) this.entity).setSkinPersistent(skinName, signature, data);
}
}
private static final float EPSILON = 0.005F;
private static final Location LOADED_LOCATION = new Location(null, 0, 0, 0);
}

View File

@ -391,6 +391,20 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
skinTracker.notifySkinChange(forceUpdate);
}
@Override
public void setSkinPersistent(String skinName, String signature, String data) {
Preconditions.checkNotNull(skinName);
Preconditions.checkNotNull(signature);
Preconditions.checkNotNull(data);
npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, skinName.toLowerCase());
npc.data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA, signature);
npc.data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA, data);
npc.data().setPersistent(NPC.PLAYER_SKIN_USE_LATEST, false);
npc.data().setPersistent("cached-skin-uuid-name", skinName.toLowerCase());
skinTracker.notifySkinChange(false);
}
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
controllerLook.a(target, yawOffset, renderOffset);
}
@ -497,6 +511,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public void setSkinName(String skinName, boolean forceUpdate) {
((SkinnableEntity) this.entity).setSkinName(skinName, forceUpdate);
}
@Override
public void setSkinPersistent(String skinName, String signature, String data) {
((SkinnableEntity) this.entity).setSkinPersistent(skinName, signature, data);
}
}
private static final float EPSILON = 0.005F;

View File

@ -413,6 +413,20 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
skinTracker.notifySkinChange(forceUpdate);
}
@Override
public void setSkinPersistent(String skinName, String signature, String data) {
Preconditions.checkNotNull(skinName);
Preconditions.checkNotNull(signature);
Preconditions.checkNotNull(data);
npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, skinName.toLowerCase());
npc.data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA, signature);
npc.data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA, data);
npc.data().setPersistent(NPC.PLAYER_SKIN_USE_LATEST, false);
npc.data().setPersistent("cached-skin-uuid-name", skinName.toLowerCase());
skinTracker.notifySkinChange(false);
}
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
controllerLook.a(target, yawOffset, renderOffset);
}
@ -519,6 +533,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public void setSkinName(String skinName, boolean forceUpdate) {
((SkinnableEntity) this.entity).setSkinName(skinName, forceUpdate);
}
@Override
public void setSkinPersistent(String skinName, String signature, String data) {
((SkinnableEntity) this.entity).setSkinPersistent(skinName, signature, data);
}
}
private static final String[][] EMPTY_PROGRESS = new String[0][0];

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_12_R1.entity; import net.minecraft.server.v1_12_R1.DamageSource;
package net.citizensnpcs.nms.v1_12_R1.entity;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
@ -16,6 +16,7 @@ import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityLiving;
import net.minecraft.server.v1_12_R1.EntityWolf;
import net.minecraft.server.v1_12_R1.IBlockData;
@ -67,13 +68,17 @@ public class WolfController extends MobEntityController {
}
@Override
protected SoundEffect cf() {
return NMSImpl.getSoundEffect(npc, super.cf(), NPC.DEATH_SOUND_METADATA);
public void a(float f, float f1, float f2) {
if (npc == null || !npc.isFlyable()) {
super.a(f, f1, f2);
} else {
NMSImpl.flyingMoveLogic(this, f, f1, f2);
}
}
@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
protected SoundEffect cf() {
return NMSImpl.getSoundEffect(npc, super.cf(), NPC.DEATH_SOUND_METADATA);
}
@Override
@ -86,6 +91,11 @@ public class WolfController extends MobEntityController {
}
}
@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
}
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
@ -131,15 +141,6 @@ public class WolfController extends MobEntityController {
// cancelled.
}
@Override
public void a(float f, float f1, float f2) {
if (npc == null || !npc.isFlyable()) {
super.a(f, f1, f2);
} else {
NMSImpl.flyingMoveLogic(this, f, f1, f2);
}
}
@Override
protected SoundEffect F() {
return NMSImpl.getSoundEffect(npc, super.F(), NPC.AMBIENT_SOUND_METADATA);
@ -217,6 +218,5 @@ public class WolfController extends MobEntityController {
public void setSitting(boolean sitting) {
getHandle().setSitting(sitting);
}
}
}