diff --git a/src/client/java/dev/schmarrn/BeegSmolClient.java b/src/client/java/dev/schmarrn/BeegSmolClient.java index bf74ccb..4b386a7 100644 --- a/src/client/java/dev/schmarrn/BeegSmolClient.java +++ b/src/client/java/dev/schmarrn/BeegSmolClient.java @@ -1,10 +1,24 @@ package dev.schmarrn; +import dev.schmarrn.components.MobEffectInstancesComponent; +import dev.schmarrn.components.MyComponents; +import dev.schmarrn.items.MyItems; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; +import net.minecraft.util.FastColor; public class BeegSmolClient implements ClientModInitializer { @Override public void onInitializeClient() { - // This entrypoint is suitable for setting up client-specific logic, such as rendering. + ColorProviderRegistry.ITEM.register((stack, tintIndex) -> { + if (tintIndex > 0) { + return -1; + } + MobEffectInstancesComponent mei = stack.getOrDefault(MyComponents.MOB_EFFECTS, MobEffectInstancesComponent.EMPTY); + if (mei.effectInstances().isEmpty()) { + return -1; + } + return FastColor.ARGB32.opaque(mei.effectInstances().getFirst().getEffect().value().getColor()); + }, MyItems.VIAL); } -} \ No newline at end of file +} diff --git a/src/client/resources/beeg-smol.client.mixins.json b/src/client/resources/beeg-smol.client.mixins.json deleted file mode 100644 index 688d9fd..0000000 --- a/src/client/resources/beeg-smol.client.mixins.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "required": true, - "package": "dev.schmarrn.mixin.client", - "compatibilityLevel": "JAVA_21", - "client": [ ], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file diff --git a/src/main/java/dev/schmarrn/MyMobEffects.java b/src/main/java/dev/schmarrn/MyMobEffects.java index 1152656..fefa01a 100644 --- a/src/main/java/dev/schmarrn/MyMobEffects.java +++ b/src/main/java/dev/schmarrn/MyMobEffects.java @@ -10,8 +10,8 @@ import net.minecraft.world.entity.ai.attributes.Attributes; public class MyMobEffects { - public static final Holder BEEG = Registry.registerForHolder(BuiltInRegistries.MOB_EFFECT, BeegSmol.rl("beeg"), new MyMobEffect(MobEffectCategory.NEUTRAL, 0xFF00FF).addAttributeModifier(Attributes.SCALE, BeegSmol.rl("effect.beeg"), 0.5, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)); - public static final Holder SMOL = Registry.registerForHolder(BuiltInRegistries.MOB_EFFECT, BeegSmol.rl("smol"), new MyMobEffect(MobEffectCategory.NEUTRAL, 0xFF00FF).addAttributeModifier(Attributes.SCALE, BeegSmol.rl("effect.smol"), -0.5, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)); + public static final Holder BEEG = Registry.registerForHolder(BuiltInRegistries.MOB_EFFECT, BeegSmol.rl("beeg"), new MyMobEffect(MobEffectCategory.NEUTRAL, 0xd092ef).addAttributeModifier(Attributes.SCALE, BeegSmol.rl("effect.beeg"), 0.5, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)); + public static final Holder SMOL = Registry.registerForHolder(BuiltInRegistries.MOB_EFFECT, BeegSmol.rl("smol"), new MyMobEffect(MobEffectCategory.NEUTRAL, 0x92efb6).addAttributeModifier(Attributes.SCALE, BeegSmol.rl("effect.smol"), -0.5, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)); public static final MobEffectInstance BIG_INSTANCE = getMobEffectInstance(BEEG, 0); public static final MobEffectInstance SMALL_INSTANCE = getMobEffectInstance(SMOL, 0); diff --git a/src/main/java/dev/schmarrn/brewing/CustomBrewingRecipes.java b/src/main/java/dev/schmarrn/brewing/CustomBrewingRecipes.java index 2c11622..872928d 100644 --- a/src/main/java/dev/schmarrn/brewing/CustomBrewingRecipes.java +++ b/src/main/java/dev/schmarrn/brewing/CustomBrewingRecipes.java @@ -6,6 +6,7 @@ import dev.schmarrn.items.Vial; import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.Potion; @@ -59,6 +60,15 @@ public ItemStack getOutput(ItemStack base, ItemStack ingredient) { }); } + public static boolean isRecipe(ItemStack base, ItemStack ingredient) { + for (IBrewingRecipe recipe : RECIPES) { + if (recipe.isBase(base) && recipe.isIngredient(ingredient)) { + return true; + } + } + return false; + } + public static boolean isIngredient(ItemStack stack) { for (IBrewingRecipe recipe : RECIPES) { if (recipe.isIngredient(stack)) { diff --git a/src/main/java/dev/schmarrn/items/MyItems.java b/src/main/java/dev/schmarrn/items/MyItems.java index 221a244..cd26ee1 100644 --- a/src/main/java/dev/schmarrn/items/MyItems.java +++ b/src/main/java/dev/schmarrn/items/MyItems.java @@ -6,7 +6,7 @@ import net.minecraft.world.item.Item; public class MyItems { - public static final Item POTION = Registry.register(BuiltInRegistries.ITEM, BeegSmol.rl("vial"), new Vial(new Item.Properties().stacksTo(1))); + public static final Item VIAL = Registry.register(BuiltInRegistries.ITEM, BeegSmol.rl("vial"), new Vial(new Item.Properties().stacksTo(1))); public static void init() { // no-op diff --git a/src/main/java/dev/schmarrn/items/Vial.java b/src/main/java/dev/schmarrn/items/Vial.java index 85f1b3e..b4ea41a 100644 --- a/src/main/java/dev/schmarrn/items/Vial.java +++ b/src/main/java/dev/schmarrn/items/Vial.java @@ -3,6 +3,8 @@ import dev.schmarrn.components.MobEffectInstancesComponent; import dev.schmarrn.components.MyComponents; import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionHand; @@ -15,10 +17,10 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; import java.util.List; public class Vial extends Item { - public Vial(Properties properties) { super(properties); } @@ -35,7 +37,7 @@ public Vial(Properties properties) { } public static @NotNull ItemStack getWithEffects(List mes) { - ItemStack itemStack = MyItems.POTION.getDefaultInstance(); + ItemStack itemStack = MyItems.VIAL.getDefaultInstance(); itemStack.set(MyComponents.MOB_EFFECTS, new MobEffectInstancesComponent(mes)); return itemStack; } @@ -84,4 +86,14 @@ public int getUseDuration(ItemStack itemStack, LivingEntity livingEntity) { public @NotNull InteractionResultHolder use(Level level, Player player, InteractionHand interactionHand) { return ItemUtils.startUsingInstantly(level, player, interactionHand); } + + @Override + public String getDescriptionId(ItemStack itemStack) { + String effect = BuiltInRegistries.MOB_EFFECT.getKey(itemStack.getOrDefault(MyComponents.MOB_EFFECTS, MobEffectInstancesComponent.EMPTY) + .effectInstances() + .getFirst() + .getEffect() + .value()).getPath(); + return this.getDescriptionId() + ".effect." + effect; + } } diff --git a/src/main/java/dev/schmarrn/mixin/PotionBrewingMixin.java b/src/main/java/dev/schmarrn/mixin/PotionBrewingMixin.java index d2a2308..b728f4b 100644 --- a/src/main/java/dev/schmarrn/mixin/PotionBrewingMixin.java +++ b/src/main/java/dev/schmarrn/mixin/PotionBrewingMixin.java @@ -33,7 +33,7 @@ public class PotionBrewingMixin { at = @At("RETURN") ) private boolean bs$hasPotionMix(boolean original, ItemStack base, ItemStack ingredient) { - return original || CustomBrewingRecipes.isBasis(base) && CustomBrewingRecipes.isIngredient(ingredient); + return original || CustomBrewingRecipes.isRecipe(base, ingredient); } @ModifyReturnValue( diff --git a/src/main/resources/assets/beeg-smol/lang/en_us.json b/src/main/resources/assets/beeg-smol/lang/en_us.json new file mode 100644 index 0000000..3b63727 --- /dev/null +++ b/src/main/resources/assets/beeg-smol/lang/en_us.json @@ -0,0 +1,7 @@ +{ + "item.beeg-smol.vial": "Vial", + "item.beeg-smol.vial.effect.beeg": "Vial of Growing", + "item.beeg-smol.vial.effect.smol": "Vial of Shrinking", + "effect.beeg-smol.beeg": "Growing", + "effect.beeg-smol.smol": "Shrinking" +} \ No newline at end of file diff --git a/src/main/resources/assets/beeg-smol/models/item/vial.json b/src/main/resources/assets/beeg-smol/models/item/vial.json index 83b8e5b..8d7e1fa 100644 --- a/src/main/resources/assets/beeg-smol/models/item/vial.json +++ b/src/main/resources/assets/beeg-smol/models/item/vial.json @@ -1,7 +1,7 @@ { "parent": "item/generated", "textures": { - "layer0": "item/potion_overlay", - "layer1": "item/potion" + "layer0": "beeg-smol:item/vial_overlay", + "layer1": "beeg-smol:item/vial" } } diff --git a/src/main/resources/assets/beeg-smol/textures/item/vial.png b/src/main/resources/assets/beeg-smol/textures/item/vial.png new file mode 100644 index 0000000..b14b0b2 Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/item/vial.png differ diff --git a/src/main/resources/assets/beeg-smol/textures/item/vial.png~ b/src/main/resources/assets/beeg-smol/textures/item/vial.png~ new file mode 100644 index 0000000..b86b4b7 Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/item/vial.png~ differ diff --git a/src/main/resources/assets/beeg-smol/textures/item/vial_overlay.png b/src/main/resources/assets/beeg-smol/textures/item/vial_overlay.png new file mode 100644 index 0000000..5357035 Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/item/vial_overlay.png differ diff --git a/src/main/resources/assets/beeg-smol/textures/item/vial_overlay.png~ b/src/main/resources/assets/beeg-smol/textures/item/vial_overlay.png~ new file mode 100644 index 0000000..852260d Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/item/vial_overlay.png~ differ diff --git a/src/main/resources/assets/beeg-smol/textures/mob_effect/beeg.png b/src/main/resources/assets/beeg-smol/textures/mob_effect/beeg.png new file mode 100644 index 0000000..2e39037 Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/mob_effect/beeg.png differ diff --git a/src/main/resources/assets/beeg-smol/textures/mob_effect/beeg.png~ b/src/main/resources/assets/beeg-smol/textures/mob_effect/beeg.png~ new file mode 100644 index 0000000..87eb238 Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/mob_effect/beeg.png~ differ diff --git a/src/main/resources/assets/beeg-smol/textures/mob_effect/smol.png b/src/main/resources/assets/beeg-smol/textures/mob_effect/smol.png new file mode 100644 index 0000000..4be4c1f Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/mob_effect/smol.png differ diff --git a/src/main/resources/assets/beeg-smol/textures/mob_effect/smol.png~ b/src/main/resources/assets/beeg-smol/textures/mob_effect/smol.png~ new file mode 100644 index 0000000..87eb238 Binary files /dev/null and b/src/main/resources/assets/beeg-smol/textures/mob_effect/smol.png~ differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6cb90cc..f0f28f5 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,11 +22,7 @@ ] }, "mixins": [ - "beeg-smol.mixins.json", - { - "config": "beeg-smol.client.mixins.json", - "environment": "client" - } + "beeg-smol.mixins.json" ], "depends": { "fabricloader": ">=0.15.11",