Skip to content

Commit 83e59f4

Browse files
committed
always reset raw value when tag value is set, initialize tag values
1 parent 5cfc1a4 commit 83e59f4

File tree

6 files changed

+9
-15
lines changed

6 files changed

+9
-15
lines changed

src/Tag/DoubleTag.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public function generatePayload(NbtSerializer $serializer): string
3131
*/
3232
public function setValue(float $value): FloatValueTag
3333
{
34-
if($value !== $this->value) {
35-
$this->resetRawValue();
36-
}
34+
$this->resetRawValue();
3735
return parent::setValue($value);
3836
}
3937

@@ -48,4 +46,4 @@ protected function readPayload(Reader $reader): Tag
4846
$this->value = $reader->getSerializer()->decodeDouble($this->rawValue);
4947
return $this;
5048
}
51-
}
49+
}

src/Tag/FloatTag.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public function generatePayload(NbtSerializer $serializer): string
2929
*/
3030
public function setValue(float $value): FloatValueTag
3131
{
32-
if($value !== $this->value) {
33-
$this->resetRawValue();
34-
}
32+
$this->resetRawValue();
3533
return parent::setValue($value);
3634
}
3735

@@ -46,4 +44,4 @@ protected function readPayload(Reader $reader): Tag
4644
$this->value = $reader->getSerializer()->decodeFloat($this->rawValue);
4745
return $this;
4846
}
49-
}
47+
}

src/Tag/FloatValueTag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
abstract class FloatValueTag extends Tag
66
{
7-
protected float $value;
7+
protected float $value = 0;
88

99
/**
1010
* @return float

src/Tag/IntValueTag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
abstract class IntValueTag extends Tag
66
{
7-
protected int $value;
7+
protected int $value = 0;
88

99
/**
1010
* @return int

src/Tag/LongTag.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public function generatePayload(NbtSerializer $serializer): string
3030
*/
3131
public function setValue(int $value): IntValueTag
3232
{
33-
if($value !== $this->value) {
34-
$this->resetRawValue();
35-
}
33+
$this->resetRawValue();
3634
return parent::setValue($value);
3735
}
3836

@@ -47,4 +45,4 @@ protected function readPayload(Reader $reader): Tag
4745
$this->value = $result->getValue();
4846
return $this;
4947
}
50-
}
48+
}

src/Tag/StringTag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class StringTag extends Tag
1010
{
1111
public const TYPE = TagType::TAG_String;
1212

13-
protected string $value;
13+
protected string $value = "";
1414

1515
/**
1616
* @return string

0 commit comments

Comments
 (0)