This commit is contained in:
themode 2020-08-20 19:06:55 +02:00
parent 56cace9402
commit 6b778f425a
3 changed files with 16 additions and 17 deletions

View File

@ -1909,7 +1909,7 @@ public class Player extends LivingEntity implements CommandSender {
/**
* Reset data from the current block the player is mining.
* If the currently mined block (or if there isn't any) is not a CustomBlock, nothing append
* If the currently mined block (or if there isn't any) is not a {@link CustomBlock}, nothing happen
*/
public void resetTargetBlock() {
if (targetCustomBlock != null) {
@ -1962,18 +1962,21 @@ public class Player extends LivingEntity implements CommandSender {
* @return a {@link PlayerInfoPacket} to add the player
*/
protected PlayerInfoPacket getAddPlayerToList() {
final String textures = skin == null ? "" : skin.getTextures();
final String signature = skin == null ? null : skin.getSignature();
PlayerInfoPacket playerInfoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.ADD_PLAYER);
PlayerInfoPacket.AddPlayer addPlayer =
new PlayerInfoPacket.AddPlayer(getUuid(), getUsername(), getGameMode(), getLatency());
addPlayer.displayName = displayName;
PlayerInfoPacket.AddPlayer.Property prop =
new PlayerInfoPacket.AddPlayer.Property("textures", textures, signature);
addPlayer.properties.add(prop);
// Skin support
if (skin != null) {
final String textures = skin.getTextures();
final String signature = skin.getSignature();
PlayerInfoPacket.AddPlayer.Property prop =
new PlayerInfoPacket.AddPlayer.Property("textures", textures, signature);
addPlayer.properties.add(prop);
}
playerInfoPacket.playerInfos.add(addPlayer);
return playerInfoPacket;

View File

@ -54,9 +54,9 @@ public class PlayerSkin {
final JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
final JsonArray propertiesArray = jsonObject.get("properties").getAsJsonArray();
Iterator<JsonElement> iterator = propertiesArray.iterator();
final Iterator<JsonElement> iterator = propertiesArray.iterator();
while (iterator.hasNext()) {
JsonObject propertyObject = iterator.next().getAsJsonObject();
final JsonObject propertyObject = iterator.next().getAsJsonObject();
final String name = propertyObject.get("name").getAsString();
if (!name.equals("textures"))
continue;
@ -82,7 +82,7 @@ public class PlayerSkin {
try {
final String response = URLUtils.getText(url);
JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
final JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
final String uuid = jsonObject.get("id").getAsString();
return fromUuid(uuid);
} catch (IOException e) {

View File

@ -64,13 +64,13 @@ public class PlayerDiggingListener {
}
} else {
// Player is not mining a custom block, be sure that he doesn't have the effect
removeEffect(player);
player.resetTargetBlock();
}
}
break;
case CANCELLED_DIGGING:
// Remove custom block target
removeEffect(player);
player.resetTargetBlock();
sendAcknowledgePacket(player, blockPosition, blockStateId,
ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING, true);
@ -119,7 +119,7 @@ public class PlayerDiggingListener {
private static void breakBlock(Instance instance, Player player, BlockPosition blockPosition) {
// Finished digging, remove effect if any
removeEffect(player);
player.resetTargetBlock();
// Unverified block break, client is fully responsive
instance.breakBlock(player, blockPosition);
@ -148,10 +148,6 @@ public class PlayerDiggingListener {
player.getPlayerConnection().sendPacket(entityEffectPacket);
}
private static void removeEffect(Player player) {
player.resetTargetBlock();
}
private static void sendAcknowledgePacket(Player player, BlockPosition blockPosition, int blockStateId,
ClientPlayerDiggingPacket.Status status, boolean success) {
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();