|
22 | 22 |
|
23 | 23 | package com.falsepattern.endlessids.mixin.mixins.common.potion.vanilla; |
24 | 24 |
|
25 | | -import com.falsepattern.endlessids.EndlessIDs; |
26 | | -import com.falsepattern.endlessids.constants.ExtendedConstants; |
27 | 25 | import lombok.val; |
28 | | -import lombok.var; |
29 | 26 | import org.spongepowered.asm.mixin.Mixin; |
30 | 27 | import org.spongepowered.asm.mixin.Shadow; |
31 | 28 | import org.spongepowered.asm.mixin.injection.At; |
32 | 29 | import org.spongepowered.asm.mixin.injection.Inject; |
33 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
34 | 30 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
35 | 31 |
|
36 | 32 | import net.minecraft.nbt.NBTTagCompound; |
|
40 | 36 | @Mixin(value = PotionEffect.class, |
41 | 37 | priority = 2000 ) //Hodgepodge fixPotionLimit compat (inject-head into overwrite in readCustomPotionEffectFromNBT) |
42 | 38 | public abstract class PotionEffectMixin { |
43 | | - @Inject(method = "<init>(IIIZ)V", |
44 | | - at = @At("RETURN"), |
45 | | - require = 1) |
46 | | - private void fixOutOfBoundsID(int p_i1576_1_, int p_i1576_2_, int p_i1576_3_, boolean p_i1576_4_, CallbackInfo ci) { |
47 | | - var id = p_i1576_1_ & ExtendedConstants.potionIDMask; |
48 | | - recovery: |
49 | | - if (id != p_i1576_1_ && Potion.potionTypes[id] == null) { |
50 | | - //Maybe vanilla code? |
51 | | - val realId = id; |
52 | | - id = id & 0xFF; |
53 | | - if (Potion.potionTypes[id] == null) { |
54 | | - //Nope |
55 | | - id = realId; |
56 | | - } |
57 | | - } |
58 | | - if (Potion.potionTypes[id] == null) { |
59 | | - EndlessIDs.LOG.error("Encountered invalid potion ID: {}. See the following stacktrace for more info.", p_i1576_1_); |
60 | | - EndlessIDs.LOG.error("Stacktrace:", new Throwable()); |
61 | | - EndlessIDs.LOG.error("Recovering to a valid potion ID (usually movement speed)"); |
62 | | - for (int i = 0; i < Potion.potionTypes.length; i++) { |
63 | | - if (Potion.potionTypes[i] != null) { |
64 | | - id = i; |
65 | | - break; |
66 | | - } |
67 | | - } |
68 | | - } |
69 | | - this.potionID = id; |
70 | | - } |
71 | | - |
72 | 39 | @Inject(method = "readCustomPotionEffectFromNBT", |
73 | 40 | at = @At(value = "HEAD"), |
74 | 41 | cancellable = true, |
|
0 commit comments