use of org.spongepowered.common.bridge.world.damagesource.DamageSourceBridge in project SpongeCommon by SpongePowered.
the class BaseFireBlockMixin method impl$spongeRedirectForFireDamage.
@Redirect(method = "entityInside", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z"))
private boolean impl$spongeRedirectForFireDamage(final Entity self, final DamageSource source, final float damage, final BlockState blockState, final Level world, final BlockPos blockPos, final Entity entity) {
if (self.level.isClientSide) {
// Short Circuit
return self.hurt(source, damage);
}
try {
final ServerLocation location = ServerLocation.of((ServerWorld) world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
final DamageSource fire = MinecraftBlockDamageSource.ofFire("inFire", location, true);
((DamageSourceBridge) fire).bridge$setFireSource();
return self.hurt(DamageSource.IN_FIRE, damage);
} finally {
// Since "source" is already the DamageSource.IN_FIRE object, we can re-use it to re-assign.
((DamageSourceBridge) source).bridge$setFireSource();
}
}
use of org.spongepowered.common.bridge.world.damagesource.DamageSourceBridge in project SpongeCommon by SpongePowered.
the class MagmaBlockMixin method impl$swapDamageSourceForMagma.
@Redirect(method = "stepOn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z"))
private boolean impl$swapDamageSourceForMagma(Entity entity, DamageSource source, float damage, Level world, BlockPos pos, Entity original) {
if (!world.isClientSide) {
try {
final ServerLocation location = ServerLocation.of((ServerWorld) world, pos.getX(), pos.getY(), pos.getZ());
final DamageSource hotFloor = MinecraftBlockDamageSource.ofFire("hotFloor", location, false);
((DamageSourceBridge) (Object) hotFloor).bridge$setHotFloorSource();
return entity.hurt(DamageSource.HOT_FLOOR, damage);
} finally {
((DamageSourceBridge) source).bridge$setHotFloorSource();
}
}
return entity.hurt(source, damage);
}
Aggregations