This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
generated from NeoForgeMDKs/MDK-1.21-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
72 additions
and
7 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
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,32 @@ | ||
package ho.artisan.farmaway.common; | ||
|
||
import ho.artisan.farmaway.FarmAway; | ||
import ho.artisan.farmaway.common.registry.FAEffects; | ||
import net.minecraft.util.RandomSource; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent; | ||
|
||
@EventBusSubscriber(modid = FarmAway.MOD_ID) | ||
public class FAEvents { | ||
@SubscribeEvent | ||
public static void livingDamagePost(LivingIncomingDamageEvent event) { | ||
int a = event.getEntity().getEffect(FAEffects.BLUES).getAmplifier(); | ||
if (event.getEntity().hasEffect(FAEffects.BLUES)) { | ||
int i = RandomSource.create().nextInt(0, 100); | ||
if (a <= 6) { | ||
if (i > 50 - a * 5) { | ||
event.setAmount(0); | ||
} else { | ||
event.setAmount(event.getOriginalAmount() * 2); | ||
} | ||
} else { | ||
if (i > 50 - 6 * 5) { | ||
event.setAmount(0); | ||
} else { | ||
event.setAmount(event.getOriginalAmount() * 2); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
12 changes: 12 additions & 0 deletions
12
src/main/java/ho/artisan/farmaway/common/effect/BluesEffect.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,12 @@ | ||
package ho.artisan.farmaway.common.effect; | ||
|
||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class BluesEffect extends MobEffect { | ||
public BluesEffect() { | ||
super(MobEffectCategory.NEUTRAL, 1); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/ho/artisan/farmaway/common/registry/FAEffects.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,17 @@ | ||
package ho.artisan.farmaway.common.registry; | ||
|
||
import ho.artisan.farmaway.FarmAway; | ||
import ho.artisan.farmaway.common.effect.BluesEffect; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
public class FAEffects { | ||
private static DeferredRegister<MobEffect> EFFECTS = DeferredRegister.create(BuiltInRegistries.MOB_EFFECT, FarmAway.MOD_ID); | ||
public static Holder<MobEffect> BLUES = EFFECTS.register("blues", BluesEffect::new); | ||
public static void register(IEventBus bus) { | ||
EFFECTS.register(bus); | ||
} | ||
} |
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
File renamed without changes