Skip to content

Commit

Permalink
Estrogen Pill and Crystal Estrogen Pill Projectiles for the potato ca…
Browse files Browse the repository at this point in the history
…nnon
  • Loading branch information
MayaqqDev committed Apr 8, 2024
1 parent 0f88286 commit 3d114fc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/src/main/java/dev/mayaqq/estrogen/Estrogen.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static void init() {
EstrogenItems.registerTooltips();
EstrogenBlocks.registerExtraProperties();

EstrogenPotatoProjectiles.register();

LOGGER.info("Injecting Estrogen into your veins!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package dev.mayaqq.estrogen.registry;

import com.simibubi.create.content.equipment.potatoCannon.PotatoCannonProjectileType;
import dev.mayaqq.estrogen.Estrogen;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.EntityHitResult;

import java.util.function.Predicate;

public class EstrogenPotatoProjectiles {
public static final PotatoCannonProjectileType
ESTROGEN_PILL = create("estrogen_pill")
.damage(3)
.reloadTicks(8)
.velocity(1.5f)
.knockback(0.3f)
.renderTumbling()
.onEntityHit(potion(EstrogenEffects.ESTROGEN_EFFECT.get(), 1, 200, true))
.registerAndAssign(EstrogenItems.ESTROGEN_PILL.get()),
CRYSTAL_ESTROGEN_PILL = create("crystal_estrogen_pill")
.damage(3)
.reloadTicks(8)
.velocity(2.0f)
.knockback(0.4f)
.renderTumbling()
.onEntityHit(potion(EstrogenEffects.ESTROGEN_EFFECT.get(), 2, 300, true))
.registerAndAssign(EstrogenItems.CRYSTAL_ESTROGEN_PILL.get());

private static PotatoCannonProjectileType.Builder create(String name) {
return new PotatoCannonProjectileType.Builder(Estrogen.id(name));
}

private static Predicate<EntityHitResult> potion(MobEffect effect, int level, int ticks, boolean recoverable) {
return ray -> {
Entity entity = ray.getEntity();
if (entity.level().isClientSide)
return true;
if (entity instanceof LivingEntity)
applyEffect((LivingEntity) entity, new MobEffectInstance(effect, ticks, level - 1));
return !recoverable;
};
}

private static void applyEffect(LivingEntity entity, MobEffectInstance effect) {
if (effect.getEffect()
.isInstantenous())
effect.getEffect()
.applyInstantenousEffect(null, null, entity, effect.getDuration(), 1.0);
else
entity.addEffect(effect);
}

public static void register() {}
}

0 comments on commit 3d114fc

Please sign in to comment.