minecraft-source/src/net/minecraft/world/level/block/PlayerHeadBlock.java

42 lines
1.7 KiB
Java

package net.minecraft.world.level.block;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntity;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import org.apache.commons.lang3.StringUtils;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
public class PlayerHeadBlock extends SkullBlock {
protected PlayerHeadBlock(final Properties c) {
super(Types.PLAYER, c);
}
@Override
public void setPlacedBy(final Level bjt, final BlockPos fk, final BlockState byg, @Nullable final LivingEntity akw, final ItemStack bek) {
super.setPlacedBy(bjt, fk, byg, akw, bek);
final BlockEntity bwi7 = bjt.getBlockEntity(fk);
if (bwi7 instanceof SkullBlockEntity) {
final SkullBlockEntity bxf8 = (SkullBlockEntity)bwi7;
GameProfile gameProfile9 = null;
if (bek.hasTag()) {
final CompoundTag jt10 = bek.getTag();
if (jt10.contains("SkullOwner", 10)) {
gameProfile9 = NbtUtils.readGameProfile(jt10.getCompound("SkullOwner"));
}
else if (jt10.contains("SkullOwner", 8) && !StringUtils.isBlank((CharSequence)jt10.getString("SkullOwner"))) {
gameProfile9 = new GameProfile((UUID)null, jt10.getString("SkullOwner"));
}
}
bxf8.setOwner(gameProfile9);
}
}
}