Skip to content

Commit

Permalink
textures, finish MVP
Browse files Browse the repository at this point in the history
  • Loading branch information
andi-makes committed Jun 23, 2024
1 parent 2764367 commit 2b8d371
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 24 deletions.
18 changes: 16 additions & 2 deletions src/client/java/dev/schmarrn/BeegSmolClient.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
9 changes: 0 additions & 9 deletions src/client/resources/beeg-smol.client.mixins.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/dev/schmarrn/MyMobEffects.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import net.minecraft.world.entity.ai.attributes.Attributes;

public class MyMobEffects {
public static final Holder<MobEffect> 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<MobEffect> 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<MobEffect> 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<MobEffect> 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);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dev/schmarrn/brewing/CustomBrewingRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/schmarrn/items/MyItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/dev/schmarrn/items/Vial.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -35,7 +37,7 @@ public Vial(Properties properties) {
}

public static @NotNull ItemStack getWithEffects(List<MobEffectInstance> mes) {
ItemStack itemStack = MyItems.POTION.getDefaultInstance();
ItemStack itemStack = MyItems.VIAL.getDefaultInstance();
itemStack.set(MyComponents.MOB_EFFECTS, new MobEffectInstancesComponent(mes));
return itemStack;
}
Expand Down Expand Up @@ -84,4 +86,14 @@ public int getUseDuration(ItemStack itemStack, LivingEntity livingEntity) {
public @NotNull InteractionResultHolder<ItemStack> 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;
}
}
2 changes: 1 addition & 1 deletion src/main/java/dev/schmarrn/mixin/PotionBrewingMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/assets/beeg-smol/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/beeg-smol/models/item/vial.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
6 changes: 1 addition & 5 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2b8d371

Please sign in to comment.