Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify supported dyes to allow co-existing with dye addon mods #4764

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import vazkii.botania.common.entity.BotaniaEntities;
import vazkii.botania.common.entity.GaiaGuardianEntity;
import vazkii.botania.common.handler.*;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.helper.PlayerHelper;
import vazkii.botania.common.impl.BotaniaAPIImpl;
import vazkii.botania.common.impl.DefaultHornHarvestable;
Expand Down Expand Up @@ -317,9 +318,9 @@ private void registerCapabilities() {
Blocks.VINE, Blocks.CAVE_VINES, Blocks.CAVE_VINES_PLANT, Blocks.TWISTING_VINES,
Blocks.TWISTING_VINES_PLANT, Blocks.WEEPING_VINES, Blocks.WEEPING_VINES_PLANT);
BotaniaFabricCapabilities.HORN_HARVEST.registerForBlocks((w, p, s, be, c) -> DefaultHornHarvestable.INSTANCE,
Arrays.stream(DyeColor.values()).map(BotaniaBlocks::getMushroom).toArray(Block[]::new));
ColorHelper.supportedColors().map(BotaniaBlocks::getMushroom).toArray(Block[]::new));
BotaniaFabricCapabilities.HORN_HARVEST.registerForBlocks((w, p, s, be, c) -> DefaultHornHarvestable.INSTANCE,
Arrays.stream(DyeColor.values()).map(BotaniaBlocks::getShinyFlower).toArray(Block[]::new));
ColorHelper.supportedColors().map(BotaniaBlocks::getShinyFlower).toArray(Block[]::new));
BotaniaFabricCapabilities.HOURGLASS_TRIGGER.registerForBlockEntities((be, c) -> {
var torch = (AnimatedTorchBlockEntity) be;
return hourglass -> torch.toggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;

import vazkii.botania.common.block.BotaniaBlocks;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.data.BlockTagProvider;
import vazkii.botania.xplat.XplatAbstractions;

Expand Down Expand Up @@ -44,9 +44,9 @@ protected void addTags(HolderLookup.Provider provider) {
List.of(GLASS, GLASS_ALT).forEach(t -> tag(t).add(BotaniaBlocks.manaGlass, BotaniaBlocks.elfGlass, BotaniaBlocks.bifrostPerm));
List.of(GLASS_PANE, GLASS_PANE_ALT).forEach(t -> tag(t).add(BotaniaBlocks.managlassPane, BotaniaBlocks.alfglassPane, BotaniaBlocks.bifrostPane));

for (DyeColor color : DyeColor.values()) {
ColorHelper.supportedColors().forEach(color -> {
this.tag(MUSHROOMS).add(BotaniaBlocks.getMushroom(color));
}
});

var vanillaTags = List.of(
BlockTags.COAL_ORES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;

import vazkii.botania.common.block.BotaniaBlocks;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.item.relic.DiceOfFateItem;
import vazkii.botania.data.ItemTagProvider;

Expand All @@ -40,9 +40,9 @@ public FabricItemTagProvider(PackOutput packOutput, CompletableFuture<HolderLook

@Override
protected void addTags(HolderLookup.Provider provider) {
for (var color : DyeColor.values()) {
ColorHelper.supportedColors().forEach(color -> {
this.tag(MUSHROOMS).add(BotaniaBlocks.getMushroom(color).asItem());
}
});
this.copy(FabricBlockTagProvider.MUSHROOMS, MUSHROOMS);
this.copy(FabricBlockTagProvider.QUARTZ_BLOCKS, QUARTZ_BLOCKS);
this.copy(FabricBlockTagProvider.GLASS, GLASS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import vazkii.botania.common.entity.BotaniaEntities;
import vazkii.botania.common.entity.GaiaGuardianEntity;
import vazkii.botania.common.handler.*;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.helper.PlayerHelper;
import vazkii.botania.common.impl.BotaniaAPIImpl;
import vazkii.botania.common.impl.DefaultHornHarvestable;
Expand Down Expand Up @@ -558,9 +559,9 @@ private void registerBlockLookasides() {
Blocks.VINE, Blocks.CAVE_VINES, Blocks.CAVE_VINES_PLANT, Blocks.TWISTING_VINES,
Blocks.TWISTING_VINES_PLANT, Blocks.WEEPING_VINES, Blocks.WEEPING_VINES_PLANT);
CapabilityUtil.registerBlockLookaside(BotaniaForgeCapabilities.HORN_HARVEST, (w, p, s) -> DefaultHornHarvestable.INSTANCE,
Arrays.stream(DyeColor.values()).map(BotaniaBlocks::getMushroom).toArray(Block[]::new));
ColorHelper.supportedColors().map(BotaniaBlocks::getMushroom).toArray(Block[]::new));
CapabilityUtil.registerBlockLookaside(BotaniaForgeCapabilities.HORN_HARVEST, (w, p, s) -> DefaultHornHarvestable.INSTANCE,
Arrays.stream(DyeColor.values()).map(BotaniaBlocks::getShinyFlower).toArray(Block[]::new));
ColorHelper.supportedColors().map(BotaniaBlocks::getShinyFlower).toArray(Block[]::new));
CapabilityUtil.registerBlockLookaside(BotaniaForgeCapabilities.MANA_GHOST, (w, p, s) -> ((ManaCollisionGhost) s.getBlock()),
BotaniaBlocks.manaDetector,
BotaniaBlocks.abstrusePlatform, BotaniaBlocks.infrangiblePlatform, BotaniaBlocks.spectralPlatform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper;

import vazkii.botania.common.block.BotaniaBlocks;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.lib.BotaniaTags;
import vazkii.botania.common.lib.LibMisc;

Expand Down Expand Up @@ -40,9 +40,9 @@ protected void addTags(HolderLookup.Provider provider) {
BotaniaBlocks.lavenderQuartz, BotaniaBlocks.redQuartz, BotaniaBlocks.elfQuartz, BotaniaBlocks.sunnyQuartz
);

for (DyeColor color : DyeColor.values()) {
ColorHelper.supportedColors().forEach(color -> {
this.tag(MUSHROOMS).add(BotaniaBlocks.getMushroom(color));
}
});

tag(TagKey.create(Registries.BLOCK, new ResourceLocation("buzzier_bees", "flower_blacklist")))
.addTag(BotaniaTags.Blocks.MYSTICAL_FLOWERS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import vazkii.botania.client.model.TinyPotatoModel;
import vazkii.botania.client.render.block_entity.CorporeaCrystalCubeBlockEntityRenderer;
import vazkii.botania.client.render.block_entity.ManaPumpBlockEntityRenderer;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.item.equipment.bauble.FlugelTiaraItem;
import vazkii.botania.common.item.equipment.bauble.ThirdEyeItem;
import vazkii.botania.common.item.relic.KeyOfTheKingsLawItem;
Expand All @@ -33,7 +34,6 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static vazkii.botania.common.lib.ResourceLocationHelper.modelResourceLocation;
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
Expand Down Expand Up @@ -66,7 +66,7 @@ public class MiscellaneousModels {
private static final ResourceLocation manaSpreaderScaffoldingId = prefix("block/mana_spreader_scaffolding");
private static final ResourceLocation elvenSpreaderScaffoldingId = prefix("block/elven_spreader_scaffolding");
private static final ResourceLocation gaiaSpreaderScaffoldingId = prefix("block/gaia_spreader_scaffolding");
private static final Map<DyeColor, ResourceLocation> spreaderPaddingIds = new EnumMap<>(Stream.of(DyeColor.values()).collect(Collectors.toMap(Function.identity(), color -> prefix("block/" + color.getSerializedName() + "_spreader_padding"))));
private static final Map<DyeColor, ResourceLocation> spreaderPaddingIds = new EnumMap<>(ColorHelper.supportedColors().collect(Collectors.toMap(Function.identity(), color -> prefix("block/" + color.getSerializedName() + "_spreader_padding"))));

public static final MiscellaneousModels INSTANCE = new MiscellaneousModels();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import vazkii.botania.common.block.red_string.*;
import vazkii.botania.common.entity.EnderAirBottleEntity;
import vazkii.botania.common.entity.VineBallEntity;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.item.BotaniaItems;
import vazkii.botania.common.item.block.BlockItemWithSpecialRenderer;
import vazkii.botania.common.item.block.TinyPotatoBlockItem;
Expand Down Expand Up @@ -683,10 +684,10 @@ public static void registerBlocks(BiConsumer<Block, ResourceLocation> r) {
Triple.of(BotaniaBlocks::getPottedShinyFlower, LibBlockNames.POTTED_PREFIX, LibBlockNames.SHINY_FLOWER_SUFFIX),
Triple.of(BotaniaBlocks::getPottedMushroom, LibBlockNames.POTTED_PREFIX, LibBlockNames.MUSHROOM_SUFFIX)
).forEach(coloredBlockRegistration -> {
for (DyeColor dyeColor : DyeColor.values()) {
ColorHelper.supportedColors().forEach(dyeColor -> {
r.accept(coloredBlockRegistration.getLeft().apply(dyeColor),
prefix(coloredBlockRegistration.getMiddle() + dyeColor.getName() + coloredBlockRegistration.getRight()));
}
});
});

r.accept(defaultAltar, prefix(LibBlockNames.APOTHECARY_PREFIX + PetalApothecaryBlock.Variant.DEFAULT.name().toLowerCase(Locale.ROOT)));
Expand Down Expand Up @@ -1850,7 +1851,7 @@ public static Block getPottedMushroom(DyeColor color) {
}

public static void registerFlowerPotPlants(BiConsumer<ResourceLocation, Supplier<? extends Block>> consumer) {
Stream.of(DyeColor.values()).forEach(dyeColor -> {
ColorHelper.supportedColors().forEach(dyeColor -> {
consumer.accept(prefix(dyeColor.getName() + MYSTICAL_FLOWER_SUFFIX), () -> getPottedFlower(dyeColor));
consumer.accept(prefix(dyeColor.getName() + SHINY_FLOWER_SUFFIX), () -> getPottedShinyFlower(dyeColor));
consumer.accept(prefix(dyeColor.getName() + MUSHROOM_SUFFIX), () -> getPottedMushroom(dyeColor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
Expand All @@ -21,10 +20,10 @@
import vazkii.botania.common.block.block_entity.corporea.*;
import vazkii.botania.common.block.block_entity.mana.*;
import vazkii.botania.common.block.block_entity.red_string.*;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.xplat.XplatAbstractions;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -55,7 +54,7 @@ public class BotaniaBlockEntities {
public static final BlockEntityType<PlatformBlockEntity> PLATFORM = type(prefix(LibBlockNames.PLATFORM), PlatformBlockEntity::new, abstrusePlatform, spectralPlatform, infrangiblePlatform);
public static final BlockEntityType<AlfheimPortalBlockEntity> ALF_PORTAL = type(prefix(LibBlockNames.ALF_PORTAL), AlfheimPortalBlockEntity::new, alfPortal);
public static final BlockEntityType<BifrostBlockEntity> BIFROST = type(prefix(LibBlockNames.BIFROST), BifrostBlockEntity::new, bifrost);
public static final BlockEntityType<FloatingFlowerBlockEntity> MINI_ISLAND = type(prefix(LibBlockNames.MINI_ISLAND), FloatingFlowerBlockEntity::new, Arrays.stream(DyeColor.values()).map(BotaniaBlocks::getFloatingFlower).toArray(Block[]::new));
public static final BlockEntityType<FloatingFlowerBlockEntity> MINI_ISLAND = type(prefix(LibBlockNames.MINI_ISLAND), FloatingFlowerBlockEntity::new, ColorHelper.supportedColors().map(BotaniaBlocks::getFloatingFlower).toArray(Block[]::new));
public static final BlockEntityType<TinyPotatoBlockEntity> TINY_POTATO = type(prefix(LibBlockNames.TINY_POTATO), TinyPotatoBlockEntity::new, tinyPotato);
public static final BlockEntityType<LifeImbuerBlockEntity> SPAWNER_CLAW = type(prefix(LibBlockNames.SPAWNER_CLAW), LifeImbuerBlockEntity::new, spawnerClaw);
public static final BlockEntityType<EnderOverseerBlockEntity> ENDER_EYE = type(prefix(LibBlockNames.ENDER_EYE_BLOCK), EnderOverseerBlockEntity::new, enderEye);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package vazkii.botania.common.handler;

import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.ItemLike;

import vazkii.botania.common.block.BotaniaBlocks;
import vazkii.botania.common.helper.ColorHelper;
import vazkii.botania.common.item.BotaniaItems;

import java.util.function.BiConsumer;
Expand All @@ -18,13 +18,13 @@ public static void init(BiConsumer<ItemLike, Float> registrationMethod) {
// unused here: final float chanceHighest = 1.0f;

// see https://github.com/VazkiiMods/Botania/issues/4263#issuecomment-1529130978
for (final var dyeColor : DyeColor.values()) {
ColorHelper.supportedColors().forEach(dyeColor -> {
registrationMethod.accept(BotaniaItems.getPetal(dyeColor), chanceLowest);
registrationMethod.accept(BotaniaBlocks.getPetalBlock(dyeColor), chanceLow);
registrationMethod.accept(BotaniaBlocks.getFlower(dyeColor), chanceMid);
registrationMethod.accept(BotaniaBlocks.getDoubleFlower(dyeColor), chanceMid);
registrationMethod.accept(BotaniaBlocks.getMushroom(dyeColor), chanceMid);
}
});

registrationMethod.accept(BotaniaBlocks.cellBlock, chanceHigh);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package vazkii.botania.common.handler;

import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.Blocks;

import vazkii.botania.api.BotaniaAPI;
Expand All @@ -17,48 +16,23 @@
public class PaintableData {
public static void init() {
BotaniaAPI.instance().registerPaintableBlock(Blocks.GLASS, ColorHelper.STAINED_GLASS_MAP);
for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.STAINED_GLASS_MAP.apply(color), ColorHelper.STAINED_GLASS_MAP);
}

BotaniaAPI.instance().registerPaintableBlock(Blocks.GLASS_PANE, ColorHelper.STAINED_GLASS_PANE_MAP);
for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.STAINED_GLASS_PANE_MAP.apply(color), ColorHelper.STAINED_GLASS_PANE_MAP);
}

BotaniaAPI.instance().registerPaintableBlock(Blocks.TERRACOTTA, ColorHelper.TERRACOTTA_MAP);
for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.TERRACOTTA_MAP.apply(color), ColorHelper.TERRACOTTA_MAP);
}
BotaniaAPI.instance().registerPaintableBlock(Blocks.CANDLE, ColorHelper.CANDLE_MAP);
BotaniaAPI.instance().registerPaintableBlock(Blocks.CANDLE_CAKE, ColorHelper.CANDLE_CAKE_MAP);

for (DyeColor color : DyeColor.values()) {
ColorHelper.supportedColors().forEach(color -> {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.STAINED_GLASS_MAP.apply(color), ColorHelper.STAINED_GLASS_MAP);
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.STAINED_GLASS_PANE_MAP.apply(color), ColorHelper.STAINED_GLASS_PANE_MAP);
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.TERRACOTTA_MAP.apply(color), ColorHelper.TERRACOTTA_MAP);
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.GLAZED_TERRACOTTA_MAP.apply(color), ColorHelper.GLAZED_TERRACOTTA_MAP);
}

for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.WOOL_MAP.apply(color), ColorHelper.WOOL_MAP);
}

for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.CARPET_MAP.apply(color), ColorHelper.CARPET_MAP);
}

for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.CONCRETE_MAP.apply(color), ColorHelper.CONCRETE_MAP);
}

for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.CONCRETE_POWDER_MAP.apply(color), ColorHelper.CONCRETE_POWDER_MAP);
}

BotaniaAPI.instance().registerPaintableBlock(Blocks.CANDLE, ColorHelper.CANDLE_MAP);
for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.CANDLE_MAP.apply(color), ColorHelper.CANDLE_MAP);
}

BotaniaAPI.instance().registerPaintableBlock(Blocks.CANDLE_CAKE, ColorHelper.CANDLE_CAKE_MAP);
for (DyeColor color : DyeColor.values()) {
BotaniaAPI.instance().registerPaintableBlock(ColorHelper.CANDLE_CAKE_MAP.apply(color), ColorHelper.CANDLE_CAKE_MAP);
}
});
}
}
22 changes: 22 additions & 0 deletions Xplat/src/main/java/vazkii/botania/common/helper/ColorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Locale;
import java.util.function.Function;
import java.util.stream.Stream;

public final class ColorHelper {
public static final Function<DyeColor, Block> STAINED_GLASS_MAP = color -> BuiltInRegistries.BLOCK.get(new ResourceLocation(color.getSerializedName() + "_stained_glass"));
Expand Down Expand Up @@ -62,5 +63,26 @@ public static int getColorLegibleOnGrayBackground(DyeColor color) {
};
}

public static Stream<DyeColor> supportedColors() {
return Stream.of(
DyeColor.WHITE,
DyeColor.ORANGE,
DyeColor.MAGENTA,
DyeColor.LIGHT_BLUE,
DyeColor.YELLOW,
DyeColor.LIME,
DyeColor.PINK,
DyeColor.GRAY,
DyeColor.LIGHT_GRAY,
DyeColor.CYAN,
DyeColor.PURPLE,
DyeColor.BLUE,
DyeColor.BROWN,
DyeColor.GREEN,
DyeColor.RED,
DyeColor.BLACK
);
}

private ColorHelper() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@
import java.util.stream.IntStream;

public class FlowerPouchItem extends Item {
public static final int SIZE = 2 * DyeColor.values().length;
public static final int DYE_COUNT = 16;
public static final int SIZE = 2 * DYE_COUNT;

public FlowerPouchItem(Properties props) {
super(props);
}

public static Item getFlowerForSlot(int slot) {
if (slot < 16) {
if (slot < DYE_COUNT) {
DyeColor color = DyeColor.byId(slot);
return BotaniaBlocks.getFlower(color).asItem();
} else {
DyeColor color = DyeColor.byId(slot - 16);
DyeColor color = DyeColor.byId(slot - DYE_COUNT);
return BotaniaBlocks.getDoubleFlower(color).asItem();
}
}
Expand Down
Loading
Loading