|
| 1 | +package net.modfest.fireblanket.mixin.adventure_fix; |
| 2 | + |
| 3 | +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; |
| 4 | +import com.llamalad7.mixinextras.sugar.Local; |
| 5 | +import net.minecraft.entity.Entity; |
| 6 | +import net.minecraft.entity.projectile.SmallFireballEntity; |
| 7 | +import net.minecraft.server.network.ServerPlayerEntity; |
| 8 | +import net.minecraft.server.world.ServerWorld; |
| 9 | +import net.minecraft.util.math.BlockPos; |
| 10 | +import net.minecraft.world.GameRules; |
| 11 | +import org.spongepowered.asm.mixin.Mixin; |
| 12 | +import org.spongepowered.asm.mixin.injection.At; |
| 13 | + |
| 14 | +/** |
| 15 | + * Some mods apparently will spawn fire charges. Reduce the griefing potential. |
| 16 | + * <p> |
| 17 | + * As an amusing aside, it makes Fireblanket live up to its name. |
| 18 | + * |
| 19 | + * @author Ampflower |
| 20 | + **/ |
| 21 | +@Mixin(SmallFireballEntity.class) |
| 22 | +public abstract class MixinSmallFireballEntity { |
| 23 | + |
| 24 | + @ModifyExpressionValue( |
| 25 | + method = "onBlockHit", |
| 26 | + at = @At( |
| 27 | + value = "INVOKE", |
| 28 | + target = "Lnet/minecraft/world/World;isAir(Lnet/minecraft/util/math/BlockPos;)Z" |
| 29 | + ) |
| 30 | + ) |
| 31 | + private static boolean fireblanket$madeAccurate( |
| 32 | + final boolean original, |
| 33 | + final @Local ServerWorld world, |
| 34 | + final @Local Entity entity, |
| 35 | + final @Local BlockPos blockPos |
| 36 | + ) { |
| 37 | + if (!original) { |
| 38 | + return false; |
| 39 | + } |
| 40 | + |
| 41 | + if (entity == null && !world.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) { |
| 42 | + return false; |
| 43 | + } |
| 44 | + |
| 45 | + return !(entity instanceof ServerPlayerEntity player) || player.canModifyAt(world, blockPos); |
| 46 | + } |
| 47 | +} |
0 commit comments