diff --git a/builtin/minecraft/models/item/rc_filled_map_base.json b/builtin/minecraft/models/item/rc_filled_map_base.json new file mode 100644 index 0000000..7154d8f --- /dev/null +++ b/builtin/minecraft/models/item/rc_filled_map_base.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "item/filled_map" + } +} diff --git a/builtin/minecraft/models/item/rc_filled_map_overlay.json b/builtin/minecraft/models/item/rc_filled_map_overlay.json new file mode 100644 index 0000000..e6fdb5b --- /dev/null +++ b/builtin/minecraft/models/item/rc_filled_map_overlay.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "item/filled_map_markings" + } +} diff --git a/src/Output/ItemLibraryGenerator.php b/src/Output/ItemLibraryGenerator.php index 0c3e970..43c59c6 100644 --- a/src/Output/ItemLibraryGenerator.php +++ b/src/Output/ItemLibraryGenerator.php @@ -12,6 +12,7 @@ use Aternos\Renderchest\Output\ItemStyle\EnchantedItemStyleGenerator; use Aternos\Renderchest\Output\ItemStyle\InternalItemStyleGenerator; use Aternos\Renderchest\Output\ItemStyle\ItemStyleGenerator; +use Aternos\Renderchest\Output\ItemStyle\MapItemStyleGenerator; use Aternos\Renderchest\Output\ItemStyle\PotionItemStyleGenerator; use Aternos\Renderchest\Resource\FolderResourceManager; use Aternos\Renderchest\Resource\ResourceLocator; @@ -31,6 +32,7 @@ class ItemLibraryGenerator ArmorItemStyleGenerator::class, PotionItemStyleGenerator::class, ChargedProjectileItemStyleGenerator::class, + MapItemStyleGenerator::class, EnchantedItemStyleGenerator::class, DefaultItemStyleGenerator::class ]; diff --git a/src/Output/ItemStyle/MapItemStyleGenerator.php b/src/Output/ItemStyle/MapItemStyleGenerator.php new file mode 100644 index 0000000..a11aaf6 --- /dev/null +++ b/src/Output/ItemStyle/MapItemStyleGenerator.php @@ -0,0 +1,70 @@ +getLocator() === "minecraft:filled_map"; + } + + /** + * @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_MAP_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); + } +}