summaryrefslogtreecommitdiff
path: root/src/main/java/lv/enes/mc/eris_alchemy/utils
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-01-11 23:11:27 +0100
committerGravatar Uko Kokņevičs2024-01-11 23:11:27 +0100
commitbca6a74e9a17e04de419743850f66af96a6473cc (patch)
tree6f81c0ceb615b0a85810df89ea9acafe6112eba9 /src/main/java/lv/enes/mc/eris_alchemy/utils
parentMaking SheetsMixin more extensible (diff)
downloadmc-eris-alchemy-bca6a74e9a17e04de419743850f66af96a6473cc.tar.gz
mc-eris-alchemy-bca6a74e9a17e04de419743850f66af96a6473cc.tar.xz
mc-eris-alchemy-bca6a74e9a17e04de419743850f66af96a6473cc.zip
Move default emc values to JSON files in datapack
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/utils')
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/utils/AxeUtils.java18
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/utils/BlockUtils.java15
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/utils/CoralUtils.java44
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/utils/DyeUtils.java62
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/utils/ItemUtils.java20
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/utils/TagUtils.java16
6 files changed, 14 insertions, 161 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/AxeUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/AxeUtils.java
deleted file mode 100644
index 22c0bad..0000000
--- a/src/main/java/lv/enes/mc/eris_alchemy/utils/AxeUtils.java
+++ /dev/null
@@ -1,18 +0,0 @@
1package lv.enes.mc.eris_alchemy.utils;
2
3import net.minecraft.world.item.AxeItem;
4import net.minecraft.world.item.Tier;
5import net.minecraft.world.level.block.Block;
6
7import java.util.Map;
8
9/** This extends AxeItem only to read the STRIPPABLES variable :3 */
10public final class AxeUtils extends AxeItem {
11 public static Map<Block, Block> getStrippables() {
12 return STRIPPABLES;
13 }
14
15 private AxeUtils(Tier material, float attackDamage, float attackSpeed, Properties settings) {
16 super(material, attackDamage, attackSpeed, settings);
17 }
18}
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/BlockUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/BlockUtils.java
deleted file mode 100644
index 88b6231..0000000
--- a/src/main/java/lv/enes/mc/eris_alchemy/utils/BlockUtils.java
+++ /dev/null
@@ -1,15 +0,0 @@
1package lv.enes.mc.eris_alchemy.utils;
2
3import net.minecraft.core.registries.BuiltInRegistries;
4import net.minecraft.tags.TagKey;
5import net.minecraft.world.level.block.Block;
6
7import java.util.stream.Stream;
8
9public final class BlockUtils {
10 public static Stream<Block> streamTag(TagKey<Block> tag) {
11 return TagUtils.stream(BuiltInRegistries.BLOCK, tag);
12 }
13
14 private BlockUtils() {}
15}
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/CoralUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/CoralUtils.java
deleted file mode 100644
index 1136c9e..0000000
--- a/src/main/java/lv/enes/mc/eris_alchemy/utils/CoralUtils.java
+++ /dev/null
@@ -1,44 +0,0 @@
1package lv.enes.mc.eris_alchemy.utils;
2
3import net.minecraft.tags.BlockTags;
4import net.minecraft.world.level.block.*;
5
6import java.util.stream.Stream;
7
8public final class CoralUtils {
9 /**
10 * @see lv.enes.mc.eris_alchemy.mixin.CoralBlockMixin
11 * @see lv.enes.mc.eris_alchemy.mixin.CoralFanBlockMixin
12 * @see lv.enes.mc.eris_alchemy.mixin.CoralPlantBlockMixin
13 * @see lv.enes.mc.eris_alchemy.mixin.CoralWallFanBlockMixin
14 */
15 public interface CoralSuper {
16 Block lv_enes_mc$getDead();
17 }
18
19 public static Stream<CoralBlock> streamAllCoralBlocks() {
20 return BlockUtils.streamTag(BlockTags.CORAL_BLOCKS).map(b -> (CoralBlock)b);
21 }
22
23 public static Stream<BaseCoralPlantTypeBlock> streamAllCorals() {
24 return BlockUtils.streamTag(BlockTags.CORALS).map(b -> (BaseCoralPlantTypeBlock)b);
25 }
26
27 public static Stream<Block> streamAllDeadCoralBlocks() {
28 return streamAllCoralBlocks().map(CoralUtils::getDeadCoralBlock);
29 }
30
31 public static Stream<Block> streamAllDeadCorals() {
32 return streamAllCorals().map(CoralUtils::getDeadCoral);
33 }
34
35 public static Block getDeadCoral(BaseCoralPlantTypeBlock live ) {
36 return ((CoralSuper)live).lv_enes_mc$getDead();
37 }
38
39 public static Block getDeadCoralBlock(CoralBlock live) {
40 return ((CoralSuper)live).lv_enes_mc$getDead();
41 }
42
43 private CoralUtils() {}
44}
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/DyeUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/DyeUtils.java
deleted file mode 100644
index 3ceb965..0000000
--- a/src/main/java/lv/enes/mc/eris_alchemy/utils/DyeUtils.java
+++ /dev/null
@@ -1,62 +0,0 @@
1package lv.enes.mc.eris_alchemy.utils;
2
3import net.minecraft.world.item.DyeColor;
4import net.minecraft.world.item.DyeItem;
5import net.minecraft.world.level.block.Block;
6import net.minecraft.world.level.block.Blocks;
7import net.minecraft.world.level.block.ConcretePowderBlock;
8import net.minecraft.world.level.block.ShulkerBoxBlock;
9
10public final class DyeUtils {
11 public static Block getConcrete(DyeColor color) {
12 return switch (color) {
13 case BLACK -> Blocks.BLACK_CONCRETE;
14 case BLUE -> Blocks.BLUE_CONCRETE;
15 case BROWN -> Blocks.BROWN_CONCRETE;
16 case CYAN -> Blocks.CYAN_CONCRETE;
17 case GRAY -> Blocks.GRAY_CONCRETE;
18 case GREEN -> Blocks.GREEN_CONCRETE;
19 case LIGHT_BLUE -> Blocks.LIGHT_BLUE_CONCRETE;
20 case LIGHT_GRAY -> Blocks.LIGHT_GRAY_CONCRETE;
21 case LIME -> Blocks.LIME_CONCRETE;
22 case MAGENTA -> Blocks.MAGENTA_CONCRETE;
23 case ORANGE -> Blocks.ORANGE_CONCRETE;
24 case PINK -> Blocks.PINK_CONCRETE;
25 case PURPLE -> Blocks.PURPLE_CONCRETE;
26 case RED -> Blocks.RED_CONCRETE;
27 case WHITE -> Blocks.WHITE_CONCRETE;
28 case YELLOW -> Blocks.YELLOW_CONCRETE;
29 };
30 }
31
32 public static ConcretePowderBlock getConcretePowder(DyeColor color) {
33 return (ConcretePowderBlock)switch (color) {
34 case BLACK -> Blocks.BLACK_CONCRETE_POWDER;
35 case BLUE -> Blocks.BLUE_CONCRETE_POWDER;
36 case BROWN -> Blocks.BROWN_CONCRETE_POWDER;
37 case CYAN -> Blocks.CYAN_CONCRETE_POWDER;
38 case GRAY -> Blocks.GRAY_CONCRETE_POWDER;
39 case GREEN -> Blocks.GREEN_CONCRETE_POWDER;
40 case LIGHT_BLUE -> Blocks.LIGHT_BLUE_CONCRETE_POWDER;
41 case LIGHT_GRAY -> Blocks.LIGHT_GRAY_CONCRETE_POWDER;
42 case LIME -> Blocks.LIME_CONCRETE_POWDER;
43 case MAGENTA -> Blocks.MAGENTA_CONCRETE_POWDER;
44 case ORANGE -> Blocks.ORANGE_CONCRETE_POWDER;
45 case PINK -> Blocks.PINK_CONCRETE_POWDER;
46 case PURPLE -> Blocks.PURPLE_CONCRETE_POWDER;
47 case RED -> Blocks.RED_CONCRETE_POWDER;
48 case WHITE -> Blocks.WHITE_CONCRETE_POWDER;
49 case YELLOW -> Blocks.YELLOW_CONCRETE_POWDER;
50 };
51 }
52
53 public static DyeItem getDye(DyeColor color) {
54 return DyeItem.byColor(color);
55 }
56
57 public static ShulkerBoxBlock getShulkerBox(DyeColor color) {
58 return (ShulkerBoxBlock)ShulkerBoxBlock.getBlockByColor(color);
59 }
60
61 private DyeUtils() {}
62}
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/ItemUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/ItemUtils.java
index 26d4405..4414d06 100644
--- a/src/main/java/lv/enes/mc/eris_alchemy/utils/ItemUtils.java
+++ b/src/main/java/lv/enes/mc/eris_alchemy/utils/ItemUtils.java
@@ -1,14 +1,22 @@
1package lv.enes.mc.eris_alchemy.utils; 1package lv.enes.mc.eris_alchemy.utils;
2 2
3import net.minecraft.core.Holder;
3import net.minecraft.core.registries.BuiltInRegistries; 4import net.minecraft.core.registries.BuiltInRegistries;
4import net.minecraft.tags.TagKey; 5import net.minecraft.resources.ResourceLocation;
5import net.minecraft.world.item.Item; 6import net.minecraft.world.item.ItemStack;
6 7import net.minecraft.world.level.ItemLike;
7import java.util.stream.Stream;
8 8
9public final class ItemUtils { 9public final class ItemUtils {
10 public static Stream<Item> streamTag(TagKey<Item> tag) { 10 public static <I extends ItemLike> ResourceLocation getId(Holder<I> holder) {
11 return TagUtils.stream(BuiltInRegistries.ITEM, tag); 11 return getId(holder.value());
12 }
13
14 public static ResourceLocation getId(ItemLike item) {
15 return BuiltInRegistries.ITEM.getKey(item.asItem());
16 }
17
18 public static ResourceLocation getId(ItemStack stack) {
19 return getId(stack.getItem());
12 } 20 }
13 21
14 private ItemUtils() {} 22 private ItemUtils() {}
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/TagUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/TagUtils.java
deleted file mode 100644
index 93e577f..0000000
--- a/src/main/java/lv/enes/mc/eris_alchemy/utils/TagUtils.java
+++ /dev/null
@@ -1,16 +0,0 @@
1package lv.enes.mc.eris_alchemy.utils;
2
3import net.minecraft.core.Holder;
4import net.minecraft.core.Registry;
5import net.minecraft.tags.TagKey;
6
7import java.util.stream.Stream;
8import java.util.stream.StreamSupport;
9
10public final class TagUtils {
11 public static <T> Stream<T> stream(Registry<T> registry, TagKey<T> tag) {
12 return StreamSupport.stream(registry.getTagOrEmpty(tag).spliterator(), false).map(Holder::value);
13 }
14
15 private TagUtils() {}
16}