diff --git a/src/api/java/de/teamlapen/vampirism/api/entity/player/vampire/EnumBloodSource.java b/src/api/java/de/teamlapen/vampirism/api/entity/player/vampire/EnumBloodSource.java deleted file mode 100644 index 17c2a180e0..0000000000 --- a/src/api/java/de/teamlapen/vampirism/api/entity/player/vampire/EnumBloodSource.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.teamlapen.vampirism.api.entity.player.vampire; -/** -* This Enum is for usage with {@link de.teamlapen.vampirism.api.event.BloodDrinkEvent}, it shows where the blood came from. -*/ -public enum EnumBloodSource { - BITE_FEED, - VAMPIRE_FOOD, - BLOOD_BOTTLE, - CONTAINER, - OTHER; -} diff --git a/src/api/java/de/teamlapen/vampirism/api/entity/player/vampire/IDrinkBloodContext.java b/src/api/java/de/teamlapen/vampirism/api/entity/player/vampire/IDrinkBloodContext.java new file mode 100644 index 0000000000..be5f094c5e --- /dev/null +++ b/src/api/java/de/teamlapen/vampirism/api/entity/player/vampire/IDrinkBloodContext.java @@ -0,0 +1,59 @@ +package de.teamlapen.vampirism.api.entity.player.vampire; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.Optional; + +/** + * Context for {@link de.teamlapen.vampirism.api.entity.vampire.IVampire#drinkBlood(int, float, boolean, IDrinkBloodContext)} + */ +public interface IDrinkBloodContext { + + /** + * @return The entity that is the source of the blood if the blood is obtained from an entity + */ + Optional getEntity(); + + /** + * @return The itemstack that is the source of the blood if the blood is obtained from an item + */ + Optional getStack(); + + /** + * @return The blockstate that is the source of the blood if the blood is obtained from a block + */ + Optional getBlockState(); + + /** + * @return The blockpos that is the source of the blood if the blood is obtained from a block + */ + Optional getBlockPos(); + + @Deprecated(forRemoval = true) + static IDrinkBloodContext none() { + return new IDrinkBloodContext() { + @Override + public Optional getEntity() { + return Optional.empty(); + } + + @Override + public Optional getStack() { + return Optional.empty(); + } + + @Override + public Optional getBlockState() { + return Optional.empty(); + } + + @Override + public Optional getBlockPos() { + return Optional.empty(); + } + }; + } +} diff --git a/src/api/java/de/teamlapen/vampirism/api/entity/vampire/IVampire.java b/src/api/java/de/teamlapen/vampirism/api/entity/vampire/IVampire.java index fec94f1e41..6c28093b3d 100755 --- a/src/api/java/de/teamlapen/vampirism/api/entity/vampire/IVampire.java +++ b/src/api/java/de/teamlapen/vampirism/api/entity/vampire/IVampire.java @@ -4,7 +4,7 @@ import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.api.entity.factions.IFaction; import de.teamlapen.vampirism.api.entity.factions.IFactionEntity; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import net.minecraft.world.level.LevelAccessor; import org.jetbrains.annotations.NotNull; @@ -24,27 +24,27 @@ public interface IVampire extends IFactionEntity { * * @param amt In blood food unit, not mB. See {@link de.teamlapen.vampirism.api.VReference#FOOD_TO_FLUID_BLOOD} for conversion * @param saturationMod Similar to the food saturation modifier - * @param bloodSource The type of blood source used. See {@link de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource} + * @param drinkContext The context where the blood is obtained from */ - default void drinkBlood(int amt, float saturationMod, EnumBloodSource bloodSource) { - drinkBlood(amt, saturationMod, true, bloodSource); + default void drinkBlood(int amt, float saturationMod, IDrinkBloodContext drinkContext) { + drinkBlood(amt, saturationMod, true, drinkContext); } /** - * @deprecated Use {@link #drinkBlood(int, float, de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource)} instead + * @deprecated Use {@link #drinkBlood(int, float, de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext)} instead */ - @Deprecated + @Deprecated(forRemoval = true) default void drinkBlood(int amt, float saturationMod) { - drinkBlood(amt, saturationMod, true, EnumBloodSource.OTHER); + drinkBlood(amt, saturationMod, true, IDrinkBloodContext.none()); } /** - * @deprecated Use {@link #drinkBlood(int, float, boolean, de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource)} instead + * @deprecated Use {@link #drinkBlood(int, float, boolean, de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext)} instead */ - @Deprecated + @Deprecated(forRemoval = true) default void drinkBlood(int amt, float saturationMod, boolean useRemaining) { - drinkBlood(amt, saturationMod, useRemaining, EnumBloodSource.OTHER); + drinkBlood(amt, saturationMod, useRemaining, IDrinkBloodContext.none()); } /** @@ -53,8 +53,9 @@ default void drinkBlood(int amt, float saturationMod, boolean useRemaining) { * * @param amt In blood food unit, not mB. See {@link de.teamlapen.vampirism.api.VReference#FOOD_TO_FLUID_BLOOD} for conversion * @param saturationMod Similar to the food saturation modifier + * @param drinkContext The context where the blood is obtained from */ - void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource); + void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext); @NotNull @Override diff --git a/src/api/java/de/teamlapen/vampirism/api/event/BloodDrinkEvent.java b/src/api/java/de/teamlapen/vampirism/api/event/BloodDrinkEvent.java index fca735f34e..d53b51b178 100644 --- a/src/api/java/de/teamlapen/vampirism/api/event/BloodDrinkEvent.java +++ b/src/api/java/de/teamlapen/vampirism/api/event/BloodDrinkEvent.java @@ -1,9 +1,8 @@ package de.teamlapen.vampirism.api.event; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.entity.player.vampire.IVampirePlayer; import de.teamlapen.vampirism.api.entity.vampire.IVampire; -import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.eventbus.api.Event; import org.jetbrains.annotations.NotNull; @@ -14,10 +13,10 @@ public abstract class BloodDrinkEvent extends Event { private final IVampire vampire; private int amount; private float saturation; - private final EnumBloodSource bloodSource; + private final IDrinkBloodContext bloodSource; - private BloodDrinkEvent(@NotNull IVampire vampire, int amount, float saturation, EnumBloodSource bloodSource) { + private BloodDrinkEvent(@NotNull IVampire vampire, int amount, float saturation, IDrinkBloodContext bloodSource) { this.vampire = vampire; this.amount = amount; this.saturation = saturation; @@ -46,7 +45,7 @@ public float getSaturation() { /** * @return The type of blood source that the blood was obtained from. */ - public EnumBloodSource getBloodSource() { + public IDrinkBloodContext getBloodSource() { return this.bloodSource; } @@ -65,38 +64,18 @@ public void setSaturationModifier(float saturation) { this.saturation = saturation; } - /** - * Posted whenever a Vampire Player feeds by biting another mob. - * This does not change the amount drained from the entity, meaning it only changes the amount of blood the vampire receives from biting. - */ - public static class BiteFeedEvent extends BloodDrinkEvent { - private final LivingEntity target; - public BiteFeedEvent(@NotNull IVampirePlayer player, LivingEntity target, int amount, float saturation) { - super(player,amount, saturation, EnumBloodSource.BITE_FEED); - this.target = target; - } - - /** - * @return The LivingEntity that is being bitten - */ - @NotNull - public LivingEntity getTarget() { - return this.target; - } - } - /** * Posted whenever a Vampire Player drinks blood, such as when drinking blood from a bottle, eating a human heart or biting another mob */ public static class PlayerDrinkBloodEvent extends BloodDrinkEvent { private boolean useRemaining; - public PlayerDrinkBloodEvent(@NotNull IVampirePlayer player, int amount, float saturation, boolean useRemaining, EnumBloodSource bloodSource) { + public PlayerDrinkBloodEvent(@NotNull IVampirePlayer player, int amount, float saturation, boolean useRemaining, IDrinkBloodContext bloodSource) { super(player, amount, saturation, bloodSource); this.useRemaining = useRemaining; } /** - * @return Whether the remaining blood should be used, see {@link de.teamlapen.vampirism.api.entity.vampire.IVampire#drinkBlood(int, float, boolean, de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource)}. + * @return Whether the remaining blood should be used, see {@link de.teamlapen.vampirism.api.entity.vampire.IVampire#drinkBlood(int, float, boolean, de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext)}. */ public boolean useRemaining() { return this.useRemaining; @@ -109,6 +88,7 @@ public void setUseRemaining(boolean useRemaining) { this.useRemaining = useRemaining; } } + /** * Posted whenever any non-player vampire entity drinks any blood at all. */ @@ -116,12 +96,12 @@ public static class EntityDrinkBloodEvent extends BloodDrinkEvent { private boolean useRemaining; - public EntityDrinkBloodEvent(@NotNull IVampire vampire, int amount, float saturation, boolean useRemaining, EnumBloodSource bloodSource) { + public EntityDrinkBloodEvent(@NotNull IVampire vampire, int amount, float saturation, boolean useRemaining, IDrinkBloodContext bloodSource) { super(vampire, amount, saturation, bloodSource); this.useRemaining = useRemaining; } /** - * @return Whether the remaining blood should be used, see {@link de.teamlapen.vampirism.api.entity.vampire.IVampire#drinkBlood(int, float, boolean, de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource)}. + * @return Whether the remaining blood should be used, see {@link de.teamlapen.vampirism.api.entity.vampire.IVampire#drinkBlood(int, float, boolean, de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext)}. */ public boolean useRemaining() { return this.useRemaining; diff --git a/src/main/java/de/teamlapen/vampirism/blockentity/AltarInfusionBlockEntity.java b/src/main/java/de/teamlapen/vampirism/blockentity/AltarInfusionBlockEntity.java index 67dbaa7e03..f8eba0192d 100644 --- a/src/main/java/de/teamlapen/vampirism/blockentity/AltarInfusionBlockEntity.java +++ b/src/main/java/de/teamlapen/vampirism/blockentity/AltarInfusionBlockEntity.java @@ -6,7 +6,6 @@ import de.teamlapen.vampirism.VampirismMod; import de.teamlapen.vampirism.advancements.critereon.VampireActionCriterionTrigger; import de.teamlapen.vampirism.api.VReference; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.blocks.AltarPillarBlock; import de.teamlapen.vampirism.blocks.AltarTipBlock; import de.teamlapen.vampirism.core.*; @@ -14,6 +13,7 @@ import de.teamlapen.vampirism.entity.player.VampirismPlayerAttributes; import de.teamlapen.vampirism.entity.player.vampire.VampireLeveling; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.inventory.AltarInfusionMenu; import de.teamlapen.vampirism.items.PureBloodItem; import de.teamlapen.vampirism.particle.FlyingBloodParticleOptions; @@ -288,7 +288,7 @@ private void tickRitual() { return; } handler.ifPresent(h -> h.setFactionLevel(VReference.VAMPIRE_FACTION, h.getCurrentLevel(VReference.VAMPIRE_FACTION) + 1)); - VampirePlayer.getOpt(player).ifPresent(v -> v.drinkBlood(Integer.MAX_VALUE, 0, false, EnumBloodSource.OTHER)); + VampirePlayer.getOpt(player).ifPresent(v -> v.drinkBlood(Integer.MAX_VALUE, 0, false, DrinkBloodContext.none())); if (player instanceof ServerPlayer serverPlayer) { ModAdvancements.TRIGGER_VAMPIRE_ACTION.trigger(serverPlayer, VampireActionCriterionTrigger.Action.PERFORM_RITUAL_INFUSION); } diff --git a/src/main/java/de/teamlapen/vampirism/blockentity/AltarInspirationBlockEntity.java b/src/main/java/de/teamlapen/vampirism/blockentity/AltarInspirationBlockEntity.java index b80163c566..6382437eca 100644 --- a/src/main/java/de/teamlapen/vampirism/blockentity/AltarInspirationBlockEntity.java +++ b/src/main/java/de/teamlapen/vampirism/blockentity/AltarInspirationBlockEntity.java @@ -2,7 +2,6 @@ import de.teamlapen.lib.lib.util.FluidTankWithListener; import de.teamlapen.vampirism.api.VReference; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.core.ModFluids; import de.teamlapen.vampirism.core.ModParticles; import de.teamlapen.vampirism.core.ModTiles; @@ -10,6 +9,7 @@ import de.teamlapen.vampirism.entity.player.VampirismPlayerAttributes; import de.teamlapen.vampirism.entity.player.vampire.VampireLeveling; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.items.BloodBottleFluidHandler; import de.teamlapen.vampirism.particle.FlyingBloodEntityParticleOptions; import net.minecraft.core.BlockPos; @@ -157,7 +157,7 @@ public static void serverTick(@NotNull Level level, @NotNull BlockPos pos, Block ((InternalTank) blockEntity.tank).doDrain(blood, IFluidHandler.FluidAction.EXECUTE); blockEntity.ritualPlayer.addEffect(new MobEffectInstance(MobEffects.REGENERATION, blockEntity.targetLevel * 10 * 20)); FactionPlayerHandler.getOpt(blockEntity.ritualPlayer).ifPresent(h -> h.setFactionLevel(VReference.VAMPIRE_FACTION, blockEntity.targetLevel)); - VampirePlayer.getOpt(blockEntity.ritualPlayer).ifPresent(v -> v.drinkBlood(Integer.MAX_VALUE, 0, false, EnumBloodSource.OTHER)); + VampirePlayer.getOpt(blockEntity.ritualPlayer).ifPresent(v -> v.drinkBlood(Integer.MAX_VALUE, 0, false, DrinkBloodContext.none())); } } diff --git a/src/main/java/de/teamlapen/vampirism/command/BloodBarCommand.java b/src/main/java/de/teamlapen/vampirism/command/BloodBarCommand.java index bee0ffb8de..84cdafd6ed 100644 --- a/src/main/java/de/teamlapen/vampirism/command/BloodBarCommand.java +++ b/src/main/java/de/teamlapen/vampirism/command/BloodBarCommand.java @@ -4,9 +4,9 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import de.teamlapen.lib.lib.util.BasicCommand; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.entity.player.FactionBasePlayer; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.commands.arguments.EntityArgument; @@ -39,7 +39,7 @@ public class BloodBarCommand extends BasicCommand { private static int setBloodBar(int amount, @NotNull Collection player) { player.stream().map(VampirePlayer::getOpt).filter(player1 -> player1.map(FactionBasePlayer::getLevel).orElse(0) > 0).forEach(player1 -> player1.ifPresent(vampire -> { vampire.useBlood(Integer.MAX_VALUE, true); - vampire.drinkBlood(amount, 0, false, EnumBloodSource.OTHER); + vampire.drinkBlood(amount, 0, false, DrinkBloodContext.none()); })); return 0; } diff --git a/src/main/java/de/teamlapen/vampirism/entity/ai/goals/BiteNearbyEntityVampireGoal.java b/src/main/java/de/teamlapen/vampirism/entity/ai/goals/BiteNearbyEntityVampireGoal.java index 477c766045..3bc3914f43 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/ai/goals/BiteNearbyEntityVampireGoal.java +++ b/src/main/java/de/teamlapen/vampirism/entity/ai/goals/BiteNearbyEntityVampireGoal.java @@ -1,10 +1,10 @@ package de.teamlapen.vampirism.entity.ai.goals; import de.teamlapen.vampirism.api.entity.IExtendedCreatureVampirism; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.api.entity.vampire.IVampireMob; import de.teamlapen.vampirism.core.ModSounds; import de.teamlapen.vampirism.entity.ExtendedCreature; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import net.minecraft.commands.arguments.EntityAnchorArgument; import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.Mob; @@ -87,7 +87,7 @@ public void tick() { if (canFeed(creature)) { int amount = creature.onBite(vampire); vampire.playSound(ModSounds.VAMPIRE_BITE.get(), 1, 1); - vampire.drinkBlood(amount, creature.getBloodSaturation(), EnumBloodSource.BITE_FEED); + vampire.drinkBlood(amount, creature.getBloodSaturation(), new DrinkBloodContext(e)); } } } diff --git a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java index 339f12313d..005e39c54b 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java @@ -6,8 +6,8 @@ import de.teamlapen.vampirism.REFERENCE; import de.teamlapen.vampirism.api.EnumStrength; import de.teamlapen.vampirism.api.entity.convertible.ICurableConvertedCreature; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.api.entity.player.vampire.IBloodStats; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.event.BloodDrinkEvent; import de.teamlapen.vampirism.blockentity.TotemBlockEntity; import de.teamlapen.vampirism.core.ModAdvancements; @@ -15,6 +15,7 @@ import de.teamlapen.vampirism.core.ModVillage; import de.teamlapen.vampirism.entity.VampirismVillagerEntity; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.entity.villager.Trades; import de.teamlapen.vampirism.util.*; import net.minecraft.core.BlockPos; @@ -148,9 +149,9 @@ public boolean doesResistGarlic(EnumStrength strength) { @Override public boolean doHurtTarget(@NotNull Entity entity) { - if (!level().isClientSide && wantsBlood() && entity instanceof Player && !Helper.isHunter(entity) && !UtilLib.canReallySee((LivingEntity) entity, this, true)) { - int amt = VampirePlayer.getOpt((Player) entity).map(vampire -> vampire.onBite(this)).orElse(0); - drinkBlood(amt, IBloodStats.MEDIUM_SATURATION, EnumBloodSource.BITE_FEED); + if (!level().isClientSide && wantsBlood() && entity instanceof Player player && !Helper.isHunter(player) && !UtilLib.canReallySee(player, this, true)) { + int amt = VampirePlayer.getOpt(player).map(vampire -> vampire.onBite(this)).orElse(0); + drinkBlood(amt, IBloodStats.MEDIUM_SATURATION, new DrinkBloodContext(player)); return true; } return super.doHurtTarget(entity); @@ -167,8 +168,8 @@ public boolean doHurtTarget(@NotNull Entity entity) { } @Override - public void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource) { - BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, bloodSource); + public void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext) { + BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, drinkContext); this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, event.getAmount() * 20)); bloodTimer = -1200 - random.nextInt(1200); } diff --git a/src/main/java/de/teamlapen/vampirism/entity/converted/CurableConvertedCreature.java b/src/main/java/de/teamlapen/vampirism/entity/converted/CurableConvertedCreature.java index 35e151eb53..215ffdd263 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/converted/CurableConvertedCreature.java +++ b/src/main/java/de/teamlapen/vampirism/entity/converted/CurableConvertedCreature.java @@ -5,7 +5,7 @@ import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.api.VampirismAPI; import de.teamlapen.vampirism.api.entity.convertible.ICurableConvertedCreature; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.event.BloodDrinkEvent; import de.teamlapen.vampirism.api.items.IVampireFinisher; import de.teamlapen.vampirism.core.ModAttributes; @@ -90,8 +90,8 @@ default InteractionResult mobInteractC(@NotNull Player player, @NotNull Interact } @Override - default void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource) { - BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, bloodSource); + default void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext) { + BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, drinkContext); ((PathfinderMob) this).addEffect(new MobEffectInstance(MobEffects.REGENERATION, event.getAmount() * 20)); } diff --git a/src/main/java/de/teamlapen/vampirism/entity/minion/VampireMinionEntity.java b/src/main/java/de/teamlapen/vampirism/entity/minion/VampireMinionEntity.java index 5ad1395910..05791a2da3 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/minion/VampireMinionEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/minion/VampireMinionEntity.java @@ -8,7 +8,7 @@ import de.teamlapen.vampirism.api.VampirismAPI; import de.teamlapen.vampirism.api.entity.factions.IFactionEntity; import de.teamlapen.vampirism.api.entity.minion.IMinionTask; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.entity.vampire.IVampire; import de.teamlapen.vampirism.api.event.BloodDrinkEvent; import de.teamlapen.vampirism.client.gui.screens.VampireMinionAppearanceScreen; @@ -78,8 +78,8 @@ public boolean doesResistGarlic(EnumStrength strength) { } @Override - public void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource) { - BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, bloodSource); + public void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext) { + BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, drinkContext); this.heal(event.getAmount() / 3f); //blood bottle = 900 amt = 9 amt = 2.5 health } diff --git a/src/main/java/de/teamlapen/vampirism/entity/player/vampire/VampirePlayer.java b/src/main/java/de/teamlapen/vampirism/entity/player/vampire/VampirePlayer.java index 9c34ac3163..cb71656b44 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/player/vampire/VampirePlayer.java +++ b/src/main/java/de/teamlapen/vampirism/entity/player/vampire/VampirePlayer.java @@ -16,8 +16,8 @@ import de.teamlapen.vampirism.api.entity.factions.IFaction; import de.teamlapen.vampirism.api.entity.player.actions.IActionHandler; import de.teamlapen.vampirism.api.entity.player.skills.ISkillHandler; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.api.entity.player.vampire.IBloodStats; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.entity.player.vampire.IVampirePlayer; import de.teamlapen.vampirism.api.entity.player.vampire.IVampireVision; import de.teamlapen.vampirism.api.entity.vampire.IVampire; @@ -37,6 +37,7 @@ import de.teamlapen.vampirism.entity.player.skills.SkillHandler; import de.teamlapen.vampirism.entity.player.vampire.actions.VampireActions; import de.teamlapen.vampirism.entity.player.vampire.skills.VampireSkills; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.fluids.BloodHelper; import de.teamlapen.vampirism.items.VampirismHunterArmorItem; import de.teamlapen.vampirism.mixin.ArmorItemAccessor; @@ -89,7 +90,6 @@ import net.minecraftforge.event.TickEvent; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; -import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -366,8 +366,8 @@ public boolean doesResistGarlic(EnumStrength strength) { } @Override - public void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource) { - BloodDrinkEvent.@NotNull PlayerDrinkBloodEvent event = VampirismEventFactory.fireVampirePlayerDrinkBloodEvent(this, amt, saturationMod, useRemaining, bloodSource); + public void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext) { + BloodDrinkEvent.@NotNull PlayerDrinkBloodEvent event = VampirismEventFactory.fireVampirePlayerDrinkBloodEvent(this, amt, saturationMod, useRemaining, drinkContext); int remainingBlood = this.bloodStats.addBlood(event.getAmount(), event.getSaturation()); if (event.useRemaining() && remainingBlood > 0) { handleSpareBlood(remainingBlood); @@ -1268,7 +1268,7 @@ private void biteBlock(@NotNull BlockPos pos, @NotNull BlockState blockState, @N } } if (blood > 0) { - drinkBlood(blood, IBloodStats.LOW_SATURATION, EnumBloodSource.CONTAINER); + drinkBlood(blood, IBloodStats.LOW_SATURATION, new DrinkBloodContext(blockState, pos)); CompoundTag updatePacket = bloodStats.writeUpdate(new CompoundTag()); sync(updatePacket, true); @@ -1309,8 +1309,7 @@ private boolean biteFeed(@NotNull LivingEntity entity) { saturationMod = ((IBiteableEntity) entity).getBloodSaturation(); } if (blood > 0) { - Pair bloodDrunk = VampirismEventFactory.fireBiteFeedEvent(this, entity, blood, saturationMod); - drinkBlood(bloodDrunk.getLeft(), bloodDrunk.getRight(), EnumBloodSource.BITE_FEED); + drinkBlood(blood, saturationMod, new DrinkBloodContext(entity)); CompoundTag updatePacket = bloodStats.writeUpdate(new CompoundTag()); updatePacket.putInt(KEY_SPAWN_BITE_PARTICLE, entity.getId()); sync(updatePacket, true); diff --git a/src/main/java/de/teamlapen/vampirism/entity/vampire/BasicVampireEntity.java b/src/main/java/de/teamlapen/vampirism/entity/vampire/BasicVampireEntity.java index e17cf54aa4..264b422525 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/vampire/BasicVampireEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/vampire/BasicVampireEntity.java @@ -9,7 +9,7 @@ import de.teamlapen.vampirism.api.entity.actions.EntityActionTier; import de.teamlapen.vampirism.api.entity.actions.IEntityActionUser; import de.teamlapen.vampirism.api.entity.player.IFactionPlayer; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.entity.vampire.IBasicVampire; import de.teamlapen.vampirism.api.event.BloodDrinkEvent; import de.teamlapen.vampirism.api.world.ICaptureAttributes; @@ -261,8 +261,8 @@ public EntityActionTier getEntityTier() { } @Override - public void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource) { - BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, bloodSource); + public void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext) { + BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, drinkContext); this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, event.getAmount() * 20)); boolean dedicated = ServerLifecycleHooks.getCurrentServer().isDedicatedServer(); bloodtimer += event.getAmount() * 40 + this.getRandom().nextInt(1000) * (dedicated ? 2 : 1); diff --git a/src/main/java/de/teamlapen/vampirism/entity/vampire/DrinkBloodContext.java b/src/main/java/de/teamlapen/vampirism/entity/vampire/DrinkBloodContext.java new file mode 100644 index 0000000000..422be53553 --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/entity/vampire/DrinkBloodContext.java @@ -0,0 +1,64 @@ +package de.teamlapen.vampirism.entity.vampire; + +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class DrinkBloodContext implements IDrinkBloodContext { + + private static final DrinkBloodContext NONE = new DrinkBloodContext(); + @Nullable + private LivingEntity entity; + @Nullable + private ItemStack stack; + @Nullable + private BlockState blockState; + @Nullable + private BlockPos blockPos; + + public DrinkBloodContext(@NotNull LivingEntity entity) { + this.entity = entity; + } + + public DrinkBloodContext(@NotNull ItemStack stack) { + this.stack = stack; + } + + public DrinkBloodContext(@NotNull BlockState blockState, @NotNull BlockPos blockPos) { + this.blockState = blockState; + this.blockPos = blockPos; + } + + private DrinkBloodContext() { + } + + public static DrinkBloodContext none() { + return NONE; + } + + @Override + public Optional getEntity() { + return Optional.ofNullable(entity); + } + + @Override + public Optional getStack() { + return Optional.ofNullable(stack); + } + + @Override + public Optional getBlockState() { + return Optional.ofNullable(blockState); + } + + @Override + public Optional getBlockPos() { + return Optional.ofNullable(blockPos); + } +} diff --git a/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java b/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java index ff7cd53eff..b55ac0ca03 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java @@ -4,8 +4,8 @@ import de.teamlapen.vampirism.REFERENCE; import de.teamlapen.vampirism.api.EnumStrength; import de.teamlapen.vampirism.api.VReference; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.api.entity.player.vampire.IBloodStats; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.entity.vampire.IVampireMob; import de.teamlapen.vampirism.api.event.BloodDrinkEvent; import de.teamlapen.vampirism.api.items.IItemWithTier; @@ -185,7 +185,7 @@ public boolean doesResistGarlic(@NotNull EnumStrength strength) { public boolean doHurtTarget(@NotNull Entity entity) { if (canSuckBloodFromPlayer && !level().isClientSide && wantsBlood() && entity instanceof Player player && !Helper.isHunter(player) && !UtilLib.canReallySee(player, this, true)) { int amt = VampirePlayer.getOpt(player).map(v -> v.onBite(this)).orElse(0); - drinkBlood(amt, IBloodStats.MEDIUM_SATURATION, EnumBloodSource.BITE_FEED); + drinkBlood(amt, IBloodStats.MEDIUM_SATURATION, new DrinkBloodContext(player)); VampirePlayer.getOpt(player).ifPresent(v -> v.tryInfect(this)); return true; } @@ -214,8 +214,8 @@ public MobCategory getClassification(boolean forSpawnCount) { } @Override - public void drinkBlood(int amt, float saturationMod, boolean useRemaining, EnumBloodSource bloodSource) { - BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, bloodSource); + public void drinkBlood(int amt, float saturationMod, boolean useRemaining, IDrinkBloodContext drinkContext) { + BloodDrinkEvent.@NotNull EntityDrinkBloodEvent event = VampirismEventFactory.fireVampireDrinkBlood(this, amt, saturationMod, useRemaining, drinkContext); this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, event.getAmount() * 20)); } diff --git a/src/main/java/de/teamlapen/vampirism/items/BloodBottleItem.java b/src/main/java/de/teamlapen/vampirism/items/BloodBottleItem.java index c1a81f21dc..39e78e3536 100644 --- a/src/main/java/de/teamlapen/vampirism/items/BloodBottleItem.java +++ b/src/main/java/de/teamlapen/vampirism/items/BloodBottleItem.java @@ -3,11 +3,11 @@ import de.teamlapen.lib.lib.util.ModDisplayItemGenerator; import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.api.entity.factions.IFaction; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.api.entity.vampire.IVampire; import de.teamlapen.vampirism.api.items.IFactionExclusiveItem; import de.teamlapen.vampirism.core.ModItems; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.fluids.BloodHelper; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -86,11 +86,12 @@ public IFaction getExclusiveFaction(@NotNull ItemStack stack) { @Override public ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level worldIn, @NotNull LivingEntity entityLiving) { if (entityLiving instanceof IVampire) { + ItemStack copy = stack.copy(); int blood = BloodHelper.getBlood(stack); int drink = Math.min(blood, MULTIPLIER); ItemStack[] result = new ItemStack[1]; int amt = BloodHelper.drain(stack, drink, IFluidHandler.FluidAction.EXECUTE, true, containerStack -> result[0] = containerStack); - ((IVampire) entityLiving).drinkBlood(amt / MULTIPLIER, 0, EnumBloodSource.BLOOD_BOTTLE); + ((IVampire) entityLiving).drinkBlood(amt / MULTIPLIER, 0, new DrinkBloodContext(copy)); return result[0]; } return FluidUtil.getFluidHandler(stack).map(IFluidHandlerItem::getContainer).orElseGet(() -> super.finishUsingItem(stack, worldIn, entityLiving)); @@ -120,6 +121,7 @@ public void onUseTick(@NotNull Level level, @NotNull LivingEntity pLivingEntity, pLivingEntity.releaseUsingItem(); return; } + ItemStack copy = stack.copy(); int blood = BloodHelper.getBlood(stack); VampirePlayer vampire = VampirePlayer.getOpt((Player) pLivingEntity).resolve().orElse(null); if (vampire == null || vampire.getLevel() == 0 || blood == 0 || !vampire.getBloodStats().needsBlood()) { @@ -131,7 +133,7 @@ public void onUseTick(@NotNull Level level, @NotNull LivingEntity pLivingEntity, InteractionHand activeHand = pLivingEntity.getUsedItemHand(); int drink = Math.min(blood, 3 * MULTIPLIER); if (BloodHelper.drain(stack, drink, IFluidHandler.FluidAction.EXECUTE, true, containerStack -> pLivingEntity.setItemInHand(activeHand, containerStack)) > 0) { - vampire.drinkBlood(Math.round(((float) drink) / VReference.FOOD_TO_FLUID_BLOOD), 0.3F, false, EnumBloodSource.BLOOD_BOTTLE); + vampire.drinkBlood(Math.round(((float) drink) / VReference.FOOD_TO_FLUID_BLOOD), 0.3F, false, new DrinkBloodContext(copy)); } blood = BloodHelper.getBlood(stack); diff --git a/src/main/java/de/teamlapen/vampirism/items/FeedingAdapterItem.java b/src/main/java/de/teamlapen/vampirism/items/FeedingAdapterItem.java index 9108f06548..412a714820 100644 --- a/src/main/java/de/teamlapen/vampirism/items/FeedingAdapterItem.java +++ b/src/main/java/de/teamlapen/vampirism/items/FeedingAdapterItem.java @@ -1,10 +1,10 @@ package de.teamlapen.vampirism.items; import de.teamlapen.vampirism.api.VReference; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.blocks.BloodContainerBlock; import de.teamlapen.vampirism.core.ModFluids; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.fluids.BloodHelper; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -55,7 +55,7 @@ public void onUseTick(@NotNull Level level, @NotNull LivingEntity player, @NotNu if (blood > 0 && count == 1) { int drink = Math.min(blood, 3 * VReference.FOOD_TO_FLUID_BLOOD); BloodContainerBlock.writeFluidToItemStack(bloodContainer, new FluidStack(ModFluids.BLOOD.get(), blood - drink)); - vampire.drinkBlood(Math.round(((float) drink) / VReference.FOOD_TO_FLUID_BLOOD), 0.3F, false, EnumBloodSource.CONTAINER); + vampire.drinkBlood(Math.round(((float) drink) / VReference.FOOD_TO_FLUID_BLOOD), 0.3F, false, new DrinkBloodContext(bloodContainer)); blood = blood - drink; if (blood > 0) { diff --git a/src/main/java/de/teamlapen/vampirism/items/PureBloodItem.java b/src/main/java/de/teamlapen/vampirism/items/PureBloodItem.java index 0c148dd2f8..2ba6396170 100644 --- a/src/main/java/de/teamlapen/vampirism/items/PureBloodItem.java +++ b/src/main/java/de/teamlapen/vampirism/items/PureBloodItem.java @@ -2,11 +2,11 @@ import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.api.VampirismAPI; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.core.ModEffects; import de.teamlapen.vampirism.core.ModItems; import de.teamlapen.vampirism.entity.player.vampire.VampireLeveling; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; @@ -65,7 +65,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level worldIn, @ public ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level worldIn, @NotNull LivingEntity entityLiving) { if (entityLiving instanceof Player) { VampirePlayer.getOpt((Player) entityLiving).ifPresent(v -> { - v.drinkBlood(50, 0.3f, false, EnumBloodSource.OTHER); + v.drinkBlood(50, 0.3f, false, DrinkBloodContext.none()); entityLiving.addEffect(new MobEffectInstance(ModEffects.SATURATION.get())); stack.shrink(1); }); diff --git a/src/main/java/de/teamlapen/vampirism/items/VampirismItemBloodFoodItem.java b/src/main/java/de/teamlapen/vampirism/items/VampirismItemBloodFoodItem.java index 73cfb4c792..d90a5d9d0b 100755 --- a/src/main/java/de/teamlapen/vampirism/items/VampirismItemBloodFoodItem.java +++ b/src/main/java/de/teamlapen/vampirism/items/VampirismItemBloodFoodItem.java @@ -1,9 +1,8 @@ package de.teamlapen.vampirism.items; -import de.teamlapen.vampirism.VampirismMod; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; import de.teamlapen.vampirism.api.entity.vampire.IVampire; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; +import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext; import de.teamlapen.vampirism.util.Helper; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -30,11 +29,11 @@ public VampirismItemBloodFoodItem(FoodProperties vampireFood, @NotNull FoodPrope @Override public ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level worldIn, @NotNull LivingEntity entityLiving) { if (entityLiving instanceof Player player) { - assert stack.getItem().getFoodProperties() != null;//Don't shrink stack before retrieving food - VampirePlayer.getOpt(player).ifPresent(v -> v.drinkBlood(vampireFood.getNutrition(), vampireFood.getSaturationModifier(), EnumBloodSource.VAMPIRE_FOOD)); + //Don't shrink stack before retrieving food + VampirePlayer.getOpt(player).ifPresent(v -> v.drinkBlood(vampireFood.getNutrition(), vampireFood.getSaturationModifier(), new DrinkBloodContext(stack))); } if (entityLiving instanceof IVampire) { - ((IVampire) entityLiving).drinkBlood(vampireFood.getNutrition(), vampireFood.getSaturationModifier(), EnumBloodSource.VAMPIRE_FOOD); + ((IVampire) entityLiving).drinkBlood(vampireFood.getNutrition(), vampireFood.getSaturationModifier(), new DrinkBloodContext(stack)); stack.shrink(1); } else { entityLiving.eat(worldIn, stack); //Shrinks stack and applies human food effects diff --git a/src/main/java/de/teamlapen/vampirism/util/VampirismEventFactory.java b/src/main/java/de/teamlapen/vampirism/util/VampirismEventFactory.java index 0dce86d322..ed79cce991 100644 --- a/src/main/java/de/teamlapen/vampirism/util/VampirismEventFactory.java +++ b/src/main/java/de/teamlapen/vampirism/util/VampirismEventFactory.java @@ -2,14 +2,13 @@ import de.teamlapen.vampirism.api.entity.factions.IFactionPlayerHandler; import de.teamlapen.vampirism.api.entity.factions.IPlayableFaction; -import de.teamlapen.vampirism.api.entity.player.vampire.EnumBloodSource; +import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext; import de.teamlapen.vampirism.api.entity.player.vampire.IVampirePlayer; import de.teamlapen.vampirism.api.entity.vampire.IVampire; import de.teamlapen.vampirism.api.event.BloodDrinkEvent; import de.teamlapen.vampirism.api.event.PlayerFactionEvent; import de.teamlapen.vampirism.api.event.VampirismVillageEvent; import de.teamlapen.vampirism.api.world.ITotem; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.npc.Villager; import net.minecraftforge.common.MinecraftForge; @@ -66,19 +65,13 @@ public static boolean fireMakeAggressive(@NotNull ITotem totem, @NotNull Village return Pair.of(event.getDefendStrength(), event.getAttackStrength()); } - public static @NotNull Pair fireBiteFeedEvent(@NotNull IVampirePlayer vampirePlayer, @NotNull LivingEntity target, int amount, float saturationAmount) { - BloodDrinkEvent.BiteFeedEvent event = new BloodDrinkEvent.BiteFeedEvent(vampirePlayer, target, amount, saturationAmount); - MinecraftForge.EVENT_BUS.post(event); - return Pair.of(event.getAmount(), event.getSaturation()); - } - - public static @NotNull BloodDrinkEvent.PlayerDrinkBloodEvent fireVampirePlayerDrinkBloodEvent(@NotNull IVampirePlayer vampirePlayer, int amount, float saturationAmount, boolean useRemaining, EnumBloodSource bloodSource) { + public static @NotNull BloodDrinkEvent.PlayerDrinkBloodEvent fireVampirePlayerDrinkBloodEvent(@NotNull IVampirePlayer vampirePlayer, int amount, float saturationAmount, boolean useRemaining, IDrinkBloodContext bloodSource) { BloodDrinkEvent.PlayerDrinkBloodEvent event = new BloodDrinkEvent.PlayerDrinkBloodEvent(vampirePlayer, amount, saturationAmount, useRemaining, bloodSource); MinecraftForge.EVENT_BUS.post(event); return event; } - public static @NotNull BloodDrinkEvent.EntityDrinkBloodEvent fireVampireDrinkBlood(@NotNull IVampire vampire, int amount, float saturationAmount, boolean useRemaining, EnumBloodSource bloodSource) { + public static @NotNull BloodDrinkEvent.EntityDrinkBloodEvent fireVampireDrinkBlood(@NotNull IVampire vampire, int amount, float saturationAmount, boolean useRemaining, IDrinkBloodContext bloodSource) { BloodDrinkEvent.EntityDrinkBloodEvent event = new BloodDrinkEvent.EntityDrinkBloodEvent(vampire, amount, saturationAmount, useRemaining, bloodSource); MinecraftForge.EVENT_BUS.post(event); return event;