|
1 | 1 | package huix.infinity.mixin.world.entity; |
2 | 2 |
|
| 3 | +import com.mojang.authlib.GameProfile; |
| 4 | +import com.mojang.serialization.DataResult; |
| 5 | +import huix.infinity.attachment.IFWAttachments; |
3 | 6 | import huix.infinity.common.core.component.IFWDataComponents; |
4 | 7 | import huix.infinity.common.core.registries.IFWRegistries; |
5 | 8 | import huix.infinity.common.world.curse.Curse; |
|
10 | 13 | import huix.infinity.init.InfinityWay; |
11 | 14 | import huix.infinity.util.ReflectHelper; |
12 | 15 | import huix.infinity.util.WorldHelper; |
| 16 | +import net.minecraft.core.GlobalPos; |
13 | 17 | import net.minecraft.nbt.CompoundTag; |
| 18 | +import net.minecraft.nbt.ListTag; |
| 19 | +import net.minecraft.nbt.NbtOps; |
14 | 20 | import net.minecraft.resources.ResourceLocation; |
15 | 21 | import net.minecraft.sounds.SoundEvents; |
16 | 22 | import net.minecraft.util.Mth; |
17 | 23 | import net.minecraft.world.entity.*; |
18 | 24 | import net.minecraft.world.entity.ai.attributes.AttributeSupplier; |
19 | 25 | import net.minecraft.world.entity.ai.attributes.Attributes; |
| 26 | +import net.minecraft.world.entity.player.Abilities; |
| 27 | +import net.minecraft.world.entity.player.Inventory; |
20 | 28 | import net.minecraft.world.entity.player.Player; |
21 | 29 | import net.minecraft.world.food.FoodData; |
22 | 30 | import net.minecraft.world.food.FoodProperties; |
| 31 | +import net.minecraft.world.inventory.PlayerEnderChestContainer; |
23 | 32 | import net.minecraft.world.item.ItemStack; |
24 | 33 | import net.minecraft.world.level.GameRules; |
25 | 34 | import net.minecraft.world.level.Level; |
| 35 | +import net.minecraft.world.phys.Vec3; |
26 | 36 | import net.neoforged.neoforge.common.NeoForge; |
27 | 37 | import net.neoforged.neoforge.common.NeoForgeMod; |
28 | 38 | import net.neoforged.neoforge.event.entity.player.PlayerXpEvent; |
29 | | -import org.spongepowered.asm.mixin.Mixin; |
30 | | -import org.spongepowered.asm.mixin.Overwrite; |
31 | | -import org.spongepowered.asm.mixin.Shadow; |
32 | | -import org.spongepowered.asm.mixin.Unique; |
| 39 | +import org.slf4j.Logger; |
| 40 | +import org.spongepowered.asm.mixin.*; |
33 | 41 | import org.spongepowered.asm.mixin.injection.At; |
34 | 42 | import org.spongepowered.asm.mixin.injection.Inject; |
35 | 43 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
36 | 44 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
37 | 45 |
|
| 46 | +import javax.annotation.Nullable; |
38 | 47 | import java.util.Objects; |
| 48 | +import java.util.Optional; |
39 | 49 |
|
40 | | -@Mixin( Player.class ) |
| 50 | +@Mixin(Player.class) |
41 | 51 | public abstract class PlayerMixin extends LivingEntity implements PlayerExtension { |
42 | 52 |
|
43 | | - @Shadow public abstract void causeFoodExhaustion(float exhaustion); |
44 | | - |
45 | | - @Shadow public abstract FoodData getFoodData(); |
46 | | - |
47 | | - |
48 | | - @Unique |
49 | | - private PersistentEffectInstance curse; |
50 | | - |
51 | 53 | @Unique |
52 | | - public boolean learnedCurse = false; |
| 54 | + private PersistentEffectInstance curse = PersistentEffectInstance.of(Curses.none); |
| 55 | + @Override |
| 56 | + public Curse curse() { |
| 57 | + return (Curse) this.curse.persistentEff().value(); |
| 58 | + } |
53 | 59 |
|
54 | 60 | @Override |
55 | 61 | public boolean knownCurse() { |
56 | | - return this.hasCurse() && this.learnedCurse; |
| 62 | + return learnedCurse; |
57 | 63 | } |
58 | 64 |
|
59 | | -// @Override |
60 | | -// public void curse(PersistentEffectInstance curse) { |
61 | | -// this.curse = curse; |
62 | | -// } |
| 65 | + @Override |
| 66 | + public void learnCurse() { |
| 67 | + learnedCurse = true; |
| 68 | + } |
63 | 69 |
|
64 | | -// @Override |
65 | | -// public Curse curse() { |
66 | | -// System.out.println(this.curse); |
67 | | -// return (Curse) this.curse.persistentEff().value(); |
68 | | -// } |
| 70 | + @Unique |
| 71 | + private boolean learnedCurse = false; |
69 | 72 |
|
70 | | - @Inject(at = @At(value = "RETURN"), method = "readAdditionalSaveData") |
| 73 | + @Inject(at = @At("RETURN"), method = "readAdditionalSaveData") |
71 | 74 | private void readNBT(CompoundTag compound, CallbackInfo ci){ |
72 | | -// this.curse(PersistentEffectInstance.load(compound.getCompound("curse"))); |
73 | | - this.curse(Curses.cannot_eat_meats); |
74 | | - System.out.println("11111111111" + this.curse); |
75 | 75 | this.learnedCurse = compound.getBoolean("learnedCurse"); |
76 | 76 | } |
77 | 77 |
|
78 | 78 | @Inject(at = @At("RETURN"), method = "addAdditionalSaveData") |
79 | | - private void saveNBT(CompoundTag compound, CallbackInfo ci) { |
80 | | - if (curse != null) compound.put("curse", this.curse.save()); |
| 79 | + private void injectNBT(CompoundTag compound, CallbackInfo ci){ |
81 | 80 | compound.putBoolean("learnedCurse", this.learnedCurse); |
82 | 81 | } |
83 | 82 |
|
| 83 | + @Override |
| 84 | + public void curse(PersistentEffectInstance curse) { |
| 85 | + this.curse = curse; |
| 86 | + } |
84 | 87 |
|
85 | 88 | @Overwrite |
86 | 89 | public int getXpNeededForNextLevel() { |
@@ -231,6 +234,29 @@ protected PlayerMixin(EntityType<? extends LivingEntity> entityType, Level level |
231 | 234 | private int lastLevelUpTime; |
232 | 235 | @Shadow |
233 | 236 | public float experienceProgress; |
| 237 | + @Shadow @Final private GameProfile gameProfile; |
| 238 | + @Shadow private int currentImpulseContextResetGraceTime; |
| 239 | + @Shadow private boolean ignoreFallDamageFromCurrentImpulse; |
| 240 | + @Shadow @Nullable public Vec3 currentImpulseImpactPos; |
| 241 | + |
| 242 | + @Shadow public abstract void setLastDeathLocation(Optional<GlobalPos> lastDeathLocation); |
| 243 | + |
| 244 | + @Shadow protected abstract void setShoulderEntityRight(CompoundTag entityCompound); |
| 245 | + |
| 246 | + @Shadow protected abstract void setShoulderEntityLeft(CompoundTag entityCompound); |
| 247 | + |
| 248 | + @Shadow protected PlayerEnderChestContainer enderChestInventory; |
| 249 | + @Shadow @Final private Abilities abilities; |
| 250 | + @Shadow protected FoodData foodData; |
| 251 | + |
| 252 | + @Shadow public abstract void setScore(int score); |
| 253 | + |
| 254 | + @Shadow public int enchantmentSeed; |
| 255 | + @Shadow @Final private Inventory inventory; |
| 256 | + |
| 257 | + @Shadow public abstract void causeFoodExhaustion(float exhaustion); |
| 258 | + |
| 259 | + @Shadow public abstract FoodData getFoodData(); |
234 | 260 | @Shadow |
235 | 261 | public void increaseScore(int score) { |
236 | 262 | } |
|
0 commit comments