-
-
Notifications
You must be signed in to change notification settings - Fork 478
feat: Cure effects food property #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c27e67a
feat: honey bottle cures and heals
RealRONiN 95127da
refactor: cure effects food property
RealRONiN 4e45b8d
refactor: moved Paper's honey bottle cure poison to default food prop…
RealRONiN be73255
revert: reverted some formattings and auto-imports
RealRONiN 174d563
Merge branch 'ver/1.19.2' into RealRONiN/ver/1.19.2
granny c239491
rebase
granny 1b640b4
deep clean patch
granny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat: honey bottle cures and heals
- Loading branch information
commit c27e67a4a830c1c9c003a4da80226a5f98bf6d95
There are no files selected for viewing
This file contains hidden or 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,141 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aniket Joshi <arealronin@gmail.com> | ||
| Date: Thu, 6 Oct 2022 14:11:41 +0530 | ||
| Subject: [PATCH] Honey bottle cures and heals | ||
|
|
||
|
|
||
| diff --git a/src/main/java/net/minecraft/world/item/HoneyBottleItem.java b/src/main/java/net/minecraft/world/item/HoneyBottleItem.java | ||
| index c8d6b5e60b6c8c612fa8580c63a32c4a8f8b0a7b..4f9ec6b66b0d923a1c2c2e95272c3472da8840de 100644 | ||
| --- a/src/main/java/net/minecraft/world/item/HoneyBottleItem.java | ||
| +++ b/src/main/java/net/minecraft/world/item/HoneyBottleItem.java | ||
| @@ -7,10 +7,17 @@ import net.minecraft.sounds.SoundEvents; | ||
| import net.minecraft.stats.Stats; | ||
| import net.minecraft.world.InteractionHand; | ||
| import net.minecraft.world.InteractionResultHolder; | ||
| +import net.minecraft.world.effect.MobEffect; | ||
| +import net.minecraft.world.effect.MobEffectInstance; | ||
| import net.minecraft.world.effect.MobEffects; | ||
| import net.minecraft.world.entity.LivingEntity; | ||
| import net.minecraft.world.entity.player.Player; | ||
| import net.minecraft.world.level.Level; | ||
| +import org.bukkit.event.entity.EntityPotionEffectEvent; | ||
| +import org.bukkit.event.entity.EntityRegainHealthEvent; | ||
| + | ||
| +import java.util.List; | ||
| +import java.util.Map; | ||
|
|
||
| public class HoneyBottleItem extends Item { | ||
| private static final int DRINK_DURATION = 40; | ||
| @@ -29,6 +36,33 @@ public class HoneyBottleItem extends Item { | ||
|
|
||
| if (!world.isClientSide) { | ||
| user.removeEffect(MobEffects.POISON, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper | ||
| + | ||
| + // Purpur start - honey bottle cures and heals | ||
| + if (world.purpurConfig.honeyBottleCures) { | ||
| + Map<MobEffect, MobEffectInstance> effects = user.activeEffects; | ||
| + if (!effects.isEmpty()) { | ||
| + for (MobEffect effect : effects.keySet()) { | ||
| + if (world.purpurConfig.honeyBottleCurableEffects.contains(effect) && | ||
| + user.hasEffect(effect)) | ||
| + user.removeEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); | ||
| + } | ||
| + } | ||
| + } | ||
| + | ||
| + if (world.purpurConfig.honeyBottleHeals) { | ||
| + user.heal(world.purpurConfig.honeyBottleRegenAmount, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); | ||
| + } | ||
| + | ||
| + if (world.purpurConfig.honeyBottleAddsPositiveEffects) { | ||
| + List<MobEffect> effects = world.purpurConfig.honeyBottleAddedEffects; | ||
| + if (!effects.isEmpty()) { | ||
| + for (MobEffect effect : effects) { | ||
| + user.addEffect(new MobEffectInstance(effect, world.purpurConfig.honeyBottlePotionEffectsDuration), | ||
| + org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); | ||
| + } | ||
| + } | ||
| + } | ||
| + // Purpur end | ||
| } | ||
|
|
||
| if (stack.isEmpty()) { | ||
| @@ -70,4 +104,4 @@ public class HoneyBottleItem extends Item { | ||
| public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) { | ||
| return ItemUtils.startUsingInstantly(world, user, hand); | ||
| } | ||
| -} | ||
| +} | ||
| \ No newline at end of file | ||
| diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java | ||
| index a6356d19f0fc664be523f19c2ea1704191a7a73a..f70903ad70a0c215f313f9c5636a92a6c2decaa6 100644 | ||
| --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java | ||
| +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java | ||
| @@ -4,15 +4,20 @@ import gg.pufferfish.pufferfish.PufferfishConfig; | ||
| import net.minecraft.core.Registry; | ||
| import net.minecraft.resources.ResourceLocation; | ||
| import net.minecraft.util.Mth; | ||
| +import net.minecraft.world.effect.MobEffect; | ||
| +import net.minecraft.world.effect.MobEffects; | ||
| import net.minecraft.world.entity.Entity; | ||
| import net.minecraft.world.entity.EntityType; | ||
| import net.minecraft.world.item.DyeColor; | ||
| import net.minecraft.world.item.Item; | ||
| import net.minecraft.world.item.Items; | ||
| +import net.minecraft.world.item.alchemy.Potion; | ||
| +import net.minecraft.world.item.alchemy.Potions; | ||
| import net.minecraft.world.level.Explosion; | ||
| import net.minecraft.world.level.block.Block; | ||
| import net.minecraft.world.level.block.Blocks; | ||
| import net.minecraft.world.level.block.state.properties.Tilt; | ||
| +import org.bukkit.potion.PotionEffectType; | ||
| import org.purpurmc.purpur.entity.GlowSquidColor; | ||
| import org.purpurmc.purpur.tool.Strippable; | ||
| import org.purpurmc.purpur.tool.Tillable; | ||
| @@ -3131,5 +3136,44 @@ public class PurpurWorldConfig { | ||
| cauldronDripstoneWaterFillChance = (float) getDouble("blocks.cauldron.fill-chances.dripstone-water", cauldronDripstoneWaterFillChance); | ||
| cauldronDripstoneLavaFillChance = (float) getDouble("blocks.cauldron.fill-chances.dripstone-lava", cauldronDripstoneLavaFillChance); | ||
| } | ||
| -} | ||
|
|
||
| + public boolean honeyBottleCures = false; | ||
| + public boolean honeyBottleHeals = false; | ||
| + public float honeyBottleRegenAmount = 1.5f; | ||
| + public boolean honeyBottleAddsPositiveEffects = true; | ||
| + public int honeyBottlePotionEffectsDuration = 200; | ||
| + public List<MobEffect> honeyBottleCurableEffects = new ArrayList<>(); | ||
|
RealRONiN marked this conversation as resolved.
Outdated
|
||
| + public List<MobEffect> honeyBottleAddedEffects = new ArrayList<>(); | ||
|
RealRONiN marked this conversation as resolved.
Outdated
|
||
| + private void honeyBottleSettings() { | ||
| + honeyBottleCures = getBoolean("gameplay-mechanics.item.honey-bottle.cures-effects", honeyBottleCures); | ||
| + honeyBottleHeals = getBoolean("gameplay-mechanics.item.honey-bottle.heals", honeyBottleHeals); | ||
| + honeyBottleAddsPositiveEffects = getBoolean("gameplay-mechanics.item.honey-bottle.adds-effects", honeyBottleAddsPositiveEffects); | ||
| + honeyBottleRegenAmount = (float) getDouble("gameplay-mechanics.item.honey-bottle.regen-health-amount", honeyBottleRegenAmount); | ||
| + honeyBottlePotionEffectsDuration = getInt("gameplay-mechanics.item.honey-bottle.potion-effects-duration", honeyBottlePotionEffectsDuration); | ||
| + | ||
| + getList("gameplay-mechanics.item.honey-bottle.curable-effects", new ArrayList<String>(){{ | ||
| + add("minecraft:slowness"); | ||
| + add("minecraft:mining_fatigue"); | ||
| + add("minecraft:nausea"); | ||
| + add("minecraft:blindness"); | ||
| + add("minecraft:poison"); | ||
| + add("minecraft:wither"); | ||
| + add("minecraft:levitation"); | ||
| + add("minecraft:unluck"); | ||
| + add("minecraft:bad_omen"); | ||
|
RealRONiN marked this conversation as resolved.
Outdated
|
||
| + }}).forEach(key -> { | ||
| + MobEffect curableEffect = Registry.MOB_EFFECT.get(new ResourceLocation(key.toString())); | ||
| + honeyBottleCurableEffects.add(curableEffect); | ||
| + }); | ||
| + | ||
| + getList("gameplay-mechanics.item.honey-bottle.added-effects", new ArrayList<String>(){{ | ||
| + add("minecraft:strength"); | ||
| + add("minecraft:regeneration"); | ||
| + add("minecraft:saturation"); | ||
| + add("minecraft:glowing"); | ||
|
RealRONiN marked this conversation as resolved.
Outdated
|
||
| + }}).forEach(key -> { | ||
| + MobEffect addedEffect = Registry.MOB_EFFECT.get(new ResourceLocation(key.toString())); | ||
| + honeyBottleAddedEffects.add(addedEffect); | ||
| + }); | ||
| + } | ||
| +} | ||
| \ No newline at end of file | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.