Skip to content

Commit 31630e7

Browse files
committed
add content chat helpers and content for storage network
1 parent 48bf945 commit 31630e7

6 files changed

Lines changed: 76 additions & 3 deletions

File tree

mod.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
mod_version=0.2.0
2+
mod_version=0.2.1
33

44
mod_id=flib
55
mod_license=MIT
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.lothrazar.library.data;
2+
public enum OpCompareType {
3+
4+
GREATER, LESS, EQUAL;
5+
6+
public static OpCompareType get(int i) {
7+
return OpCompareType.values()[i];
8+
}
9+
10+
public OpCompareType toggle() {
11+
switch (this) {
12+
case LESS:
13+
return EQUAL;
14+
case EQUAL:
15+
return GREATER;
16+
case GREATER:
17+
return LESS;
18+
}
19+
return OpCompareType.EQUAL;
20+
}
21+
22+
public String symbol() {
23+
switch (this) {
24+
case LESS:
25+
return "<";
26+
case EQUAL:
27+
return "=";
28+
case GREATER:
29+
default:
30+
return ">";
31+
}
32+
}
33+
34+
public String word() {
35+
switch (this) {
36+
case LESS:
37+
return "less";
38+
case EQUAL:
39+
return "eq";
40+
case GREATER:
41+
default:
42+
return "more";
43+
}
44+
}
45+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.lothrazar.library.gui;
2+
3+
import net.minecraft.resources.ResourceLocation;
4+
5+
public record TileableTexture(ResourceLocation texture, int width, int height) {}

src/main/java/com/lothrazar/library/util/ChatUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.network.chat.Component;
77
import net.minecraft.network.chat.MutableComponent;
88
import net.minecraft.world.entity.player.Player;
9+
import net.minecraft.world.level.block.state.BlockState;
910

1011
public class ChatUtil {
1112

@@ -47,6 +48,10 @@ public static void sendStatusMessage(Player player, Component nameTextComponent)
4748
}
4849
}
4950

51+
public static void statusMessage(Player player, BlockState bs) {
52+
ChatUtil.sendStatusMessage(player, Component.translatable(bs.getBlock().getName().getString()));
53+
}
54+
5055
public static String lang(String message) {
5156
return ilang(message).getString();
5257
}

src/main/java/com/lothrazar/library/util/ItemStackUtil.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ public class ItemStackUtil {
2929
//hasContainerItem() is hasCraftingRemainingItem()
3030
//and getContainerItem() is getCraftingRemainingItem() now
3131

32+
33+
public static void addOrMergeIntoList(List<ItemStack> list, ItemStack stackToAdd) {
34+
boolean added = false;
35+
for (ItemStack stack : list) {
36+
if (ItemStack.isSameItemSameComponents(stackToAdd, stack)) {
37+
stack.setCount(stack.getCount() + stackToAdd.getCount());
38+
added = true;
39+
break;
40+
}
41+
}
42+
if (!added) {
43+
list.add(stackToAdd);
44+
}
45+
}
46+
47+
48+
3249
/**
3350
* example
3451
*

update.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"homepage": "https://www.curseforge.com/minecraft/mc-mods/flib",
33
"promos": {
4-
"1.21.1-latest": "0.2.0"
4+
"1.21.1-latest": "0.2.1"
55
},
66
"1.18.2": {
77
"0.0.1": "First",
@@ -31,6 +31,7 @@
3131
"1.21.1": {
3232
"0.1.0": "Ported to Minecraft 1.21",
3333
"0.1.1": "Add TintedVertexConsumer. Add Helper methods to RecipeCauldronFactory for use with several things including dependent-mod JEI plugins",
34-
"0.2.0": "Fix default value in GameRuleFactory createBoolean. @Deprecated FluidTagIngredient bedcause a version has been merged into neoforge, see SizedFluidIngredient. Added DataComponentsFlib. Added Codec and StreamCodec to RelativeShape, EnergyIngredient, and RandomizedOutputIngredient for 1.21 data-component support. Since enchantments are data driven now, removed EnchantmentFlib class; its helpers (getCurrentLevelTool, getCurrentArmorLevel/Slot, getLevelAll, getFirstArmorStackWithEnchant) were merged into EnchantUtil. TagDataUtil.buildNamedPlayerSkull now uses DataComponents.PROFILE / ResolvableProfile instead of the legacy SkullOwner CustomData tag (buildSkullFromTag removed). Add BucketItemFlib to assist modded fluids. ItemStackUtil.addLoreToStack now appends to existing lore instead of overwriting it. Render types updated 1.21 compatibility. "
34+
"0.2.0": "Fix default value in GameRuleFactory createBoolean. @Deprecated FluidTagIngredient bedcause a version has been merged into neoforge, see SizedFluidIngredient. Added DataComponentsFlib. Added Codec and StreamCodec to RelativeShape, EnergyIngredient, and RandomizedOutputIngredient for 1.21 data-component support. Since enchantments are data driven now, removed EnchantmentFlib class; its helpers (getCurrentLevelTool, getCurrentArmorLevel/Slot, getLevelAll, getFirstArmorStackWithEnchant) were merged into EnchantUtil. TagDataUtil.buildNamedPlayerSkull now uses DataComponents.PROFILE / ResolvableProfile instead of the legacy SkullOwner CustomData tag (buildSkullFromTag removed). Add BucketItemFlib to assist modded fluids. ItemStackUtil.addLoreToStack now appends to existing lore instead of overwriting it. Render types updated 1.21 compatibility. ",
35+
"0.2.1": "Add ItemStackUtil:addOrMergeIntoList and ChatUtil:statusMessage for blockstate to assist Storage Network. Add data/OpCompareType and gui/TileableTexture"
3536
}
3637
}

0 commit comments

Comments
 (0)