Skip to content

Commit

Permalink
[Hotfix] Temporarily disable custom EffectCure syncing (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadows-of-Fire authored May 21, 2024
1 parent 8ac9f9c commit d36fa2d
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions patches/net/minecraft/world/effect/MobEffectInstance.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,26 @@
public static final MapCodec<MobEffectInstance.Details> MAP_CODEC = MapCodec.recursive(
"MobEffectInstance.Details",
p_323465_ -> RecordCodecBuilder.mapCodec(
@@ -408,13 +_,14 @@
Codec.BOOL.optionalFieldOf("ambient", Boolean.valueOf(false)).forGetter(MobEffectInstance.Details::ambient),
@@ -409,10 +_,13 @@
Codec.BOOL.optionalFieldOf("show_particles", Boolean.valueOf(true)).forGetter(MobEffectInstance.Details::showParticles),
Codec.BOOL.optionalFieldOf("show_icon").forGetter(p_323788_ -> Optional.of(p_323788_.showIcon())),
- p_323465_.optionalFieldOf("hidden_effect").forGetter(MobEffectInstance.Details::hiddenEffect)
+ p_323465_.optionalFieldOf("hidden_effect").forGetter(MobEffectInstance.Details::hiddenEffect),
+ net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.setOf(net.neoforged.neoforge.common.EffectCure.CODEC).optionalFieldOf("neoforge:cures").forGetter(MobEffectInstance.Details::cures)
p_323465_.optionalFieldOf("hidden_effect").forGetter(MobEffectInstance.Details::hiddenEffect)
+ // Neo: Add additional serialization logic for custom EffectCure(s)
+ , net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.setOf(net.neoforged.neoforge.common.EffectCure.CODEC).optionalFieldOf("neoforge:cures").forGetter(MobEffectInstance.Details::cures)
)
.apply(p_324063_, MobEffectInstance.Details::create)
)
);
+ // TODO: https://github.com/neoforged/NeoForge/issues/986 - Fix this to have vanilla-compatible sync.
public static final StreamCodec<ByteBuf, MobEffectInstance.Details> STREAM_CODEC = StreamCodec.recursive(
- p_329990_ -> StreamCodec.composite(
+ p_329990_ -> net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.composite(
p_329990_ -> StreamCodec.composite(
ByteBufCodecs.VAR_INT,
MobEffectInstance.Details::amplifier,
ByteBufCodecs.VAR_INT,
@@ -427,14 +_,16 @@
@@ -427,14 +_,23 @@
MobEffectInstance.Details::showIcon,
p_329990_.apply(ByteBufCodecs::optional),
MobEffectInstance.Details::hiddenEffect,
+ net.neoforged.neoforge.common.EffectCure.STREAM_CODEC.<java.util.Set<net.neoforged.neoforge.common.EffectCure>>apply(ByteBufCodecs.collection(java.util.HashSet::new)).apply(ByteBufCodecs::optional),
+ MobEffectInstance.Details::cures,
+ // net.neoforged.neoforge.common.EffectCure.STREAM_CODEC.<java.util.Set<net.neoforged.neoforge.common.EffectCure>>apply(ByteBufCodecs.collection(java.util.HashSet::new)).apply(ByteBufCodecs::optional),
+ // MobEffectInstance.Details::cures,
MobEffectInstance.Details::new
)
);
Expand All @@ -108,7 +105,15 @@
+ int p_323657_, int p_324205_, boolean p_324263_, boolean p_324000_, Optional<Boolean> p_323607_, Optional<MobEffectInstance.Details> p_324604_, Optional<java.util.Set<net.neoforged.neoforge.common.EffectCure>> cures
) {
- return new MobEffectInstance.Details(p_323657_, p_324205_, p_324263_, p_324000_, p_323607_.orElse(p_324000_), p_324604_);
- }
+ return new MobEffectInstance.Details(p_323657_, p_324205_, p_324263_, p_324000_, p_323607_.orElse(p_324000_), p_324604_, cures);
}
+ }
+
+ // TODO: https://github.com/neoforged/NeoForge/issues/986 - Delete these once custom cure sync is fixed.
+ @Deprecated(forRemoval = true, since = "1.20.6")
+ private Details(int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional<MobEffectInstance.Details> hiddenEffect) {
+ this(amplifier, duration, ambient, showParticles, showIcon, hiddenEffect, Optional.empty());
+ }
+
}
}

0 comments on commit d36fa2d

Please sign in to comment.