Fix bound blade not dropping blood shards if you kill in one hit (#141)

This commit is contained in:
koolkrafter5 authored and GitHub committed 2026-07-14 20:06:43 +02:00
1 parent acfbc0f8ff
commit 6f45c3efae
4 files changed
+30 -47

No files matched your search

@@ -64,7 +64,6 @@ import WayofTime.alchemicalWizardry.common.ClientToServerPacketHandler;
import WayofTime.alchemicalWizardry.common.CommonProxy;
import WayofTime.alchemicalWizardry.common.LifeBucketHandler;
import WayofTime.alchemicalWizardry.common.LifeEssence;
import WayofTime.alchemicalWizardry.common.ModLivingDropsEvent;
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import WayofTime.alchemicalWizardry.common.achievements.ModAchievements;
import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry;
@@ -1554,7 +1553,6 @@ public class AlchemicalWizardry {
blacklistAccelerators();
MinecraftForge.EVENT_BUS.register(new ModLivingDropsEvent());
proxy.InitRendering();
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
@@ -11,6 +11,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
@@ -27,6 +28,7 @@ import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -35,14 +37,17 @@ import net.minecraftforge.event.entity.player.EntityInteractEvent;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.BloodMagicConfiguration;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.BlockStack;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.event.TeleposeEvent;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import WayofTime.alchemicalWizardry.common.achievements.ModAchievements;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import WayofTime.alchemicalWizardry.common.items.EnergySword;
import WayofTime.alchemicalWizardry.common.items.armour.BoundArmour;
import WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour;
@@ -153,6 +158,31 @@ public class AlchemicalWizardryEventHooks {
}
}
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
if (!(event.source.getEntity() instanceof EntityPlayer player)) {
return;
}
ItemStack item = player.getCurrentEquippedItem();
if (item != null && item.getItem() instanceof EnergySword sword
&& IBindable.checkAndSetItemOwner(item, player)
&& EnergyItems.syphonBatteries(item, player, sword.drainCost())) {
event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
}
}
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {
if (!event.source.getDamageType().equals("player") || event.entityLiving instanceof EntityAnimal) {
return;
}
PotionEffect effect = event.entityLiving.getActivePotionEffect(Potion.weakness);
if (effect != null && effect.getAmplifier() >= 2 && Math.random() < 0.50d) {
event.entityLiving.dropItem(ModItems.weakBloodShard, 1);
}
}
@SubscribeEvent
public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) {
if (event.entityLiving instanceof EntityPlayer player && !event.entityLiving.worldObj.isRemote) {
@@ -1,31 +0,0 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ModLivingDropsEvent {
public static double rand;
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {
if (event.source.getDamageType().equals("player")) {
rand = Math.random();
if (!(event.entityLiving instanceof EntityAnimal)) {
PotionEffect effect = event.entityLiving.getActivePotionEffect(Potion.weakness);
if (effect != null) {
if (effect.getAmplifier() >= 2) if (rand < 0.50d) {
event.entityLiving.dropItem(ModItems.weakBloodShard, 1);
}
}
}
}
}
}
@@ -4,12 +4,9 @@ import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
@@ -88,17 +85,6 @@ public class EnergySword extends ItemSword implements IBindable {
return !isActive;
}
@Override
public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) {
if (attacker instanceof EntityPlayer player && (!IBindable.checkAndSetItemOwner(item, player)
|| !EnergyItems.syphonBatteries(item, player, this.drainCost()))) {
return false;
}
target.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
return true;
}
@Override
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) {
super.onItemRightClick(item, world, player);