get rid of dynamic field assignments

nearly there now... eventually
This commit is contained in:
Dylan K. Taylor 2017-11-17 10:43:33 +00:00
parent 19315dfd06
commit e0654b85ba
2 changed files with 6 additions and 6 deletions

View File

@ -369,7 +369,7 @@ class Item implements ItemIds, \JsonSerializable{
/** @var CompoundTag $entry */
foreach($ench as $k => $entry){
if($entry->getShort("id") === $enchantment->getId()){
$ench->{$k} = new CompoundTag("", [
$ench[$k] = new CompoundTag("", [
new ShortTag("id", $enchantment->getId()),
new ShortTag("lvl", $enchantment->getLevel())
]);
@ -380,7 +380,7 @@ class Item implements ItemIds, \JsonSerializable{
}
if(!$found){
$ench->{count($ench)} = new CompoundTag("", [
$ench[count($ench)] = new CompoundTag("", [
new ShortTag("id", $enchantment->getId()),
new ShortTag("lvl", $enchantment->getLevel())
]);
@ -512,18 +512,18 @@ class Item implements ItemIds, \JsonSerializable{
* @return NamedTag|null
*/
public function getNamedTagEntry(string $name) : ?NamedTag{
return $this->getNamedTag()->{$name} ?? null;
return $this->getNamedTag()->getTag($name) ?? null;
}
public function setNamedTagEntry(NamedTag $new) : void{
$tag = $this->getNamedTag();
$tag->{$new->getName()} = $new;
$tag->setTag($new);
$this->setNamedTag($tag);
}
public function removeNamedTagEntry(string $name) : void{
$tag = $this->getNamedTag();
unset($tag->{$name});
$tag->removeTag($name);
$this->setNamedTag($tag);
}

View File

@ -208,7 +208,7 @@ abstract class Tile extends Position{
if(!($customBlockDataTag instanceof NamedTag)){
continue;
}
$nbt->{$customBlockDataTag->getName()} = $customBlockDataTag;
$nbt->setTag($customBlockDataTag);
}
}
}