-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from Gu-ZT/CuredItem
诅咒金相关物品给玩家带来的debuff进行创造模式判断
- Loading branch information
Showing
3 changed files
with
31 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dev.dubhe.anvilcraft.item; | ||
|
||
import dev.dubhe.anvilcraft.init.ModItems; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
|
||
public interface Cured { | ||
default void inventoryTick(ItemStack stack, Level level, Entity entity, int slotId, boolean isSelected) { | ||
if (!(entity instanceof Player player)) return; | ||
if (player.getAbilities().instabuild) return; | ||
MobEffectInstance weakness = new MobEffectInstance(MobEffects.WEAKNESS, 200, 1, false, true); | ||
MobEffectInstance slowness = new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 200, 1, false, true); | ||
MobEffectInstance hungry = new MobEffectInstance(MobEffects.HUNGER, 200, 1, false, true); | ||
player.addEffect((weakness)); | ||
int curedNumber = player.getInventory().countItem(ModItems.CURSED_GOLD_INGOT) + player.getInventory().countItem(ModItems.CURSED_GOLD_NUGGET) + player.getInventory().countItem(ModItems.CURSED_GOLD_BLOCK); | ||
if (curedNumber > 8) { | ||
player.addEffect((slowness)); | ||
} | ||
if (curedNumber > 64) { | ||
player.addEffect((hungry)); | ||
} | ||
} | ||
} |
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