Add upside down for all disguises, add rainbow wool for sheep

This commit is contained in:
libraryaddict 2020-05-12 13:36:39 +12:00
parent a018973eeb
commit 52eec84d23
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
5 changed files with 55 additions and 15 deletions

View File

@ -325,6 +325,16 @@ public abstract class Disguise {
bar.addPlayer((Player) getEntity());
}
public boolean isUpsideDown() {
return getWatcher().isUpsideDown();
}
public Disguise setUpsideDown(boolean upsideDown) {
getWatcher().setUpsideDown(upsideDown);
return this;
}
private void createRunnable() {
final boolean alwaysSendVelocity;

View File

@ -53,6 +53,8 @@ public class FlagWatcher {
private boolean sleeping;
private boolean swimming;
private transient boolean previouslySneaking;
@Getter
private boolean upsideDown;
public FlagWatcher(Disguise disguise) {
this.disguise = (TargetedDisguise) disguise;
@ -84,6 +86,9 @@ public class FlagWatcher {
cloned.equipment = equipment.clone(cloned);
cloned.modifiedEntityAnimations = Arrays.copyOf(modifiedEntityAnimations, modifiedEntityAnimations.length);
cloned.addEntityAnimations = addEntityAnimations;
cloned.upsideDown = upsideDown;
cloned.swimming = swimming;
cloned.sleeping = sleeping;
return cloned;
}
@ -120,6 +125,25 @@ public class FlagWatcher {
getEquipment().setChestplate(itemStack);
}
@Deprecated
public void setInternalUpsideDown(boolean upsideDown) {
this.upsideDown = upsideDown;
}
public void setUpsideDown(boolean upsideDown) {
if (isUpsideDown() == upsideDown) {
return;
}
this.upsideDown = upsideDown;
if (getDisguise().isPlayerDisguise()) {
((PlayerDisguise) getDisguise()).setUpsideDown(upsideDown);
} else {
setInteralCustomName(isUpsideDown() ? "Dinnerbone" : "");
}
}
public List<WrappedWatchableObject> convert(List<WrappedWatchableObject> list) {
List<WrappedWatchableObject> newList = new ArrayList<>();
HashSet<Integer> sentValues = new HashSet<>();
@ -377,6 +401,10 @@ public class FlagWatcher {
return;
}
setInteralCustomName(name);
}
protected void setInteralCustomName(String name) {
if (Strings.isNullOrEmpty(name)) {
if (NmsVersion.v1_13.isSupported()) {
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.empty());

View File

@ -32,8 +32,6 @@ public class PlayerDisguise extends TargetedDisguise {
private boolean explicitNameVisible = false;
private UUID uuid = UUID.randomUUID();
private volatile DisguiseUtilities.DScoreTeam scoreboardName;
@Getter
private boolean upsideDown;
private PlayerDisguise() {
super(DisguiseType.PLAYER);
@ -197,7 +195,7 @@ public class PlayerDisguise extends TargetedDisguise {
return this;
}
this.upsideDown = upsideDown;
getWatcher().setInternalUpsideDown(upsideDown);
if (isDisguiseInUse()) {
resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "Dinnerbone", true);

View File

@ -37,14 +37,6 @@ public class PlayerWatcher extends LivingWatcher {
((PlayerDisguise) getDisguise()).setNameVisible(nameVisible);
}
public boolean isUpsideDown() {
return ((PlayerDisguise) getDisguise()).isUpsideDown();
}
public void setUpsideDown(boolean upsideDown) {
((PlayerDisguise) getDisguise()).setUpsideDown(upsideDown);
}
@RandomDefaultValue
public String getName() {
return ((PlayerDisguise) getDisguise()).getName();

View File

@ -15,10 +15,6 @@ public class SheepWatcher extends AgeableWatcher {
return AnimalColor.getColorByWool(((int) getData(MetaIndex.SHEEP_WOOL) & 15)).getDyeColor();
}
public boolean isSheared() {
return (getData(MetaIndex.SHEEP_WOOL) & 16) != 0;
}
@Deprecated
public void setColor(AnimalColor color) {
setColor(color.getDyeColor());
@ -31,6 +27,22 @@ public class SheepWatcher extends AgeableWatcher {
sendData(MetaIndex.SHEEP_WOOL);
}
public boolean isRainbowWool() {
return "jeb_".equals(getCustomName());
}
public void setRainbowWool(boolean rainbow) {
if (isRainbowWool() == rainbow) {
return;
}
setInteralCustomName("jeb_");
}
public boolean isSheared() {
return (getData(MetaIndex.SHEEP_WOOL) & 16) != 0;
}
public void setSheared(boolean flag) {
byte b0 = getData(MetaIndex.SHEEP_WOOL);