Skip to content

Commit

Permalink
feat: add blacksmith upgrade to beaver familiar
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Aug 9, 2024
1 parent dc60150 commit 9dd51a8
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/generated/resources/assets/occultism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_bat.description.title": "Description",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_bat.entity.text": "**Provides**: [#](ad03fc)Night Vision[#]()\n",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_bat.name": "Bat Familiar",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_beaver.description.text": "The Beaver familiar will chop down nearby trees when they grow from a sapling into a tree. It can only handle small trees.\n\\\n\\\n**Upgrade Behaviour**\\\nCannot be upgraded by the blacksmith familiar.\n",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_beaver.description.text": "The Beaver familiar will chop down nearby trees when they grow from a sapling into a tree. It can only handle small trees.\n\\\n\\\n**Upgrade Behaviour**\\\nGives free snacks when right-clicked with an empty hand.\n",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_beaver.description.title": "Description",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_beaver.entity.text": "**Provides**: [#](ad03fc)Increased wood break speed[#]()\n",
"book.occultism.dictionary_of_spirits.familiar_rituals.familiar_beaver.name": "Beaver Familiar",
Expand Down Expand Up @@ -843,6 +843,7 @@
"debug.occultism.debug_wand.printed_glyphs": "Printed glyphs",
"debug.occultism.debug_wand.spirit_selected": "Selected spirit with id %s",
"debug.occultism.debug_wand.spirit_tamed": "Tamed spirit with id %s",
"dialog.occultism.beaver.snack_on_cooldown": "Hey now, don't be greedy!",
"dialog.occultism.dragon.pet": "purrr",
"dialog.occultism.mummy.kapow": "KAPOW!",
"effect.occultism.bat_lifesteal": "Lifesteal",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "occultism:item/beaver_nugget"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
import com.klikli_dev.occultism.common.advancement.FamiliarTrigger;
import com.klikli_dev.occultism.registry.OccultismAdvancements;
import com.klikli_dev.occultism.registry.OccultismEffects;
import com.klikli_dev.occultism.registry.OccultismItems;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -40,11 +43,13 @@
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation;
import net.minecraft.world.entity.ai.navigation.WaterBoundPathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.pathfinder.PathType;
import net.neoforged.neoforge.common.NeoForgeMod;
import net.neoforged.neoforge.fluids.FluidType;
import net.neoforged.neoforge.items.ItemHandlerHelper;

import javax.annotation.Nullable;
import java.util.EnumSet;
Expand All @@ -54,8 +59,10 @@

public class BeaverFamiliarEntity extends FamiliarEntity {

protected static final int SNACK_INTERVAL = 20;
private final WaterBoundPathNavigation waterNavigator;
private final GroundPathNavigation groundNavigator;
protected long lastSnackTime;
private BlockPos treeTarget;

public BeaverFamiliarEntity(EntityType<? extends BeaverFamiliarEntity> type, Level level) {
Expand Down Expand Up @@ -115,6 +122,26 @@ public boolean canDrownInFluidType(FluidType type) {
return false;
}

@Override
public InteractionResult mobInteract(Player pPlayer, InteractionHand pHand) {
ItemStack itemstack = pPlayer.getItemInHand(pHand);
if (this.getOwner() == pPlayer) {

if (!pPlayer.isShiftKeyDown() && itemstack.isEmpty()) {
if(this.level().getGameTime() > this.lastSnackTime + SNACK_INTERVAL){
this.lastSnackTime = this.level().getGameTime();
ItemHandlerHelper.giveItemToPlayer(pPlayer, new ItemStack(OccultismItems.BEAVER_NUGGET.get()));
} else {
pPlayer.displayClientMessage(Component.translatable("dialog.occultism.beaver.snack_on_cooldown"), true);
}
//even if we don't give a snack we return success, otherwise we make the familiar change sitting position
return InteractionResult.sidedSuccess(this.level().isClientSide);
}

}
return super.mobInteract(pPlayer, pHand);
}

public boolean hasWhiskers() {
return this.hasVariant(0);
}
Expand Down Expand Up @@ -148,6 +175,11 @@ public void setTreeTarget(BlockPos pos) {
this.treeTarget = pos;
}

@Override
public boolean canBlacksmithUpgrade() {
return true;
}

private static class ChopTreeGoal extends Goal {

private final BeaverFamiliarEntity beaver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected void registerModels() {
this.registerItemGenerated(this.name(OccultismItems.SOUL_SHARD_ITEM.get()));
this.registerItemGenerated(this.name(OccultismItems.DEMONS_DREAM_ESSENCE.get()));
this.registerItemGenerated(this.name(OccultismItems.OTHERWORLD_ESSENCE.get()));
this.registerItemGenerated(this.name(OccultismItems.BEAVER_NUGGET.get()));
}

protected String name(Item item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ private void addFamiliarRitualsCategory(BookContextHelper helper) {
\\
\\
**Upgrade Behaviour**\\
Cannot be upgraded by the blacksmith familiar.
Gives free snacks when right-clicked with an empty hand.
""".formatted(COLOR_PURPLE));

helper.entry("familiar_beholder");
Expand Down Expand Up @@ -3189,6 +3189,7 @@ public void addAutoTooltip(ItemLike key, String value) {
private void addDialogs() {
this.add("dialog.occultism.dragon.pet", "purrr");
this.add("dialog.occultism.mummy.kapow", "KAPOW!");
this.add("dialog.occultism.beaver.snack_on_cooldown", "Hey now, don't be greedy!");
}

private void addModonomiconIntegration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ public class OccultismFoods {
.effect(() -> new MobEffectInstance(OccultismEffects.THIRD_EYE, 60 * 20, 1), 1.0f)
.effect(() -> new MobEffectInstance(MobEffects.LUCK, 5* 60 * 20, 1), 1.0f)
.build());

public static final Lazy<FoodProperties> BEAVER_NUGGET = Lazy.of(
() -> new FoodProperties.Builder().nutrition(8).saturationModifier(0.8F).build());
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ public class OccultismItems {
public static final DeferredItem<Item> OTHERWORLD_ESSENCE = ITEMS.register("otherworld_essence",
() -> new SpiritHealingItem(defaultProperties().food(OccultismFoods.OTHERWORLD_ESSENCE.get())));

public static final DeferredItem<Item> BEAVER_NUGGET = ITEMS.register("beaver_nugget",
() -> new Item(defaultProperties().food(OccultismFoods.BEAVER_NUGGET.get())));

//Miner Spirits
public static final DeferredItem<Item> MAGIC_LAMP_EMPTY = ITEMS.register("magic_lamp_empty",
() -> new Item(defaultProperties()));
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/klikli_dev/occultism/util/TextUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public class TextUtil {
//Vemerion: Sooo many new familiars! <3
//EqisEdu: the long-awaited additional spirit miner tiers!
//feellian: New Spirit models!
private static final String[] EASTER_EGGS = {"KliKli", "Xalmas", "Toastbroat", "Najlitarvan", "TheBoo", "Ridanisaurus", "Legiaseth", "Vallen", "Vemerion", "EqisEdu", "Feellian"};
//Chonky: Various contributions to occultism & creator of mod integrations
//Kat: Added a lot of QoL to Occultism
//Ginkrepeerc: Suggested the Buc-ees easter egg beaver nuggets
//Ciege: Community helper
//Chanticleer: Community helper
private static final String[] EASTER_EGGS = {"KliKli", "Xalmas", "Toastbroat", "Najlitarvan", "TheBoo", "Ridanisaurus", "Legiaseth", "Vallen", "Vemerion", "EqisEdu", "Feellian", "Ginkrepeerc", "Kat", "Chonky", "Ciege", "Chanticleer" };
private static final String[] SYLLABLE1 = {"Kr", "Ca", "Ra", "Mrok", "Cru", "Ray", "Bre", "Zed", "Drak", "Mor", "Jag", "Mer", "Jar", "Mjol", "Zork", "Mad", "Cry", "Zur", "Creo", "Azak", "Azur", "Rei", "Cro", "Mar", "Luk", "Bar", "Gor", "Rak", "Thr", "Nar", "Vor", "Fir", "Trin", "Drog", "Karn", "Gar", "Ulf", "Hroth", "Ald", "Yng", "Styr", "Eir", "Ein", "Sig", "Ket", "Erl", "Haf", "Bryn", "Nid", "Grim", "Hol", "Fen", "Sigr", "Geir", "Hyr", "Val", "Har", "Kol", "Eyr"};
private static final String[] SYLLABLE2 = {"air", "ir", "mi", "sor", "mee", "clo", "red", "cra", "ark", "arc", "miri", "lori", "cres", "mur", "zer", "marac", "zoir", "slamar", "salmar", "urak", "tim", "jor", "vyr", "dor", "thor", "kyl", "lyn", "wyn", "wynn", "lond", "rond", "vond", "dorn", "korn", "morn", "gorn", "thorn", "worn", "norn", "rinn", "dell", "bell", "vell", "fell", "kell", "zell", "nir", "fir", "mir", "tir", "sir", "vir", "zir", "lir", "jyr", "ryl", "rym", "lym", "lyn", "ryn", "myr", "myl", "myn", "ryn"};
private static final String[] SYLLABLE3 = {"d", "ed", "ark", "arc", "es", "er", "der", "tron", "med", "ure", "zur", "cred", "mur", "aeus", "th", "vyr", "dor", "morn", "born", "thorn", "fyr", "lyr", "ryth", "ryn", "drin", "dryn", "kyr", "kyn", "lynd", "lind", "lyne", "line", "ryne", "rine", "thyr", "thyre", "vyn", "vin", "vyne", "vine", "rynne", "rinne", "syr", "syrn", "zirn", "zirne", "kyl", "kylle", "dor", "dorne", "lor", "lorne", "morn", "morne", "thorn", "thorne", "vyrn", "vyrne", "wyrm"};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9dd51a8

Please sign in to comment.