Skip to content

Commit

Permalink
Reorder colored items in Creative inventory
Browse files Browse the repository at this point in the history
(Finally catch up to vanilla's 1.19.3 changes.)
  • Loading branch information
TheRealWormbo committed Dec 31, 2024
1 parent bbd236a commit 11e1d0d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 135 deletions.
108 changes: 12 additions & 96 deletions Xplat/src/main/java/vazkii/botania/common/block/BotaniaBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -1082,102 +1082,18 @@ public static void registerBlocks(BiConsumer<Block, ResourceLocation> r) {

public static void registerItemBlocks(BiConsumer<Item, ResourceLocation> r) {
Item.Properties props = BotaniaItems.defaultBuilder();
r.accept(new BlockItem(whiteFlower, props), BuiltInRegistries.BLOCK.getKey(whiteFlower));
r.accept(new BlockItem(orangeFlower, props), BuiltInRegistries.BLOCK.getKey(orangeFlower));
r.accept(new BlockItem(magentaFlower, props), BuiltInRegistries.BLOCK.getKey(magentaFlower));
r.accept(new BlockItem(lightBlueFlower, props), BuiltInRegistries.BLOCK.getKey(lightBlueFlower));
r.accept(new BlockItem(yellowFlower, props), BuiltInRegistries.BLOCK.getKey(yellowFlower));
r.accept(new BlockItem(limeFlower, props), BuiltInRegistries.BLOCK.getKey(limeFlower));
r.accept(new BlockItem(pinkFlower, props), BuiltInRegistries.BLOCK.getKey(pinkFlower));
r.accept(new BlockItem(grayFlower, props), BuiltInRegistries.BLOCK.getKey(grayFlower));
r.accept(new BlockItem(lightGrayFlower, props), BuiltInRegistries.BLOCK.getKey(lightGrayFlower));
r.accept(new BlockItem(cyanFlower, props), BuiltInRegistries.BLOCK.getKey(cyanFlower));
r.accept(new BlockItem(purpleFlower, props), BuiltInRegistries.BLOCK.getKey(purpleFlower));
r.accept(new BlockItem(blueFlower, props), BuiltInRegistries.BLOCK.getKey(blueFlower));
r.accept(new BlockItem(brownFlower, props), BuiltInRegistries.BLOCK.getKey(brownFlower));
r.accept(new BlockItem(greenFlower, props), BuiltInRegistries.BLOCK.getKey(greenFlower));
r.accept(new BlockItem(redFlower, props), BuiltInRegistries.BLOCK.getKey(redFlower));
r.accept(new BlockItem(blackFlower, props), BuiltInRegistries.BLOCK.getKey(blackFlower));
r.accept(new BlockItem(whiteShinyFlower, props), BuiltInRegistries.BLOCK.getKey(whiteShinyFlower));
r.accept(new BlockItem(orangeShinyFlower, props), BuiltInRegistries.BLOCK.getKey(orangeShinyFlower));
r.accept(new BlockItem(magentaShinyFlower, props), BuiltInRegistries.BLOCK.getKey(magentaShinyFlower));
r.accept(new BlockItem(lightBlueShinyFlower, props), BuiltInRegistries.BLOCK.getKey(lightBlueShinyFlower));
r.accept(new BlockItem(yellowShinyFlower, props), BuiltInRegistries.BLOCK.getKey(yellowShinyFlower));
r.accept(new BlockItem(limeShinyFlower, props), BuiltInRegistries.BLOCK.getKey(limeShinyFlower));
r.accept(new BlockItem(pinkShinyFlower, props), BuiltInRegistries.BLOCK.getKey(pinkShinyFlower));
r.accept(new BlockItem(grayShinyFlower, props), BuiltInRegistries.BLOCK.getKey(grayShinyFlower));
r.accept(new BlockItem(lightGrayShinyFlower, props), BuiltInRegistries.BLOCK.getKey(lightGrayShinyFlower));
r.accept(new BlockItem(cyanShinyFlower, props), BuiltInRegistries.BLOCK.getKey(cyanShinyFlower));
r.accept(new BlockItem(purpleShinyFlower, props), BuiltInRegistries.BLOCK.getKey(purpleShinyFlower));
r.accept(new BlockItem(blueShinyFlower, props), BuiltInRegistries.BLOCK.getKey(blueShinyFlower));
r.accept(new BlockItem(brownShinyFlower, props), BuiltInRegistries.BLOCK.getKey(brownShinyFlower));
r.accept(new BlockItem(greenShinyFlower, props), BuiltInRegistries.BLOCK.getKey(greenShinyFlower));
r.accept(new BlockItem(redShinyFlower, props), BuiltInRegistries.BLOCK.getKey(redShinyFlower));
r.accept(new BlockItem(blackShinyFlower, props), BuiltInRegistries.BLOCK.getKey(blackShinyFlower));
r.accept(new BlockItem(whiteFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(whiteFloatingFlower));
r.accept(new BlockItem(orangeFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(orangeFloatingFlower));
r.accept(new BlockItem(magentaFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(magentaFloatingFlower));
r.accept(new BlockItem(lightBlueFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(lightBlueFloatingFlower));
r.accept(new BlockItem(yellowFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(yellowFloatingFlower));
r.accept(new BlockItem(limeFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(limeFloatingFlower));
r.accept(new BlockItem(pinkFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(pinkFloatingFlower));
r.accept(new BlockItem(grayFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(grayFloatingFlower));
r.accept(new BlockItem(lightGrayFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(lightGrayFloatingFlower));
r.accept(new BlockItem(cyanFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(cyanFloatingFlower));
r.accept(new BlockItem(purpleFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(purpleFloatingFlower));
r.accept(new BlockItem(blueFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(blueFloatingFlower));
r.accept(new BlockItem(brownFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(brownFloatingFlower));
r.accept(new BlockItem(greenFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(greenFloatingFlower));
r.accept(new BlockItem(redFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(redFloatingFlower));
r.accept(new BlockItem(blackFloatingFlower, props), BuiltInRegistries.BLOCK.getKey(blackFloatingFlower));
r.accept(new BlockItem(petalBlockWhite, props), BuiltInRegistries.BLOCK.getKey(petalBlockWhite));
r.accept(new BlockItem(petalBlockOrange, props), BuiltInRegistries.BLOCK.getKey(petalBlockOrange));
r.accept(new BlockItem(petalBlockMagenta, props), BuiltInRegistries.BLOCK.getKey(petalBlockMagenta));
r.accept(new BlockItem(petalBlockLightBlue, props), BuiltInRegistries.BLOCK.getKey(petalBlockLightBlue));
r.accept(new BlockItem(petalBlockYellow, props), BuiltInRegistries.BLOCK.getKey(petalBlockYellow));
r.accept(new BlockItem(petalBlockLime, props), BuiltInRegistries.BLOCK.getKey(petalBlockLime));
r.accept(new BlockItem(petalBlockPink, props), BuiltInRegistries.BLOCK.getKey(petalBlockPink));
r.accept(new BlockItem(petalBlockGray, props), BuiltInRegistries.BLOCK.getKey(petalBlockGray));
r.accept(new BlockItem(petalBlockSilver, props), BuiltInRegistries.BLOCK.getKey(petalBlockSilver));
r.accept(new BlockItem(petalBlockCyan, props), BuiltInRegistries.BLOCK.getKey(petalBlockCyan));
r.accept(new BlockItem(petalBlockPurple, props), BuiltInRegistries.BLOCK.getKey(petalBlockPurple));
r.accept(new BlockItem(petalBlockBlue, props), BuiltInRegistries.BLOCK.getKey(petalBlockBlue));
r.accept(new BlockItem(petalBlockBrown, props), BuiltInRegistries.BLOCK.getKey(petalBlockBrown));
r.accept(new BlockItem(petalBlockGreen, props), BuiltInRegistries.BLOCK.getKey(petalBlockGreen));
r.accept(new BlockItem(petalBlockRed, props), BuiltInRegistries.BLOCK.getKey(petalBlockRed));
r.accept(new BlockItem(petalBlockBlack, props), BuiltInRegistries.BLOCK.getKey(petalBlockBlack));
r.accept(new BlockItem(whiteMushroom, props), BuiltInRegistries.BLOCK.getKey(whiteMushroom));
r.accept(new BlockItem(orangeMushroom, props), BuiltInRegistries.BLOCK.getKey(orangeMushroom));
r.accept(new BlockItem(magentaMushroom, props), BuiltInRegistries.BLOCK.getKey(magentaMushroom));
r.accept(new BlockItem(lightBlueMushroom, props), BuiltInRegistries.BLOCK.getKey(lightBlueMushroom));
r.accept(new BlockItem(yellowMushroom, props), BuiltInRegistries.BLOCK.getKey(yellowMushroom));
r.accept(new BlockItem(limeMushroom, props), BuiltInRegistries.BLOCK.getKey(limeMushroom));
r.accept(new BlockItem(pinkMushroom, props), BuiltInRegistries.BLOCK.getKey(pinkMushroom));
r.accept(new BlockItem(grayMushroom, props), BuiltInRegistries.BLOCK.getKey(grayMushroom));
r.accept(new BlockItem(lightGrayMushroom, props), BuiltInRegistries.BLOCK.getKey(lightGrayMushroom));
r.accept(new BlockItem(cyanMushroom, props), BuiltInRegistries.BLOCK.getKey(cyanMushroom));
r.accept(new BlockItem(purpleMushroom, props), BuiltInRegistries.BLOCK.getKey(purpleMushroom));
r.accept(new BlockItem(blueMushroom, props), BuiltInRegistries.BLOCK.getKey(blueMushroom));
r.accept(new BlockItem(brownMushroom, props), BuiltInRegistries.BLOCK.getKey(brownMushroom));
r.accept(new BlockItem(greenMushroom, props), BuiltInRegistries.BLOCK.getKey(greenMushroom));
r.accept(new BlockItem(redMushroom, props), BuiltInRegistries.BLOCK.getKey(redMushroom));
r.accept(new BlockItem(blackMushroom, props), BuiltInRegistries.BLOCK.getKey(blackMushroom));
r.accept(new BlockItem(doubleFlowerWhite, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerWhite));
r.accept(new BlockItem(doubleFlowerOrange, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerOrange));
r.accept(new BlockItem(doubleFlowerMagenta, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerMagenta));
r.accept(new BlockItem(doubleFlowerLightBlue, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerLightBlue));
r.accept(new BlockItem(doubleFlowerYellow, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerYellow));
r.accept(new BlockItem(doubleFlowerLime, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerLime));
r.accept(new BlockItem(doubleFlowerPink, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerPink));
r.accept(new BlockItem(doubleFlowerGray, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerGray));
r.accept(new BlockItem(doubleFlowerLightGray, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerLightGray));
r.accept(new BlockItem(doubleFlowerCyan, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerCyan));
r.accept(new BlockItem(doubleFlowerPurple, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerPurple));
r.accept(new BlockItem(doubleFlowerBlue, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerBlue));
r.accept(new BlockItem(doubleFlowerBrown, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerBrown));
r.accept(new BlockItem(doubleFlowerGreen, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerGreen));
r.accept(new BlockItem(doubleFlowerRed, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerRed));
r.accept(new BlockItem(doubleFlowerBlack, props), BuiltInRegistries.BLOCK.getKey(doubleFlowerBlack));
Stream.<Function<DyeColor, Block>>of(
BotaniaBlocks::getFlower,
BotaniaBlocks::getShinyFlower,
BotaniaBlocks::getFloatingFlower,
BotaniaBlocks::getPetalBlock,
BotaniaBlocks::getMushroom,
BotaniaBlocks::getDoubleFlower
).forEach(
blockGetter -> ColorHelper.supportedColors().map(blockGetter).forEach(
block -> r.accept(new BlockItem(block, props), BuiltInRegistries.BLOCK.getKey(block))
)
);
r.accept(new BlockItem(defaultAltar, props), BuiltInRegistries.BLOCK.getKey(defaultAltar));
r.accept(new BlockItem(forestAltar, props), BuiltInRegistries.BLOCK.getKey(forestAltar));
r.accept(new BlockItem(plainsAltar, props), BuiltInRegistries.BLOCK.getKey(plainsAltar));
Expand Down
23 changes: 11 additions & 12 deletions Xplat/src/main/java/vazkii/botania/common/helper/ColorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import org.jetbrains.annotations.Nullable;

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

Expand All @@ -36,7 +35,7 @@ public static DyeColor getWoolColor(Block b) {
ResourceLocation name = BuiltInRegistries.BLOCK.getKey(b);
if ("minecraft".equals(name.getNamespace()) && name.getPath().endsWith("_wool")) {
String color = name.getPath().substring(0, name.getPath().length() - "_wool".length());
return DyeColor.valueOf(color.toUpperCase(Locale.ROOT));
return DyeColor.byName(color, null);
}
return null;
}
Expand Down Expand Up @@ -66,21 +65,21 @@ public static int getColorLegibleOnGrayBackground(DyeColor color) {
public static Stream<DyeColor> supportedColors() {
return Stream.of(
DyeColor.WHITE,
DyeColor.LIGHT_GRAY,
DyeColor.GRAY,
DyeColor.BLACK,
DyeColor.BROWN,
DyeColor.RED,
DyeColor.ORANGE,
DyeColor.MAGENTA,
DyeColor.LIGHT_BLUE,
DyeColor.YELLOW,
DyeColor.LIME,
DyeColor.PINK,
DyeColor.GRAY,
DyeColor.LIGHT_GRAY,
DyeColor.GREEN,
DyeColor.CYAN,
DyeColor.PURPLE,
DyeColor.LIGHT_BLUE,
DyeColor.BLUE,
DyeColor.BROWN,
DyeColor.GREEN,
DyeColor.RED,
DyeColor.BLACK
DyeColor.PURPLE,
DyeColor.MAGENTA,
DyeColor.PINK
);
}

Expand Down
40 changes: 24 additions & 16 deletions Xplat/src/main/java/vazkii/botania/common/item/BotaniaItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.RecipeSerializer;

import org.jetbrains.annotations.NotNull;

import vazkii.botania.api.block.FloatingFlower;
import vazkii.botania.api.item.AncientWillContainer;
import vazkii.botania.api.mana.spark.SparkUpgradeType;
Expand Down Expand Up @@ -75,22 +77,22 @@ public final class BotaniaItems {
public static final Item obedienceStick = make(prefix(LibItemNames.OBEDIENCE_STICK), new FloralObedienceStickItem(unstackable()));
public static final Item fertilizer = make(prefix(LibItemNames.FERTILIZER), new FloralFertilizerItem(defaultBuilder()));

public static final Item whitePetal = make(prefix("white" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.WHITE), DyeColor.WHITE, defaultBuilder()));
public static final Item orangePetal = make(prefix("orange" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.ORANGE), DyeColor.ORANGE, defaultBuilder()));
public static final Item magentaPetal = make(prefix("magenta" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.MAGENTA), DyeColor.MAGENTA, defaultBuilder()));
public static final Item lightBluePetal = make(prefix("light_blue" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.LIGHT_BLUE), DyeColor.LIGHT_BLUE, defaultBuilder()));
public static final Item yellowPetal = make(prefix("yellow" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.YELLOW), DyeColor.YELLOW, defaultBuilder()));
public static final Item limePetal = make(prefix("lime" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.LIME), DyeColor.LIME, defaultBuilder()));
public static final Item pinkPetal = make(prefix("pink" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.PINK), DyeColor.PINK, defaultBuilder()));
public static final Item grayPetal = make(prefix("gray" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.GRAY), DyeColor.GRAY, defaultBuilder()));
public static final Item lightGrayPetal = make(prefix("light_gray" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.LIGHT_GRAY), DyeColor.LIGHT_GRAY, defaultBuilder()));
public static final Item cyanPetal = make(prefix("cyan" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.CYAN), DyeColor.CYAN, defaultBuilder()));
public static final Item purplePetal = make(prefix("purple" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.PURPLE), DyeColor.PURPLE, defaultBuilder()));
public static final Item bluePetal = make(prefix("blue" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.BLUE), DyeColor.BLUE, defaultBuilder()));
public static final Item brownPetal = make(prefix("brown" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.BROWN), DyeColor.BROWN, defaultBuilder()));
public static final Item greenPetal = make(prefix("green" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.GREEN), DyeColor.GREEN, defaultBuilder()));
public static final Item redPetal = make(prefix("red" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.RED), DyeColor.RED, defaultBuilder()));
public static final Item blackPetal = make(prefix("black" + LibItemNames.PETAL_SUFFIX), new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(DyeColor.BLACK), DyeColor.BLACK, defaultBuilder()));
public static final Item whitePetal = makePetal(DyeColor.WHITE);
public static final Item lightGrayPetal = makePetal(DyeColor.LIGHT_GRAY);
public static final Item grayPetal = makePetal(DyeColor.GRAY);
public static final Item blackPetal = makePetal(DyeColor.BLACK);
public static final Item brownPetal = makePetal(DyeColor.BROWN);
public static final Item redPetal = makePetal(DyeColor.RED);
public static final Item orangePetal = makePetal(DyeColor.ORANGE);
public static final Item yellowPetal = makePetal(DyeColor.YELLOW);
public static final Item limePetal = makePetal(DyeColor.LIME);
public static final Item greenPetal = makePetal(DyeColor.GREEN);
public static final Item cyanPetal = makePetal(DyeColor.CYAN);
public static final Item lightBluePetal = makePetal(DyeColor.LIGHT_BLUE);
public static final Item bluePetal = makePetal(DyeColor.BLUE);
public static final Item purplePetal = makePetal(DyeColor.PURPLE);
public static final Item magentaPetal = makePetal(DyeColor.MAGENTA);
public static final Item pinkPetal = makePetal(DyeColor.PINK);

public static final Item manaSteel = make(prefix(LibItemNames.MANASTEEL_INGOT), new Item(defaultBuilder()));
public static final Item manaPearl = make(prefix(LibItemNames.MANA_PEARL), new Item(defaultBuilder()));
Expand Down Expand Up @@ -397,6 +399,12 @@ private static <T extends Item> T make(ResourceLocation id, T item) {
return item;
}

@NotNull
private static MysticalPetalItem makePetal(DyeColor dyeColor) {
return make(prefix(dyeColor.getName() + LibItemNames.PETAL_SUFFIX),
new MysticalPetalItem(BotaniaBlocks.getBuriedPetal(dyeColor), dyeColor, defaultBuilder()));
}

public static Item.Properties defaultBuilder() {
return XplatAbstractions.INSTANCE.defaultItemBuilder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,21 @@
*/
package vazkii.botania.common.item.material;

import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemNameBlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;

import org.jetbrains.annotations.NotNull;

import vazkii.botania.api.recipe.CustomApothecaryColor;

public class MysticalPetalItem extends BlockItem implements CustomApothecaryColor {
public class MysticalPetalItem extends ItemNameBlockItem implements CustomApothecaryColor {
public final DyeColor color;

public MysticalPetalItem(Block buriedPetals, DyeColor color, Properties props) {
super(buriedPetals, props);
this.color = color;
}

@NotNull
@Override
public String getDescriptionId() {
// Don't take name of the block
return getOrCreateDescriptionId();
}

@Override
public int getParticleColor(ItemStack stack) {
return getPetalLikeColor(color);
Expand Down

0 comments on commit 11e1d0d

Please sign in to comment.