TextComponent.space constructor
TextComponent.space(
- int pixels, {
- Color? color,
- bool? bold,
- bool? underlined,
- bool? italic,
- bool? strikethrough,
- bool? obfuscated,
- TextClickEvent? clickEvent,
- TextHoverEvent? hoverEvent,
- String? insertion,
Attention: This requires a custom negative spaces font by AmberW installed(https://cdn.discordapp.com/attachments/157097006500806656/486915349569208322/NegativeSpaceFont3.zip)
TextComponent.space | |
---|---|
int | the pixel amount you want to move the next TextComponent (positive or negative) |
...same properties... | from TextComponent |
This automatically calculates the custom characters for moving your text horizontally. |
Tellraw(
Entity.All(),
show:[
TextComponent.space(478),
TextComponent('This is moved')
]
)
⇒ tellraw @a [{'text':'\uF82D\uF82C\uF82B\uF829\uF828\uF826'},{'text':'This is moved'}]
Implementation
TextComponent.space(
int pixels, {
this.color,
this.bold,
this.underlined,
this.italic,
this.strikethrough,
this.obfuscated,
this.clickEvent,
this.hoverEvent,
this.insertion,
}) {
var nums = <int, String>{
1: '\uF821',
2: '\uF822',
3: '\uF823',
4: '\uF824',
5: '\uF825',
6: '\uF826',
7: '\uF827',
8: '\uF828',
16: '\uF829',
32: '\uF82A',
64: '\uF82B',
128: '\uF82C',
256: '\uF82D',
512: '\uF82E',
1024: '\uF82F'
};
var negnums = <int, String>{
-1024: '\uF80F',
-512: '\uF80E',
-256: '\uF80D',
-128: '\uF80C',
-64: '\uF80B',
-32: '\uF80A',
-16: '\uF809',
-8: '\uF808',
-7: '\uF807',
-6: '\uF806',
-5: '\uF805',
-4: '\uF804',
-3: '\uF803',
-2: '\uF802',
-1: '\uF801'
};
if (pixels == 0) {
throw ('Please insert a pixel amount on how much you want to move characters');
}
var res = '';
if (pixels > 0) {
for (var value in nums.keys.toList().reversed) {
while (pixels >= value) {
res += nums[value]!;
pixels -= value;
}
}
} else {
for (var value in negnums.keys) {
while (pixels <= value) {
res += negnums[value]!;
pixels -= value;
}
}
}
value = {'text': res};
}