|
| 1 | +/* |
| 2 | + * This file is part of the Carpet AMS Addition project, licensed under the |
| 3 | + * GNU Lesser General Public License v3.0 |
| 4 | + * |
| 5 | + * Copyright (C) 2024 A Minecraft Server and contributors |
| 6 | + * |
| 7 | + * Carpet AMS Addition is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Lesser General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * Carpet AMS Addition is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU Lesser General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public License |
| 18 | + * along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +package club.mcams.carpet.mixin.rule.ghastFireballExplosionDamageSourceFix; |
| 22 | + |
| 23 | +import club.mcams.carpet.AmsServerSettings; |
| 24 | +import net.minecraft.entity.Entity; |
| 25 | +import net.minecraft.entity.projectile.FireballEntity; |
| 26 | +import org.jetbrains.annotations.Nullable; |
| 27 | +import org.spongepowered.asm.mixin.Mixin; |
| 28 | +import org.spongepowered.asm.mixin.injection.At; |
| 29 | +import org.spongepowered.asm.mixin.injection.ModifyArg; |
| 30 | + |
| 31 | +//For version <1.19.3 |
| 32 | +@Mixin(FireballEntity.class) |
| 33 | +public class FireballEntityMixin { |
| 34 | + //#if MC<11903 |
| 35 | + @ModifyArg( |
| 36 | + method="Lnet/minecraft/entity/projectile/FireballEntity;onCollision(Lnet/minecraft/util/hit/HitResult;)V", |
| 37 | + at=@At( |
| 38 | + value="INVOKE", |
| 39 | + target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;DDDFZLnet/minecraft/world/explosion/Explosion$DestructionType;)Lnet/minecraft/world/explosion/Explosion;" |
| 40 | + ), |
| 41 | + index=0 |
| 42 | + ) |
| 43 | + public Entity fillUpExplosionOwner(@Nullable Entity entity) { |
| 44 | + if(AmsServerSettings.ghastFireballExplosionDamageSourceFix) { |
| 45 | + return (FireballEntity) (Object) this; |
| 46 | + } |
| 47 | + else { |
| 48 | + return entity; |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + //#endif |
| 53 | +} |
0 commit comments