From a030ebbd6d3fb2bff1d40c9cecee66157f1bd68d Mon Sep 17 00:00:00 2001 From: Majrusz Date: Sun, 18 Jul 2021 12:01:50 +0200 Subject: [PATCH] Certain End Tools now also has an increased chance to inflict Bleeding --- .../com/majruszs_difficulty/Instances.java | 6 +++-- .../when_damaged/EndToolsBleedingOnHurt.java | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/majruszs_difficulty/features/end_items/when_damaged/EndToolsBleedingOnHurt.java diff --git a/src/main/java/com/majruszs_difficulty/Instances.java b/src/main/java/com/majruszs_difficulty/Instances.java index 8451ae3fd..b0cc96ac2 100644 --- a/src/main/java/com/majruszs_difficulty/Instances.java +++ b/src/main/java/com/majruszs_difficulty/Instances.java @@ -8,6 +8,8 @@ import com.majruszs_difficulty.effects.InfestedEffect; import com.majruszs_difficulty.entities.EntitiesConfig; import com.majruszs_difficulty.features.ExperienceBonus; +import com.majruszs_difficulty.features.end_items.when_damaged.EndToolsBleedingOnHurt; +import com.majruszs_difficulty.features.end_items.when_damaged.EndToolsLevitationOnAttack; import com.majruszs_difficulty.features.on_death.SpawnParasitesOnDeath; import com.majruszs_difficulty.features.treasure_bag.FishingRewarder; import com.majruszs_difficulty.features.IncreaseGameDifficulty; @@ -26,7 +28,6 @@ import com.majruszs_difficulty.generation.structures.FlyingEndIslandStructure; import com.majruszs_difficulty.generation.structures.FlyingPhantomStructure; import com.majruszs_difficulty.triggers.*; -import javafx.beans.binding.When; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.item.ItemGroup; import net.minecraft.item.SwordItem; @@ -213,7 +214,6 @@ public class Instances { WhenDamagedEvent.REGISTRY_LIST.add( new ThrownTridentBleedingOnHurt() ); WhenDamagedEvent.REGISTRY_LIST.add( new BiteBleedingOnAttack() ); WhenDamagedEvent.REGISTRY_LIST.add( new EndermanTeleportOnAttack() ); - WhenDamagedEvent.REGISTRY_LIST.add( new EndSwordLevitationOnAttack() ); WhenDamagedEvent.REGISTRY_LIST.add( new TriggerAllEndermansOnAttack() ); WhenDamagedEvent.REGISTRY_LIST.add( new ShulkerBlindnessOnAttack() ); WhenDamagedEvent.REGISTRY_LIST.add( new NauseaAndSlownessWhenFalling() ); @@ -222,6 +222,8 @@ public class Instances { WhenDamagedEvent.REGISTRY_LIST.add( new SlimeSlownessOnAttack() ); WhenDamagedEvent.REGISTRY_LIST.add( new ParasiteInfestOnAttack() ); WhenDamagedEvent.REGISTRY_LIST.add( new ParasiteDodgeOnHurt() ); + WhenDamagedEvent.REGISTRY_LIST.add( new EndToolsLevitationOnAttack() ); + WhenDamagedEvent.REGISTRY_LIST.add( new EndToolsBleedingOnHurt() ); // On enemy to be spawned OnEnemyToBeSpawnedEvent.REGISTRY_LIST.add( new StrengthenedEntityAttributesOnSpawn() ); diff --git a/src/main/java/com/majruszs_difficulty/features/end_items/when_damaged/EndToolsBleedingOnHurt.java b/src/main/java/com/majruszs_difficulty/features/end_items/when_damaged/EndToolsBleedingOnHurt.java new file mode 100644 index 000000000..dec78c912 --- /dev/null +++ b/src/main/java/com/majruszs_difficulty/features/end_items/when_damaged/EndToolsBleedingOnHurt.java @@ -0,0 +1,25 @@ +package com.majruszs_difficulty.features.end_items.when_damaged; + +import com.majruszs_difficulty.features.end_items.EndItems; +import com.majruszs_difficulty.features.when_damaged.WhenDamagedApplyBleedingBase; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.DamageSource; + +import javax.annotation.Nullable; + +/** Makes certain End Tools have an extra chance to inflict Bleeding effect. */ +public class EndToolsBleedingOnHurt extends WhenDamagedApplyBleedingBase { + private static final String CONFIG_NAME = "EndToolsBleeding"; + private static final String CONFIG_COMMENT = "End Axe, End Sword and End Hoe have a greater chance to inflict Bleeding."; + + public EndToolsBleedingOnHurt() { + super( CONFIG_NAME, CONFIG_COMMENT, 0.5, 24.0 ); + } + + /** Checking if all conditions were met. */ + @Override + public boolean shouldBeExecuted( @Nullable LivingEntity attacker, LivingEntity target, DamageSource damageSource ) { + return attacker != null && EndItems.haveExtraBleedingChance( attacker.getHeldItemMainhand() + .getItem() ) && super.shouldBeExecuted( attacker, target, damageSource ); + } +} \ No newline at end of file