Skip to content

Commit

Permalink
add firework star colors
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtThiemann committed Mar 15, 2024
1 parent 9367dac commit 24947fd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/minecraft/models/item/rc_firework_star_base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "item/firework_star"
}
}
6 changes: 6 additions & 0 deletions builtin/minecraft/models/item/rc_firework_star_overlay.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "item/firework_star_overlay"
}
}
2 changes: 2 additions & 0 deletions src/Output/ItemLibraryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Aternos\Renderchest\Output\ItemStyle\DecoratedPotItemStyleGenerator;
use Aternos\Renderchest\Output\ItemStyle\DefaultItemStyleGenerator;
use Aternos\Renderchest\Output\ItemStyle\EnchantedItemStyleGenerator;
use Aternos\Renderchest\Output\ItemStyle\FireWorkStarItemStyleGenerator;
use Aternos\Renderchest\Output\ItemStyle\InternalItemStyleGenerator;
use Aternos\Renderchest\Output\ItemStyle\ItemStyleGenerator;
use Aternos\Renderchest\Output\ItemStyle\MapItemStyleGenerator;
Expand All @@ -33,6 +34,7 @@ class ItemLibraryGenerator
PotionItemStyleGenerator::class,
ChargedProjectileItemStyleGenerator::class,
MapItemStyleGenerator::class,
FireWorkStarItemStyleGenerator::class,
EnchantedItemStyleGenerator::class,
DefaultItemStyleGenerator::class
];
Expand Down
70 changes: 70 additions & 0 deletions src/Output/ItemStyle/FireWorkStarItemStyleGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Aternos\Renderchest\Output\ItemStyle;

use Aternos\Renderchest\Output\CSS\CSSEntry;
use Aternos\Renderchest\Output\CSS\PropertyListEntry;
use Aternos\Renderchest\Output\Item;
use Aternos\Renderchest\Output\ItemLibraryGenerator;

class FireWorkStarItemStyleGenerator extends ItemStyleGenerator
{
const DEFAULT_COLOR = "#8a8a8a";
const BASE = "minecraft:rc_firework_star_base";
const OVERLAY = "minecraft:rc_firework_star_overlay";
const MASK = "minecraft:firework_star";

/**
* @inheritDoc
*/
public static function hasItemStyle(Item $item): bool
{
return $item->getLocator() === "minecraft:firework_star";
}

/**
* @inheritDoc
*/
public static function getGlobalStyles(ItemLibraryGenerator $generator): array
{
return [];
}

/**
* @param bool $fallback
* @return CSSEntry[]
*/
protected function getStyles(bool $fallback): array
{
$prefix = $this->item->getGenerator()->getPrefix();
return [
(new PropertyListEntry($this->getCssSelector()))
->setProperties([
"background-image" => $this->item->getGenerator()->getItemCSSUrl(static::BASE, $fallback),
"-webkit-mask-image" => $this->item->getGenerator()->getItemCSSUrl(static::MASK, $fallback),
"--" . $prefix . "layer-2-tint" => static::DEFAULT_COLOR
]),
(new PropertyListEntry($this->getCssSelector() . ":before"))
->setProperties([
"background-image" => $this->item->getGenerator()->getItemCSSUrl(static::OVERLAY, $fallback),
"-webkit-mask-image" => $this->item->getGenerator()->getItemCSSUrl(static::OVERLAY, $fallback),
])
];
}

/**
* @inheritDoc
*/
public function getItemStyles(): array
{
return $this->getStyles(false);
}

/**
* @inheritDoc
*/
public function getItemFallbackStyles(): array
{
return $this->getStyles(true);
}
}

0 comments on commit 24947fd

Please sign in to comment.