-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Estrogen Pill and Crystal Estrogen Pill Projectiles for the potato ca…
…nnon
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
common/src/main/java/dev/mayaqq/estrogen/registry/EstrogenPotatoProjectiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} | ||
} |