-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.20.4] Rework how effects determine what they can be cured by (#350)
Fixes #322
- Loading branch information
Showing
15 changed files
with
315 additions
and
219 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
.teamcity/patches/buildTypes/MinecraftForge_MinecraftForge__Build.kts
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
.teamcity/patches/buildTypes/MinecraftForge_MinecraftForge__BuildSecondaryBranches.kts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
11 changes: 11 additions & 0 deletions
11
patches/net/minecraft/world/item/HoneyBottleItem.java.patch
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,11 @@ | ||
--- a/net/minecraft/world/item/HoneyBottleItem.java | ||
+++ b/net/minecraft/world/item/HoneyBottleItem.java | ||
@@ -28,7 +_,7 @@ | ||
} | ||
|
||
if (!p_41349_.isClientSide) { | ||
- p_41350_.removeEffect(MobEffects.POISON); | ||
+ p_41350_.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.HONEY); | ||
} | ||
|
||
if (p_41348_.isEmpty()) { |
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 |
---|---|---|
@@ -1,17 +1,11 @@ | ||
--- a/net/minecraft/world/item/MilkBucketItem.java | ||
+++ b/net/minecraft/world/item/MilkBucketItem.java | ||
@@ -22,13 +_,10 @@ | ||
CriteriaTriggers.CONSUME_ITEM.trigger(serverplayer, p_42923_); | ||
serverplayer.awardStat(Stats.ITEM_USED.get(this)); | ||
@@ -28,7 +_,7 @@ | ||
} | ||
+ if (!p_42924_.isClientSide) p_42925_.curePotionEffects(p_42923_); // FORGE - move up so stack.shrink does not turn stack into air | ||
|
||
if (p_42925_ instanceof Player && !((Player)p_42925_).getAbilities().instabuild) { | ||
p_42923_.shrink(1); | ||
- } | ||
- | ||
- if (!p_42924_.isClientSide) { | ||
if (!p_42924_.isClientSide) { | ||
- p_42925_.removeAllEffects(); | ||
+ p_42925_.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.MILK); | ||
} | ||
|
||
return p_42923_.isEmpty() ? new ItemStack(Items.BUCKET) : p_42923_; |
65 changes: 65 additions & 0 deletions
65
src/main/java/net/neoforged/neoforge/common/EffectCure.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,65 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.common; | ||
|
||
import com.mojang.serialization.Codec; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.neoforged.neoforge.event.entity.living.MobEffectEvent; | ||
|
||
/** | ||
* Defines a cure that is used to remove {@link MobEffect}s from a {@link LivingEntity}. | ||
* <p>Cures can be added to or removed from your own effects via {@link MobEffect#fillEffectCures(Set, MobEffectInstance)} | ||
* or any effect by modifying the set of cures on the {@link MobEffectInstance} in {@link MobEffectEvent.Added} | ||
*/ | ||
public final class EffectCure { | ||
private static final Map<String, EffectCure> CURES = new ConcurrentHashMap<>(); | ||
|
||
public static Codec<EffectCure> CODEC = Codec.STRING.xmap(EffectCure::get, EffectCure::name); | ||
|
||
/** | ||
* {@return all registered cures} | ||
* This collection can be kept around, and will update itself in response to changes to the map. | ||
* See {@link ConcurrentHashMap#values()} for details. | ||
*/ | ||
public static Collection<EffectCure> getActions() { | ||
return Collections.unmodifiableCollection(CURES.values()); | ||
} | ||
|
||
/** | ||
* Gets or creates a new EffectCure for the given name. | ||
*/ | ||
public static EffectCure get(String name) { | ||
return CURES.computeIfAbsent(name, EffectCure::new); | ||
} | ||
|
||
/** | ||
* {@return the name of this cure} | ||
*/ | ||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EffectCure[" + name + "]"; | ||
} | ||
|
||
private final String name; | ||
|
||
/** | ||
* Use {@link #get(String)} to get or create an EffectCure | ||
*/ | ||
private EffectCure(String name) { | ||
this.name = name; | ||
} | ||
} |
Oops, something went wrong.