Skip to content

Commit

Permalink
feat: add Frenzy Serum
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Jul 30, 2024
1 parent 13df4a1 commit 9f5e48e
Show file tree
Hide file tree
Showing 26 changed files with 313 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ private void addStatusEffectTranslations() {
addEffect(ModMobEffects.ESSENCE_ANEMIA, "Essence Anemia");
addEffect(ModMobEffects.DROWSY, "Drowsy");
addEffect(ModMobEffects.DESPOIL, "Despoil");
addEffect(ModMobEffects.FRENZY, "Frenzy");
addEffect(ModMobEffects.WITHDRAWAL, "Withdrawal");
}

private void addEnchantmentTranslations() {
Expand Down Expand Up @@ -526,6 +528,7 @@ private void addItemTranslations() {
addSerumItem(ModItems.BREEDING_STIMULANT, "Breeding Stimulant", "Makes Animals hyper-fertile, making them able to repeatedly reproduce for a short time.");
addSerumItem(ModItems.ABSORPTION_BOOST, "Absorption Stimulant", "Grants stackable absorption health points to Mobs and Players.");
addSerumItem(ModItems.INSOMNIA_CURE, "Insomnia Cure", "Resets the last slept time, no need to sleep for quite some time.\nCoffee who?");
addSerumItem(ModItems.FRENZY_SERUM, "Frenzy Serum", "Quickly boost your attack damage and speed. But greatly increases hostility and aggression.\nSide effects include withdrawal symptoms after use.");

addBannerPatternItem(ModItems.MASCOT_BANNER_PATTERNS, "Banner Pattern", "Biomancy Mascot");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected void registerModels() {
serumItem(ModItems.ABSORPTION_BOOST);
serumItem(ModItems.CLEANSING_SERUM);
serumItem(ModItems.INSOMNIA_CURE);
serumItem(ModItems.FRENZY_SERUM);

serumItem(ModItems.ORGANIC_COMPOUND);
serumItem(ModItems.UNSTABLE_COMPOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ private void buildSerumRecipes(Consumer<FinishedRecipe> consumer) {
.setCraftingTime(8 * 20)
.unlockedBy(ModItems.EXOTIC_COMPOUND.get()).save(consumer);

BioLabRecipeBuilder.create(ModItems.FRENZY_SERUM.get())
.addIngredient(ModItems.VOLATILE_FLUID.get())
.addIngredient(ModItems.HORMONE_SECRETION.get())
.setReactant(ModItems.EXOTIC_COMPOUND.get())
.setCraftingTime(8 * 20)
.unlockedBy(ModItems.EXOTIC_COMPOUND.get()).save(consumer);

BioLabRecipeBuilder.create(ModItems.BREEDING_STIMULANT.get())
.addIngredient(ModItems.NUTRIENT_PASTE.get())
.addIngredient(ItemTags.FLOWERS)
Expand Down
5 changes: 5 additions & 0 deletions src/generated/resources/assets/biomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
"serum.biomancy.insomnia_cure": "Insomnia Cure",
"item.biomancy.insomnia_cure": "Insomnia Cure",
"serum.biomancy.insomnia_cure.tooltip": "Resets the last slept time, no need to sleep for quite some time.\nCoffee who?",
"serum.biomancy.frenzy_serum": "Frenzy Serum",
"item.biomancy.frenzy_serum": "Frenzy Serum",
"serum.biomancy.frenzy_serum.tooltip": "Quickly boost your attack damage and speed. But greatly increases hostility and aggression.\nSide effects include withdrawal symptoms after use.",
"item.biomancy.mascot_patterns": "Banner Pattern",
"item.biomancy.mascot_patterns.desc": "Biomancy Mascot",
"item.biomancy.hungry_flesh_blob_spawn_egg": "Hungry Flesh Blob Spawn Egg",
Expand Down Expand Up @@ -316,6 +319,8 @@
"effect.biomancy.essence_anemia": "Essence Anemia",
"effect.biomancy.drowsy": "Drowsy",
"effect.biomancy.despoil": "Despoil",
"effect.biomancy.frenzy": "Frenzy",
"effect.biomancy.withdrawal": "Withdrawal",
"serum.biomancy.empty": "ERROR: INVALID SERUM",
"death.attack.biomancy.chest_bite": "%1$s tried opening a chest, but was eaten instead",
"death.attack.biomancy.primordial_spikes": "%1$s was impaled by primordial spikes",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "biomancy:item/serum/frenzy_serum"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_exotic_compound": {
"conditions": {
"items": [
{
"items": [
"biomancy:exotic_compound"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "biomancy:bio_brewing/frenzy_serum_from_bio_brewing"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_exotic_compound",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"biomancy:bio_brewing/frenzy_serum_from_bio_brewing"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "biomancy:bio_brewing",
"ingredients": [
{
"item": "biomancy:volatile_fluid"
},
{
"item": "biomancy:hormone_secretion"
}
],
"nutrientsCost": 2,
"processingTime": 160,
"reactant": {
"item": "biomancy:exotic_compound"
},
"result": {
"item": "biomancy:frenzy_serum"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.elenterius.biomancy.entity.mob.ai.goal;

import com.github.elenterius.biomancy.init.ModMobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;

public class FrenzyAttackableTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {

public FrenzyAttackableTargetGoal(Mob goalOwner, Class<T> targetClass) {
super(goalOwner, targetClass, true);
}

@Override
public boolean canUse() {
if (!mob.hasEffect(ModMobEffects.FRENZY.get())) return false;

return super.canUse();
}

@Override
public boolean canContinueToUse() {
if (!mob.hasEffect(ModMobEffects.FRENZY.get())) {
stop();
return false;
}

return super.canContinueToUse();
}

@Override
public void stop() {
// setTarget(null); //immediately forget target
super.stop();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.elenterius.biomancy.entity.mob.ai.goal;

import com.github.elenterius.biomancy.init.ModMobEffects;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;

public class FrenzyMeleeAttackGoal extends MeleeAttackGoal {

public FrenzyMeleeAttackGoal(PathfinderMob goalOwner, double speedModifier, boolean followingTargetEvenIfNotSeen) {
super(goalOwner, speedModifier, followingTargetEvenIfNotSeen);
}

@Override
public boolean canUse() {
if (!mob.hasEffect(ModMobEffects.FRENZY.get())) return false;

return super.canUse();
}

@Override
public boolean canContinueToUse() {
if (!mob.hasEffect(ModMobEffects.FRENZY.get())) return false;

return super.canContinueToUse();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import com.github.elenterius.biomancy.BiomancyMod;
import com.github.elenterius.biomancy.init.AcidInteractions;
import com.github.elenterius.biomancy.init.ModEnchantments;
import com.github.elenterius.biomancy.init.ModMobEffects;
import com.github.elenterius.biomancy.serum.FrenzySerum;
import net.minecraft.world.entity.Mob;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
Expand All @@ -30,4 +34,12 @@ public static void onLivingTick(final TickEvent.PlayerTickEvent event) {
}
}

@SubscribeEvent
public static void onLivingJoinLevel(final EntityJoinLevelEvent event) {
if (event.getLevel().isClientSide()) return;
if (event.getEntity() instanceof Mob mob && mob.hasEffect(ModMobEffects.FRENZY.get())) {
FrenzySerum.injectAIBehavior(mob);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public final class ModItems {
public static final RegistryObject<SerumItem> ABSORPTION_BOOST = registerSerumItem(ModSerums.ABSORPTION_BOOST);
public static final RegistryObject<SerumItem> CLEANSING_SERUM = registerSerumItem(ModSerums.CLEANSING_SERUM);
public static final RegistryObject<SerumItem> INSOMNIA_CURE = registerSerumItem(ModSerums.INSOMNIA_CURE);
public static final RegistryObject<SerumItem> FRENZY_SERUM = registerSerumItem(ModSerums.FRENZY_SERUM);

//## Special
public static final RegistryObject<SimpleItem> PRIMORDIAL_CORE = registerSimpleItem("primordial_core", ModRarities.VERY_RARE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public final class ModMobEffects {
public static final RegistryObject<LibidoEffect> LIBIDO = EFFECTS.register("libido", () -> new LibidoEffect(MobEffectCategory.NEUTRAL, 0xe06a78));
public static final RegistryObject<DrowsyEffect> DROWSY = EFFECTS.register("drowsy", () -> new DrowsyEffect(MobEffectCategory.NEUTRAL, 0x9b70b2));

public static final RegistryObject<AdrenalineEffect> ADRENALINE_RUSH = EFFECTS.register("adrenaline_rush", () -> new AdrenalineEffect(MobEffectCategory.BENEFICIAL, 0xff9532)
.addAttackDamageModifier("1f1fb00f-d6bc-4b42-8533-422054cea63d", 4f, 0, AttributeModifier.Operation.ADDITION)
public static final RegistryObject<AttackDamageEffect> FRENZY = EFFECTS.register("frenzy", () -> new AttackDamageEffect(MobEffectCategory.BENEFICIAL, 0xd1001c)
.addAttackDamageModifier("1f1fb00f-d6bc-4b42-8533-422054cea63d", 4f, 0, AttributeModifier.Operation.ADDITION) // Strength ~II
.addModifier(Attributes.MOVEMENT_SPEED, "14e2a39c-abb5-43a4-9449-522eec57ff2e", 0.225f, AttributeModifier.Operation.MULTIPLY_TOTAL)
.addModifier(Attributes.ATTACK_SPEED, "08a20d5b-60ce-4769-9e67-71cab0abe989", 0.175f, AttributeModifier.Operation.MULTIPLY_TOTAL));

public static final RegistryObject<AdrenalineEffect> ADRENAL_FATIGUE = EFFECTS.register("adrenal_fatigue", () -> new AdrenalineEffect(MobEffectCategory.HARMFUL, 0x60443f)
.addAttackDamageModifier("8dadcbe5-9098-4545-b07c-3e9120c84232", -4, 0, AttributeModifier.Operation.ADDITION)
public static final RegistryObject<WithdrawalEffect> WITHDRAWAL = EFFECTS.register("withdrawal", () -> new WithdrawalEffect(0x5c4b88)
.addAttackDamageModifier("8dadcbe5-9098-4545-b07c-3e9120c84232", -3, 0, AttributeModifier.Operation.ADDITION)
.addModifier(Attributes.MOVEMENT_SPEED, "0f1be88c-cbb2-455c-8559-0b420caa980d", -0.225f, AttributeModifier.Operation.MULTIPLY_TOTAL)
.addModifier(Attributes.ATTACK_SPEED, "ab116bd1-196b-4bf8-a136-6c24e7c0e80d", -0.125f, AttributeModifier.Operation.MULTIPLY_TOTAL));

Expand Down
20 changes: 1 addition & 19 deletions src/main/java/com/github/elenterius/biomancy/init/ModSerums.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,8 @@ public final class ModSerums {
public static final RegistryObject<AbsorptionSerum> ABSORPTION_BOOST = SERUMS.register("absorption_boost", () -> new AbsorptionSerum(0xF5A21F));
public static final RegistryObject<InsomniaCureSerum> INSOMNIA_CURE = SERUMS.register("insomnia_cure", () -> new InsomniaCureSerum(0x9B70B2));
public static final RegistryObject<CleansingSerum> CLEANSING_SERUM = SERUMS.register("cleansing_serum", () -> new CleansingSerum(0x371667));

// public static final RegistryObject<AdrenalineSerum> ADRENALINE_SERUM = SERUMS.register("adrenaline_serum", () -> new AdrenalineSerum(0x8F1834));
public static final RegistryObject<FrenzySerum> FRENZY_SERUM = SERUMS.register("frenzy_serum", () -> new FrenzySerum(0xD1001C));

private ModSerums() {}

// @Mod.EventBusSubscriber(modid = BiomancyMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
// private static class CommonHandler {
// private static final Map<Serum, SerumItem> SERUM_TO_ITEM_MAP = new IdentityHashMap<>();
// @Nullable
// public static SerumItem getItemForSerum(Serum serum) {
// return SERUM_TO_ITEM_MAP.get(serum);
// }
// @SubscribeEvent
// public static void onSetup(FMLCommonSetupEvent event) {
// Set<Map.Entry<ResourceKey<Item>, Item>> entries = ForgeRegistries.ITEMS.getEntries();
//// entries.stream().map(Map.Entry::getValue)
//// .filter(SerumItem.class::isInstance).map(SerumItem.class::cast)
//// .map(item -> item.getSerum(new ItemStack(item)))
//// .filter(serum -> !serum.isEmpty())
//// .forEach(SERUM_TO_ITEM_MAP);
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public final class ModItemTags {

public static final TagKey<Item> CANNOT_BE_EATEN_BY_CRADLE = tag("cannot_be_eaten_by_cradle");

@Deprecated
public static final TagKey<Item> SUGARS = tag("sugars");

private ModItemTags() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import com.github.elenterius.biomancy.init.ModMobEffects;
import com.github.elenterius.biomancy.item.ShieldBlockingListener;
import com.github.elenterius.biomancy.serum.FrenzySerum;
import com.github.elenterius.biomancy.statuseffect.StatusEffectHandler;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.projectile.Arrow;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
Expand All @@ -29,6 +33,16 @@ public abstract class LivingEntityMixin {
@Shadow
public abstract boolean hasEffect(MobEffect effect);

@Shadow
public abstract AttributeMap getAttributes();

@Inject(method = "getAttributeValue(Lnet/minecraft/world/entity/ai/attributes/Attribute;)D", at = @At("HEAD"), cancellable = true)
protected void onGetAttributeValue(Attribute attribute, CallbackInfoReturnable<Double> cir) {
if (attribute == Attributes.ATTACK_DAMAGE && !getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE) && hasEffect(ModMobEffects.FRENZY.get())) {
cir.setReturnValue(FrenzySerum.ATTACK_DAMAGE_FALLBACK);
}
}

@Inject(method = "isSensitiveToWater", at = @At(value = "HEAD"), cancellable = true)
private void onIsSensitiveToWater(CallbackInfoReturnable<Boolean> cir) {
if (hasEffect(ModMobEffects.CORROSIVE.get())) {
Expand Down
Loading

0 comments on commit 9f5e48e

Please sign in to comment.