Search in sources :

Example 1 with MinecraftBlockDamageSource

use of org.spongepowered.common.event.damage.MinecraftBlockDamageSource in project SpongeCommon by SpongePowered.

the class MixinEntity method preSetOnFire.

@Inject(method = "setOnFireFromLava()V", at = @At(value = "FIELD", target = LAVA_DAMAGESOURCE_FIELD, opcode = Opcodes.GETSTATIC))
public // setOnFireFromLava
void preSetOnFire(CallbackInfo callbackInfo) {
    if (!this.world.isRemote) {
        this.originalLava = DamageSource.LAVA;
        AxisAlignedBB bb = this.getEntityBoundingBox().grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D);
        Location<World> location = DamageEventHandler.findFirstMatchingBlock((net.minecraft.entity.Entity) (Object) this, bb, block -> block.getMaterial() == Material.LAVA);
        DamageSource.LAVA = new MinecraftBlockDamageSource("lava", location).setFireDamage();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) MinecraftBlockDamageSource(org.spongepowered.common.event.damage.MinecraftBlockDamageSource) World(org.spongepowered.api.world.World) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with MinecraftBlockDamageSource

use of org.spongepowered.common.event.damage.MinecraftBlockDamageSource in project SpongeCommon by SpongePowered.

the class MixinBlockCactus method preSetOnFire.

@Inject(method = "onEntityCollidedWithBlock", at = @At(value = "FIELD", target = CACTUS_DAMAGE_FIELD, opcode = Opcodes.GETSTATIC))
public void preSetOnFire(net.minecraft.world.World worldIn, BlockPos pos, IBlockState state, Entity entityIn, CallbackInfo callbackInfo) {
    if (!worldIn.isRemote) {
        this.originalCactus = DamageSource.CACTUS;
        Location<World> location = new Location<>((World) worldIn, pos.getX(), pos.getY(), pos.getZ());
        DamageSource.CACTUS = new MinecraftBlockDamageSource("cactus", location);
    }
}
Also used : MinecraftBlockDamageSource(org.spongepowered.common.event.damage.MinecraftBlockDamageSource) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with MinecraftBlockDamageSource

use of org.spongepowered.common.event.damage.MinecraftBlockDamageSource in project SpongeCommon by SpongePowered.

the class MixinEntity method preFire.

@Inject(method = "dealFireDamage", at = @At(value = "FIELD", target = FIRE_DAMAGESOURCE_FIELD, opcode = Opcodes.GETSTATIC))
public void preFire(CallbackInfo callbackInfo) {
    // Sponge Start - Find the fire block!
    if (!this.world.isRemote) {
        this.originalInFire = DamageSource.IN_FIRE;
        AxisAlignedBB bb = this.getEntityBoundingBox().grow(-0.001D, -0.001D, -0.001D);
        Location<World> location = DamageEventHandler.findFirstMatchingBlock((net.minecraft.entity.Entity) (Object) this, bb, block -> block.getBlock() == Blocks.FIRE || block.getBlock() == Blocks.FLOWING_LAVA || block.getBlock() == Blocks.LAVA);
        DamageSource.IN_FIRE = new MinecraftBlockDamageSource("inFire", location).setFireDamage();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) MinecraftBlockDamageSource(org.spongepowered.common.event.damage.MinecraftBlockDamageSource) World(org.spongepowered.api.world.World) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

World (org.spongepowered.api.world.World)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 MinecraftBlockDamageSource (org.spongepowered.common.event.damage.MinecraftBlockDamageSource)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 Location (org.spongepowered.api.world.Location)1